### Example of screen setup Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Demonstrates how to initialize the video mode, attempting a specific resolution and color type, and falling back to a default if the initial attempt fails. ```APIDOC ## Example of screen setup ### Description Demonstrates how to initialize the video mode, attempting a specific resolution and color type, and falling back to a default if the initial attempt fails. ### Method N/A (This is a code example, not an API endpoint) ### Endpoint N/A ### Parameters N/A ### Request Example ```c grub_err_t rc; /* Try to initialize video mode 1024 x 768 with direct RGB. */ rc = grub_video_setup (1024, 768, GRUB_VIDEO_MODE_TYPE_RGB); if (rc != GRUB_ERR_NONE) { /* Fall back to standard VGA Index Color mode. */ rc = grub_video_setup (640, 480, GRUB_VIDEO_MODE_TYPE_INDEX); if (rc != GRUB_ERR_NONE) { /* Handle error. */ } } ``` ### Response N/A ``` -------------------------------- ### Example Screen Setup with GRUB Video API Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Demonstrates setting up the video mode, attempting a high-resolution RGB mode first, and falling back to a standard VGA Index Color mode if the initial attempt fails. ```c grub_err_t rc; /* Try to initialize video mode 1024 x 768 with direct RGB. */ rc = grub_video_setup (1024, 768, GRUB_VIDEO_MODE_TYPE_RGB); if (rc != GRUB_ERR_NONE) { /* Fall back to standard VGA Index Color mode. */ rc = grub_video_setup (640, 480, GRUB_VIDEO_MODE_TYPE_INDEX); if (rc != GRUB_ERR_NONE) { /* Handle error. */ } } ``` -------------------------------- ### Start QEMU in GDB Stub Mode (Shell) Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This command starts a QEMU instance for the i386-pc target, booting from 'disk.img'. It pauses execution and waits for a GDB instance to attach, enabling debugging. Ensure 'disk.img' is replaced with your actual disk image. ```shell qemu-system-i386 -drive file=disk.img,format=raw \ -device virtio-scsi-pci,id=scsi0 -S -s ``` -------------------------------- ### x86 Assembly for GRUB2 Bootloader Setup Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This x86 assembly code snippet demonstrates the initial setup for a GRUB2 bootloader. It handles BSS cleaning and other necessary preparations before calling the main C function. This is a foundational part of the bootloader's startup sequence. ```assembly .globl _start _start: movl $_bss_start, %edi movl $_end, %ecx subl %edi, %ecx xorl %eax, %eax cld rep stosb call main ``` -------------------------------- ### Debugging GRUB2 with GDB and QEMU Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This snippet outlines the setup and commands for debugging GRUB2 using GDB and QEMU. It assumes GDB and QEMU binaries are installed and GRUB2 has been compiled with debugging symbols. The focus is on x86_64 and i386 architectures. ```bash # Ensure GDB and QEMU are installed (Debian example): sudo apt install gdb qemu-system-x86 # Example of starting QEMU with a GRUB2 image and attaching GDB: qemu-system-x86_64 -drive file=grub.img,format=raw -S -s gdb grub-core/grub.exec # Inside GDB, connect to QEMU: target remote :1234 ``` -------------------------------- ### grub_video_create_render_target Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Creates a render target with the specified width, height, and mode type. The `mode_type` guides the driver in selecting features (e.g., index color, RGB, alpha). ```APIDOC ## grub_video_create_render_target ### Description Creates a render target with the specified width, height, and mode type. The `mode_type` guides the driver in selecting features (e.g., index color, RGB, alpha). ### Method N/A (This is a function prototype, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```c struct grub_video_render_target *new_target; grub_video_create_render_target(&new_target, 200, 150, GRUB_VIDEO_MODE_TYPE_RGB); ``` ### Response #### Success Response (200) N/A (Function returns grub_err_t) #### Response Example ``` GRUB_ERR_NONE ``` ``` -------------------------------- ### Connect GDB and Load GRUB2 Symbols (Shell) Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This sequence of commands navigates to the directory containing the 'gdb_grub' script and debug symbol files, then starts GDB with the script. The 'gdb_grub' script automatically connects to the QEMU instance and sets up debugging, including handling runtime module loading. ```shell cd $(dirname /path/to/script/gdb_grub) gdb -x gdb_grub ``` -------------------------------- ### Defining GUI Components in GRUB gfxmenu Theme Files Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Illustrates the syntax for defining GUI components and containers within a GRUB gfxmenu theme file. This example shows how to create nested 'vbox' and 'label' components. ```text +vbox{ +label { text="Hello" } +label { text="World" } } ``` -------------------------------- ### Setup GRUB Video Mode Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Configures the video driver to select and switch to the best possible video mode based on provided parameters. It supports index color, RGB, and double-buffered modes. If parameters are zero, it attempts to auto-detect the best mode. Upon successful mode switch, it sets the active rendering target to the screen and maximizes the viewport. ```c grub_err_t grub_video_setup (unsigned int width, unsigned int height, unsigned int mode_type); ``` -------------------------------- ### Get Active Render Target with GRUB Video API Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Retrieves the currently active render target. The returned target can be used with `grub_video_set_active_render_target`. ```c grub_err_t grub_video_get_active_render_target (struct grub_video_render_target **target); ``` -------------------------------- ### Create Render Target with GRUB Video API Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Creates a render target based on provided dimensions and mode type. `mode_type` guides the driver in selecting desired features like index color, RGB, or alpha. ```c grub_err_t grub_video_create_render_target (struct grub_video_render_target **result, unsigned int width, unsigned int height, unsigned int mode_type); ``` ```c struct grub_video_render_target { /* This is private data for video driver. Should not be accessed from elsewhere directly. */ }; ``` -------------------------------- ### Regenerate gost-sb.h using GCC Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This snippet shows the command to compile and run a C program to regenerate the gost-sb.h file, which is part of the libgcrypt integration process for GRUB. It requires GCC to be installed. ```bash gcc -o gost-s-box gost-s-box.c ./gost-s-box gost-sb.h ``` -------------------------------- ### GRUB Video: Get bitmap mode info Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This C function retrieves detailed format information about a bitmap and stores it in a grub_video_mode_info structure. It requires a pointer to the bitmap. ```c void grub_video_bitmap_get_mode_info (struct grub_video_bitmap *bitmap, struct grub_video_mode_info *mode_info); ``` -------------------------------- ### Get GRUB Video Viewport Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Queries the current viewport dimensions. This allows software developers to understand the active drawing area and optimize content rendering accordingly. ```c grub_err_t grub_video_get_viewport (unsigned int *x, unsigned int *y, unsigned int *width, unsigned int *height); ``` -------------------------------- ### Get GRUB Video Blit Format Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Queries the optimal blitting format for the specified video mode. It returns an enumeration indicating whether to follow exact field and mask information, use a generic optimized format (like R8G8B8A8), or if color decoding is needed for index color modes. Use `grub_video_get_info` for color coding details in generic formats. ```c enum grub_video_blit_format grub_video_get_blit_format (struct grub_video_mode_info *mode_info); ``` ```c enum grub_video_blit_format { /* Follow exactly field & mask information. */ GRUB_VIDEO_BLIT_FORMAT_RGBA, /* Make optimization assumption. */ GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8, /* Follow exactly field & mask information. */ GRUB_VIDEO_BLIT_FORMAT_RGB, /* Make optimization assumption. */ GRUB_VIDEO_BLIT_FORMAT_R8G8B8, /* When needed, decode color or just use value as is. */ GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR }; ``` -------------------------------- ### GRUB Video: Set up and fill console viewport Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This C code snippet demonstrates how to query the existing video viewport, fill it with a background color, set a new console viewport with adjusted dimensions, and then fill this new viewport with a console background color and display a character. ```c grub_uint32_t x, y, width, height; grub_video_color_t color; struct grub_font_glyph glyph; grub_err_t rc; /* Query existing viewport. */ grub_video_get_viewport (&x, &y, &width, &height); /* Fill background. */ color = grub_video_map_color (GRUB_COLOR_BACKGROUND); grub_video_fill_rect (color, 0, 0, width, height); /* Setup console viewport. */ grub_video_set_viewport (x + 10, y + 10, width - 20, height - 20); grub_video_get_viewport (&x, &y, &width, &height); color = grub_video_map_color (GRUB_COLOR_CONSOLE_BACKGROUND); grub_video_fill_rect (color, 0, 0, width, height); /* Draw text to viewport. */ color = grub_video_map_color (GRUB_COLOR_CONSOLE_TEXT); grub_font_get_glyph ('X', &glyph); grub_video_blit_glyph (&glyph, color, 0, 0); ``` -------------------------------- ### Get GRUB Video Palette Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Queries indexed color palettes from video modes. It copies colors from emulated palettes in RGB mode or reads from hardware palettes in Indexed Color modes. Color values are converted to the structure's format. The function takes a starting index, the number of colors to retrieve, and a pointer to store palette data. ```c struct grub_video_palette_data { grub_uint8_t r; /* Red color value (0-255). */ grub_uint8_t g; /* Green color value (0-255). */ grub_uint8_t b; /* Blue color value (0-255). */ grub_uint8_t a; /* Reserved bits value (0-255). */ }; grub_err_t grub_video_get_palette (unsigned int start, unsigned int count, struct grub_video_palette_data *palette_data); ``` -------------------------------- ### C 'Hello, world' Implementation for GRUB2 Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev A simple C implementation for a GRUB2 bootloader, displaying 'Hello, world' to the console. It includes a basic putchar function and a main function that iterates through the message string. This serves as a basic test for a new port. ```c static const char msg[] = "Hello, world"; void putchar (int c) { ... } void main (void) { const char *ptr = msg; while (*ptr) putchar (*ptr++); while (1); } ``` -------------------------------- ### Test GRUB Module Loading Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This command demonstrates how to create a GRUB image that includes a specific module, in this case, 'hello'. After creating the image, the 'hello' module can be executed within the GRUB shell to test module loading functionality. ```shell ./grub-mkimage -d grub-core -O $format_id -o test.img hello ``` -------------------------------- ### GRUB Video: Get bitmap width Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This C function returns the width of a given bitmap. It takes a pointer to a grub_video_bitmap structure as input. ```c unsigned int grub_video_bitmap_get_width (struct grub_video_bitmap *bitmap); ``` -------------------------------- ### GRUB Video: Get bitmap height Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This C function returns the height of a given bitmap. It takes a pointer to a grub_video_bitmap structure as input. ```c unsigned int grub_video_bitmap_get_height (struct grub_video_bitmap *bitmap); ``` -------------------------------- ### Get GRUB Video Region Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Queries the current dimensions of the redraw region. This function retrieves the x, y, width, and height of the area currently designated for redrawing. ```c grub_err_t grub_video_get_region (unsigned int *x, unsigned int *y, unsigned int *width, unsigned int *height); ``` -------------------------------- ### Build and Configure GRUB for a New Platform Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev These shell commands are used to bootstrap, configure, and compile the GRUB bootloader for a specific target CPU and platform. The configure script requires specifying the target architecture and platform, along with toolchain executables like TARGET_CC and OBJCOPY. Make then compiles the source code. ```shell ./bootstrap ./configure --target=$cpu --with-platform=$platform TARGET_CC=.. OBJCOPY=... STRIP=... make > /dev/null ``` -------------------------------- ### Create a GRUB Bootable Image Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This command utilizes grub-mkimage to create a bootable GRUB image. It specifies the GRUB core directory, the desired output format ID, and the output file name. This is a fundamental step in generating the bootloader for the target platform. ```shell ./grub-mkimage -d grub-core -O $format_id -o test.img ``` -------------------------------- ### Get GRUB Video Area Status Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Queries the current area drawing status. This function retrieves the status that determines how draw commands are clipped or processed within defined regions. ```c grub_err_r grub_video_get_area_status (grub_video_area_status_t *area_status); ``` -------------------------------- ### C-style Single-Line Comments in GRUB Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Demonstrates the correct placement and formatting of C-style single-line comments in GRUB code. Comments can precede code or be placed alongside declarations. ```c /* The page # that is the front buffer. */ int displayed_page; int render_page; /* The page # that is the back buffer. */ ``` -------------------------------- ### Palette Manipulation Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Functions for setting and getting indexed color palettes. These functions allow for the manipulation of color data for both RGB and Indexed Color modes, converting values as needed for the current video mode. ```APIDOC ## grub_video_set_palette ### Description Used to setup indexed color palettes. If mode is RGB mode, colors will be set to emulated palette data. In Indexed Color modes, palettes will be set to hardware. Color values will be converted to suit requirements of the video mode. `start` will tell what hardware color index (or emulated color index) will be set to according information in first indice of `palette_data`, after that both hardware color index and `palette_data` index will be incremented until `count` number of colors have been set. ### Method N/A (Function Call) ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **start** (unsigned int) - The starting hardware or emulated color index. - **count** (unsigned int) - The number of colors to set. - **palette_data** (struct grub_video_palette_data *) - A pointer to an array of palette data structures. - **r** (grub_uint8_t) - Red color value (0-255). - **g** (grub_uint8_t) - Green color value (0-255). - **b** (grub_uint8_t) - Blue color value (0-255). - **a** (grub_uint8_t) - Reserved bits value (0-255). ### Request Example ```c struct grub_video_palette_data my_palette[3] = { {255, 0, 0, 0}, // Red {0, 255, 0, 0}, // Green {0, 0, 255, 0} // Blue }; grub_video_set_palette(0, 3, my_palette); ``` ### Response #### Success Response (grub_err_t) Returns GRUB_ERR_NONE on success, or an error code on failure. #### Response Example ``` GRUB_ERR_NONE ``` ## grub_video_get_palette ### Description Used to query indexed color palettes. If mode is RGB mode, colors will be copied from emulated palette data. In Indexed Color modes, palettes will be read from hardware. Color values will be converted to suit structure format. `start` will tell what hardware color index (or emulated color index) will be used as a source for first indice of `palette_data`, after that both hardware color index and `palette_data` index will be incremented until `count` number of colors have been read. ### Method N/A (Function Call) ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **start** (unsigned int) - The starting hardware or emulated color index. - **count** (unsigned int) - The number of colors to retrieve. - **palette_data** (struct grub_video_palette_data *) - A pointer to an array of palette data structures to be filled. - **r** (grub_uint8_t) - Red color value (0-255). - **g** (grub_uint8_t) - Green color value (0-255). - **b** (grub_uint8_t) - Blue color value (0-255). - **a** (grub_uint8_t) - Reserved bits value (0-255). ### Request Example ```c struct grub_video_palette_data retrieved_palette[3]; grub_video_get_palette(0, 3, retrieved_palette); // retrieved_palette now contains the color data ``` ### Response #### Success Response (grub_err_t) Returns GRUB_ERR_NONE on success, or an error code on failure. #### Response Example ``` GRUB_ERR_NONE ``` ``` -------------------------------- ### Multi-Line Comments in GRUB Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Illustrates the acceptable formatting for multi-line comments in GRUB. All lines after the first must be aligned with the first line, and asterisks should be repeated on each subsequent line. ```c /* * This is a comment * which spans multiple lines. * It is long. */ ``` -------------------------------- ### GRUB Video: Get bitmap data pointer Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This C function returns a void pointer to the raw bitmap data. Users must exercise caution when accessing this data to avoid buffer overflows, as there is no bounds checking. ```c void * grub_video_bitmap_get_data (struct grub_video_bitmap *bitmap); ``` -------------------------------- ### Registering gfxmenu Module in GRUB 2 Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This snippet illustrates the process of registering the gfxmenu module within the GRUB 2 startup sequence. It shows the function calls involved when `gfxmenu.mod` is loaded and registers itself using `grub_menu_viewer_register()`. ```c /* ... other startup functions ... */ GRUB_MOD_INIT (gfxmenu) [gfxmenu/gfxmenu.c] grub_menu_viewer_register [kern/menu_viewer.c] /* ... subsequent functions ... */ ``` -------------------------------- ### GRUB2 gentpl.py Supported Platforms List Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This Python snippet from gentpl.py lists all supported GRUB2 platforms. Similar to configure.ac, adding a new platform here is necessary for the build system to recognize and generate configurations for it. ```python GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_multiboot", "i386_ieee1275", "x86_64_efi", "mips_loongson", "sparc64_ieee1275", "powerpc_ieee1275", "mips_arc", "ia64_efi", "mips_qemu_mips", "s390_mainframe" ] ``` -------------------------------- ### Run Debug OVMF and Capture GRUB2 Logs with QEMU Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This command launches QEMU with a debug build of OVMF, directing its serial debug messages to a file named 'debug.log'. It's used to obtain GRUB2 load addresses and other debug information from the EFI firmware. Assumes 'disk.img' is configured to boot GRUB2 EFI. ```bash qemu-system-x86_64 -bios /path/to/debug/OVMF.fd \ -drive file=disk.img,format=raw \ -device virtio-scsi-pci,id=scsi0 \ -debugcon file:debug.log -global isa-debugcon.iobase=0x402 ``` -------------------------------- ### GRUB Video: Create a bitmap Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This C function creates a new bitmap with specified dimensions and blitting format. The allocated bitmap data can be modified and then blitted to a rendering target using grub_video_blit_bitmap. ```c grub_err_t grub_video_bitmap_create (struct grub_video_bitmap **bitmap, unsigned int width, unsigned int height, enum grub_video_blit_format blit_format) ``` -------------------------------- ### Get GRUB Video Mode Information Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Retrieves detailed information about the active video rendering target. This information can be used by other GRUB components, such as image loaders, to optimize image conversion for the current screen format. It returns `GRUB_ERR_BAD_DEVICE` if no video driver is configured, otherwise fills a `grub_video_mode_info` structure and returns `GRUB_ERR_NONE`. ```c grub_err_t grub_video_get_info (struct grub_video_mode_info *mode_info); ``` ```c struct grub_video_mode_info { /* Width of the screen. */ unsigned int width; /* Height of the screen. */ unsigned int height; /* Mode type bitmask. Contains information like is it Index color or RGB mode. */ unsigned int mode_type; /* Bits per pixel. */ unsigned int bpp; /* Bytes per pixel. */ unsigned int bytes_per_pixel; /* Pitch of one scanline. How many bytes there are for scanline. */ unsigned int pitch; /* In index color mode, number of colors. In RGB mode this is 256. */ unsigned int number_of_colors; /* Optimization hint how binary data is coded. */ enum grub_video_blit_format blit_format; /* How many bits are reserved for red color. */ unsigned int red_mask_size; /* What is location of red color bits. In Index Color mode, this is 0. */ unsigned int red_field_pos; /* How many bits are reserved for green color. */ unsigned int green_mask_size; /* What is location of green color bits. In Index Color mode, this is 0. */ unsigned int green_field_pos; /* How many bits are reserved for blue color. */ unsigned int blue_mask_size; /* What is location of blue color bits. In Index Color mode, this is 0. */ unsigned int blue_field_pos; /* How many bits are reserved in color. */ unsigned int reserved_mask_size; /* What is location of reserved color bits. In Index Color mode, this is 0. */ unsigned int reserved_field_pos; }; ``` -------------------------------- ### Iterating Recursively Through GUI Components in GRUB gfxmenu Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Shows how to iterate through all descendant components of a given root component in the gfxmenu GUI. The `grub_gui_iterate_recursively` function calls a provided callback for each component in the subtree. ```c /* * Calls the 'callback' function for every component that is a descendant * of 'root' in the component tree. Passes the component and 'userdata' * to the callback. */ void grub_gui_iterate_recursively (grub_gui_component_t root, void (*callback) (grub_gui_component_t, void *), void *userdata); ``` -------------------------------- ### Set GRUB Video Palette Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Sets indexed color palettes for video modes. It can emulate palettes in RGB mode or set hardware palettes in Indexed Color modes. Color values are converted to suit the video mode's requirements. The function takes a starting index, the number of colors to set, and a pointer to palette data. ```c struct grub_video_palette_data { grub_uint8_t r; /* Red color value (0-255). */ grub_uint8_t g; /* Green color value (0-255). */ grub_uint8_t b; /* Blue color value (0-255). */ grub_uint8_t a; /* Reserved bits value (0-255). */ }; grub_err_t grub_video_set_palette (unsigned int start, unsigned int count, struct grub_video_palette_data *palette_data); ``` -------------------------------- ### Load GRUB2 Symbols with GDB for x86_64-efi Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This command loads GRUB2 symbols into GDB for debugging the x86_64-efi target. It assumes QEMU is running and waiting for a debugger connection, and that `gdb_grub` is in the current working directory. The `-ex` option executes a GDB command to load symbols, specifying the address of the text section. ```bash gdb -x gdb_grub -ex 'dynamic_load_symbols address of .text section' ``` -------------------------------- ### GRUB Video: Load a bitmap Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This C function attempts to load a bitmap from a specified file. It utilizes registered bitmap loaders. If the format is unrecognized or unsupported, it returns GRUB_ERR_BAD_FILE_TYPE. ```c grub_err_t grub_video_bitmap_load (struct grub_video_bitmap **bitmap, const char *filename); ``` -------------------------------- ### GRUB2 configure.ac Supported Platform List Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This part of configure.ac lists all supported CPU-platform combinations for GRUB2. Adding a new platform to this list is essential for GRUB2 to recognize and build for it. ```autoconf case "$target_cpu"-"$platform" in i386-efi) ;; x86_64-efi) ;; i386-pc) ;; i386-multiboot) ;; i386-coreboot) ;; ... esac ``` -------------------------------- ### Finding GUI Components by ID in GRUB gfxmenu Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Demonstrates how to find a specific GUI component within the gfxmenu component tree using its ID. The `grub_gui_find_by_id` function recursively searches the tree and executes a callback function for matching components. ```c /* * Recursively traverses the component tree rooted at 'root'. * For each component with an ID equal to 'id', calls the 'callback' * function with the matching component and 'userdata'. */ char *grub_gui_find_by_id (grub_gui_component_t root, const char *id, void (*callback) (grub_gui_component_t, void *), void *userdata); ``` -------------------------------- ### Blit Bitmap - GRUB Video Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Blits a bitmap to the viewport with specified coordinates, dimensions, and a blitting operator. Supports clipping to viewport boundaries and offsets for source data. Negative coordinates and offsets are allowed. The 'oper' parameter determines if the source pixel replaces or blends with the destination. Bitmap data should be created or loaded using grub_video_bitmap_create or grub_video_bitmap_load. ```c struct grub_video_bitmap { /* TBD. */ }; enum grub_video_blit_operators { GRUB_VIDEO_BLIT_REPLACE, GRUB_VIDEO_BLIT_BLEND }; grub_err_t grub_video_blit_bitmap (struct grub_video_bitmap *bitmap, enum grub_video_blit_operators oper, int x, int y, int offset_x, int offset_y, unsigned int width, unsigned int height); ``` -------------------------------- ### Download and Integrate jsmn JSON Parser Header Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev This command downloads a specific version of the jsmn.h header file using `curl` and saves it to the GRUB core library's JSON directory. This is a simple way to include the minimalistic JSON parser into the project. ```shell curl -L https://raw.githubusercontent.com/zserge/jsmn/v1.1.0/jsmn.h \ -o grub-core/lib/json/jsmn.h ``` -------------------------------- ### Fill Rectangle - GRUB Video Source: https://www.gnu.org/software/grub/manual/grub-dev/grub-dev Fills a rectangular area defined by coordinates (x, y) and dimensions (width, height) with a specified color. Negative coordinates are supported for positioning relative to the viewport, and the area will be clipped to the viewport boundaries. The color parameter must be obtained using a mapping function like grub_video_map_color, grub_video_map_rgb, or grub_video_map_rgba. ```c grub_err_t grub_video_fill_rect (grub_video_color_t color, int x, int y, unsigned int width, unsigned int height); ```