drivers/firmware/efi/libstub/gop.c
Source file repositories/reference/linux-study-clean/drivers/firmware/efi/libstub/gop.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/efi/libstub/gop.c- Extension
.c- Size
- 13571 bytes
- Lines
- 533
- Domain
- Driver Families
- Bucket
- drivers/firmware
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/ctype.hlinux/efi.hlinux/screen_info.hlinux/string.hasm/efi.hasm/setup.hvideo/edid.hefistub.h
Detected Declarations
struct matchenum efi_cmdline_optionfunction parse_modenumfunction parse_resfunction parse_autofunction parse_listfunction efi_parse_option_graphicsfunction choose_mode_modenumfunction choose_modefunction pixel_bppfunction match_resfunction choose_mode_resfunction match_autofunction choose_mode_autofunction match_listfunction choose_mode_listfunction set_modefunction find_bitsfunction setup_screen_infofunction setup_edid_infofunction find_handle_with_primary_gopfunction for_each_efi_handlefunction efi_setup_graphics
Annotated Snippet
struct match {
u32 mode;
u32 area;
u8 depth;
};
static bool match_auto(const efi_graphics_output_mode_info_t *info, u32 mode, void *ctx)
{
u32 area = info->horizontal_resolution * info->vertical_resolution;
efi_pixel_bitmask_t pi = info->pixel_information;
int pf = info->pixel_format;
u8 depth = pixel_bpp(pf, pi);
struct match *m = ctx;
if (pf == PIXEL_BLT_ONLY || pf >= PIXEL_FORMAT_MAX)
return false;
if (area > m->area || (area == m->area && depth > m->depth))
*m = (struct match){ mode, area, depth };
return false;
}
static u32 choose_mode_auto(efi_graphics_output_protocol_t *gop)
{
struct match match = {};
choose_mode(gop, match_auto, &match);
return match.mode;
}
static bool match_list(const efi_graphics_output_mode_info_t *info, u32 mode, void *ctx)
{
efi_pixel_bitmask_t pi = info->pixel_information;
u32 cur_mode = (unsigned long)ctx;
int pf = info->pixel_format;
const char *dstr;
u8 depth = 0;
bool valid;
valid = !(pf == PIXEL_BLT_ONLY || pf >= PIXEL_FORMAT_MAX);
switch (pf) {
case PIXEL_RGB_RESERVED_8BIT_PER_COLOR:
dstr = "rgb";
break;
case PIXEL_BGR_RESERVED_8BIT_PER_COLOR:
dstr = "bgr";
break;
case PIXEL_BIT_MASK:
dstr = "";
depth = pixel_bpp(pf, pi);
break;
case PIXEL_BLT_ONLY:
dstr = "blt";
break;
default:
dstr = "xxx";
break;
}
efi_printk("Mode %3u %c%c: Resolution %ux%u-%s%.0hhu\n",
mode,
(mode == cur_mode) ? '*' : ' ',
!valid ? '-' : ' ',
info->horizontal_resolution,
info->vertical_resolution,
dstr, depth);
return false;
}
static u32 choose_mode_list(efi_graphics_output_protocol_t *gop)
{
efi_graphics_output_protocol_mode_t *mode = efi_table_attr(gop, mode);
unsigned long cur_mode = efi_table_attr(mode, mode);
u32 max_mode = efi_table_attr(mode, max_mode);
efi_input_key_t key;
efi_status_t status;
efi_printk("Available graphics modes are 0-%u\n", max_mode-1);
efi_puts(" * = current mode\n"
" - = unusable mode\n");
choose_mode(gop, match_list, (void *)cur_mode);
efi_puts("\nPress any key to continue (or wait 10 seconds)\n");
status = efi_wait_for_key(10 * EFI_USEC_PER_SEC, &key);
if (status != EFI_SUCCESS && status != EFI_TIMEOUT) {
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/ctype.h`, `linux/efi.h`, `linux/screen_info.h`, `linux/string.h`, `asm/efi.h`, `asm/setup.h`, `video/edid.h`.
- Detected declarations: `struct match`, `enum efi_cmdline_option`, `function parse_modenum`, `function parse_res`, `function parse_auto`, `function parse_list`, `function efi_parse_option_graphics`, `function choose_mode_modenum`, `function choose_mode`, `function pixel_bpp`.
- Atlas domain: Driver Families / drivers/firmware.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.