boot: add basic multiboot support

Turns out writing your own bootloader from scratch
is something you probably don't wanna be bothered
with when your main goal is writing an entire
operating system.  Blessed be the souls of the
maniacs who gave us GRUB, and punched be their
faces for writing such inconsistent documentation.
main
anna 3 years ago
parent 8f2b378f7c
commit c7eb58b930
Signed by: fef
GPG Key ID: EC22E476DC2D3D84

3
.gitignore vendored

@ -4,3 +4,6 @@
# VS Code settings
/.vscode/*
!/.vscode/*.template.json
# for testing w/ QEMU
*.qcow2

@ -11,34 +11,56 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
endif()
include(cmake/config.cmake)
configure_file(
"${CMAKE_SOURCE_DIR}/include/gay/config.h.in"
"${CMAKE_BINARY_DIR}/include/gay/config.h"
)
include("arch/${ARCH}/config/toolchain.cmake")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffreestanding")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -D_ASM_SOURCE")
if(DEBUG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Og -ggdb")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Og -ggdb")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
endif()
# --whole-archive ensures no (seemingly) unused symbols
# like the multiboot table are omitted from the archive
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -nodefaultlibs -static --whole-archive")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib -nodefaultlibs -static")
add_library(gaybsd INTERFACE)
set(GAY_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/arch/${ARCH}/include
${CMAKE_CURRENT_BINARY_DIR}/include
)
set(GAY_COMPILE_OPTIONS
-nodefaultlibs
-nostartfiles
-fno-builtin
-Wall
-Wno-sign-conversion
-Wstrict-prototypes
-Wredundant-decls
-Wnested-externs
-Wbad-function-cast
-Wshadow
-Wsign-compare
-Wunreachable-code
-Wwrite-strings
-Wconversion
-Waggregate-return
-Winline
-Wcast-align
add_subdirectory("boot")
add_executable(gaybsd_image.elf)
# TODO: find a way around this hack
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/_empty.c" "")
target_sources(gaybsd_image.elf PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/_empty.c")
target_link_libraries(gaybsd_image.elf PRIVATE
gay_boot
)
add_subdirectory("boot/${ARCH}-${BOOT_TYPE}")
add_custom_target(gaybsd_image DEPENDS gaybsd_image.elf)
add_custom_command(
TARGET gaybsd_image
COMMAND "${CMAKE_OBJCOPY}"
ARGS
-O binary
"$<TARGET_FILE:gaybsd_image.elf>"
"${CMAKE_BINARY_DIR}/gaybsd_image"
)
add_custom_target(gaybsd ALL DEPENDS
gaybsd_image
)
# This file is part of GayBSD.
# Copyright (c) 2021 fef <owo@fef.moe>.

@ -0,0 +1,71 @@
/* See the end of this file for copyright and license terms. */
OUTPUT_FORMAT("elf32-i386")
OUTPUT_ARCH(i386)
KERNEL_ORIGIN = DEFINED(KERNEL_ORIGIN) ? KERNEL_ORIGIN : 0x00100000;
STACK_SIZE = 0x1000;
/* not strictly needed because we produce a binary image but can't hurt */
ENTRY(_start)
SECTIONS {
. = KERNEL_ORIGIN;
_image_start = .;
_kernel_start = .;
.text : {
. = ALIGN(8);
_text_start = .;
/*
* This is where the multiboot header is stored which grub2
* or any other compliant bootloader picks up, don't move away
*/
KEEP(*(.multiboot))
KEEP(*(.text .text.*))
_text_end = .;
}
.rodata : {
. = ALIGN(8);
_rodata_start = .;
*(.rodata .rodata.*)
_rodata_end = .;
}
_kernel_end = .;
.bss(NOLOAD) : {
. = ALIGN(8);
_bss_start = . ;
*(.bss .bss.*)
*(COMMON)
. = ALIGN(8);
_bss_end = . ;
}
.stack(NOLOAD) : {
. = ALIGN(8);
_stack_start = .;
. = . + STACK_SIZE;
. = ALIGN(8);
_stack_end = .;
}
_image_end = .;
}
/*
* This file is part of GayBSD.
* Copyright (c) 2021 fef <owo@fef.moe>.
*
* GayBSD is nonviolent software: you may only use, redistribute, and/or
* modify it under the terms of the Cooperative Nonviolent Public License
* (CNPL) as found in the LICENSE file in the source code root directory
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
* of the license, or (at your option) any later version.
*
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
* permitted by applicable law. See the CNPL for details.
*/

@ -0,0 +1,17 @@
/* See the end of this file for copyright and license terms. */
KERNEL_ORIGIN = @KERNEL_ORIGIN@;
/*
* This file is part of GayBSD.
* Copyright (c) 2021 fef <owo@fef.moe>.
*
* GayBSD is nonviolent software: you may only use, redistribute, and/or
* modify it under the terms of the Cooperative Nonviolent Public License
* (CNPL) as found in the LICENSE file in the source code root directory
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
* of the license, or (at your option) any later version.
*
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
* permitted by applicable law. See the CNPL for details.
*/

@ -0,0 +1,43 @@
# See the end of this file for copyright and license terms.
set(TOOLCHAIN_PATH "/usr/bin" CACHE STRING "Toolchain directory")
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR i686)
set(CMAKE_CROSSCOMPILING 1)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(CMAKE_AR ${TOOLCHAIN_PATH}/${CMAKE_EXECUTABLE_PREFIX}ar${CMAKE_EXECUTABLE_SUFFIX})
set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PATH}/${CMAKE_EXECUTABLE_PREFIX}clang${CMAKE_EXECUTABLE_SUFFIX})
set(CMAKE_C_COMPILER ${TOOLCHAIN_PATH}/${CMAKE_EXECUTABLE_PREFIX}clang${CMAKE_EXECUTABLE_SUFFIX})
set(CMAKE_LINKER ${TOOLCHAIN_PATH}/${CMAKE_EXECUTABLE_PREFIX}ld${CMAKE_EXECUTABLE_SUFFIX})
set(CMAKE_OBJCOPY ${TOOLCHAIN_PATH}/${CMAKE_EXECUTABLE_PREFIX}objcopy${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "")
set(CMAKE_RANLIB ${TOOLCHAIN_PATH}/${CMAKE_EXECUTABLE_PREFIX}ranlib${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "")
set(CMAKE_SZE ${TOOLCHAIN_PATH}/${CMAKE_EXECUTABLE_PREFIX}szr${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "")
set(CMAKE_STRIP ${TOOLCHAIN_PATH}/${CMAKE_EXECUTABLE_PREFIX}strip${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -target i686-none -m32")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -target i686-none -m32")
configure_file(
"${CMAKE_CURRENT_LIST_DIR}/kernel_config.ld.in"
"${CMAKE_BINARY_DIR}/config/kernel_config.ld"
)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T${CMAKE_BINARY_DIR}/config/kernel_config.ld -T${CMAKE_CURRENT_LIST_DIR}/kernel.ld")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
# This file is part of GayBSD.
# Copyright (c) 2021 fef <owo@fef.moe>.
#
# GayBSD is nonviolent software: you may only use, redistribute, and/or
# modify it under the terms of the Cooperative Nonviolent Public License
# (CNPL) as found in the LICENSE file in the source code root directory
# or at <https://git.pixie.town/thufie/npl-builder>; either version 7
# of the license, or (at your option) any later version.
#
# GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
# permitted by applicable law. See the CNPL for details.

@ -1,10 +1,11 @@
# See the end of this file for copyright and license terms.
add_custom_target(mbr.bin)
add_custom_command(
TARGET mbr.bin
COMMAND /usr/bin/nasm
ARGS -f bin -o ${CMAKE_CURRENT_BINARY_DIR}/mbr.bin ${CMAKE_CURRENT_SOURCE_DIR}/mbr.s
add_library(gay_boot STATIC)
target_include_directories(gay_boot PRIVATE ${GAY_INCLUDE_DIRS})
target_sources(gay_boot PRIVATE
multiboot.S
boot.c
)
# This file is part of GayBSD.

@ -0,0 +1,23 @@
/* See the end of this file for copyright and license terms. */
#include <multiboot.h>
#include <gay/types.h>
void _boot(u32 magic, u32 address)
{
while (1);
}
/*
* This file is part of GayBSD.
* Copyright (c) 2021 fef <owo@fef.moe>.
*
* GayBSD is nonviolent software: you may only use, redistribute, and/or
* modify it under the terms of the Cooperative Nonviolent Public License
* (CNPL) as found in the LICENSE file in the source code root directory
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
* of the license, or (at your option) any later version.
*
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
* permitted by applicable law. See the CNPL for details.
*/

@ -0,0 +1,123 @@
/* See the end of this file for copyright and license terms. */
#include <asm/common.h>
#include <gay/config.h>
#include <multiboot.h>
/* see arch/x86/config/kernel.ld */
.extern _kernel_end
.extern _image_end
.extern _stack_end
.extern _boot
.section .multiboot
mb2_load_start:
.align MB2_TAG_ALIGN
header_start: /* struct mb2_header */
/* magic */
.long MB2_HEADER_MAGIC
/* architecture */
.long MB2_ARCHITECTURE_I386
/* heaer_length */
.long header_end - header_start
/* checksum */
.long (1 << 33) - MB2_HEADER_MAGIC - MB2_ARCHITECTURE_I386 - (header_end - header_start)
.align MB2_TAG_ALIGN
address_tag_start: /* struct mb2_header_tag_address */
/* type */
.short MB2_HEADER_TAG_ADDRESS
/* flags */
.short MB2_HEADER_TAG_OPTIONAL
/* size */
.long address_tag_end - address_tag_start
/* header_addr */
.long header_start
/* load_addr */
.long mb2_load_start
/* load_end_addr */
.long _kernel_end
/* bss_end_addr */
.long _image_end
address_tag_end:
.align MB2_TAG_ALIGN
entry_address_tag_start: /* struct mb2_header_tag_entry_address */
/* type */
.short MB2_HEADER_TAG_ENTRY_ADDRESS
/* flags */
.short MB2_HEADER_TAG_OPTIONAL
/* size */
.long entry_address_tag_end - entry_address_tag_start
/* entry_addr */
.long _start
entry_address_tag_end:
.align MB2_TAG_ALIGN
framebuffer_tag_start: /* struct mb2_header_tag_framebuffer */
/* type */
.short MB2_HEADER_TAG_FRAMEBUFFER
/* flags */
.short MB2_HEADER_TAG_OPTIONAL
/* size */
.long framebuffer_tag_end - framebuffer_tag_start
/* width */
.long 1024
/* height */
.long 768
/* depth */
.long 32
framebuffer_tag_end:
.align MB2_TAG_ALIGN
end_tag_start: /* struct mb2_header_tag */
/* type */
.short MB2_HEADER_TAG_END
/* flags */
.short 0
/* size */
.long end_tag_end - end_tag_start
end_tag_end:
header_end:
.text
asmfn_begin(_start)
mov _stack_end, %esp
/* reset EFLAGS */
pushl $0
popf
/* parameter 2 for _boot() is header address */
push %ebx
/* parameter 1 for _boot() is MB2_BOOTLOADER_MAGIC */
push %eax
/* call _boot() from boot.c */
call _boot
/* this should never(TM) be reached */
halt_loop:
hlt
jmp halt_loop
asmfn_end(_start)
/*
* This file is part of GayBSD.
* Copyright (c) 2021 fef <owo@fef.moe>.
*
* GayBSD is nonviolent software: you may only use, redistribute, and/or
* modify it under the terms of the Cooperative Nonviolent Public License
* (CNPL) as found in the LICENSE file in the source code root directory
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
* of the license, or (at your option) any later version.
*
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
* permitted by applicable law. See the CNPL for details.
*/

@ -1,64 +0,0 @@
; See the end of this file for copyright and license terms.
;
; We use a custom ABI because BIOS interrupts use ax for their parameter:
;
; register | usage
; ---------|--------------------
; ax | BIOS parameter
; bx | arg1, return value
; cx | arg2
; dx | arg3
;
; Registers ax-dx are saved by the caller, all others by the callee.
;
; To save space, strings are terminated by setting bit 7 of their last
; character to 1 (because ascii only uses bits 0-6) rather than appending a
; full NUL terminator byte. This technique is stolen from FreeBSD.
;
[bits 16]
[org 0x7c00]
_start:
mov bp, 0x9000
mov sp, bp
mov bx, HELLO
call print
; TODO: switch to protected mode and call kernel here
jmp $
; args:
; - bx: pointer to string
print:
mov ah, 0x0e
_print_loop:
mov al, [bx]
mov cl, al
and al, 0x7f
int 0x10
inc bx
and cl, 0x80
je _print_loop
ret
HELLO: db "hi i'm gay uwu", 0x0d, 0x8a ; '\r', '\n'|0x80
; padding to 512 bytes (-2 for magic)
times 510 - ($-$$) db 0
; mbr magic
dw 0xaa55
; This file is part of GayBSD.
; Copyright (c) 2021 fef <owo@fef.moe>.
;
; GayBSD is nonviolent software: you may only use, redistribute, and/or
; modify it under the terms of the Cooperative Nonviolent Public License
; (CNPL) as found in the LICENSE file in the source code root directory
; or at <https://git.pixie.town/thufie/npl-builder>; either version 7
; of the license, or (at your option) any later version.
;
; GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
; permitted by applicable law. See the CNPL for details.

@ -8,6 +8,8 @@ set_property(CACHE ARCH PROPERTY STRINGS
)
include("${CMAKE_CURRENT_LIST_DIR}/config-${ARCH}.cmake")
set(KERNEL_ORIGIN "0x100000" CACHE STRING "Physical address where the kernel is loaded")
# This file is part of GayBSD.
# Copyright (c) 2021 fef <owo@fef.moe>.
#

@ -0,0 +1,29 @@
/* See the end of this file for copyright and license terms. */
#pragma once
#ifndef _ASM_SOURCE
#error "This header is only intended to be included from assembly files"
#endif
#define asmfn_begin(name) \
.global name; \
.type name, function; \
name:
#define asmfn_end(name) \
.size name, . - name
/*
* This file is part of GayBSD.
* Copyright (c) 2021 fef <owo@fef.moe>.
*
* GayBSD is nonviolent software: you may only use, redistribute, and/or
* modify it under the terms of the Cooperative Nonviolent Public License
* (CNPL) as found in the LICENSE file in the source code root directory
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
* of the license, or (at your option) any later version.
*
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
* permitted by applicable law. See the CNPL for details.
*/

@ -0,0 +1,23 @@
/* See the end of this file for copyright and license terms. */
#pragma once
/** @brief Physical address where the kernel is loaded */
#define CFG_KERNEL_ORIGIN @KERNEL_ORIGIN@
/** @brief Initial kernel stack size in bytes */
#define CFG_STACK_SIZE @STACK_SIZE@
/*
* This file is part of GayBSD.
* Copyright (c) 2021 fef <owo@fef.moe>.
*
* GayBSD is nonviolent software: you may only use, redistribute, and/or
* modify it under the terms of the Cooperative Nonviolent Public License
* (CNPL) as found in the LICENSE file in the source code root directory
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
* of the license, or (at your option) any later version.
*
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
* permitted by applicable law. See the CNPL for details.
*/

@ -0,0 +1,38 @@
/* See the end of this file for copyright and license terms. */
#pragma once
typedef __INT8_TYPE__ s8;
typedef __UINT8_TYPE__ u8;
typedef __INT16_TYPE__ s16;
typedef __UINT16_TYPE__ u16;
typedef __INT32_TYPE__ s32;
typedef __UINT32_TYPE__ u32;
typedef __INT64_TYPE__ s64;
typedef __UINT64_TYPE__ u64;
typedef __SIZE_TYPE__ size_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
typedef __PTRDIFF_TYPE__ intptr_t;
#define unsigned signed /* l00k @ d33z m4d h4xx0r sk1llz!!1 */
typedef __SIZE_TYPE__ ssize_t;
typedef __PTRDIFF_TYPE__ uintptr_t;
#undef unsigned
/*
* This file is part of GayBSD.
* Copyright (c) 2021 fef <owo@fef.moe>.
*
* GayBSD is nonviolent software: you may only use, redistribute, and/or
* modify it under the terms of the Cooperative Nonviolent Public License
* (CNPL) as found in the LICENSE file in the source code root directory
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
* of the license, or (at your option) any later version.
*
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
* permitted by applicable law. See the CNPL for details.
*/

@ -0,0 +1,362 @@
/* See the end of this file for copyright and license terms. */
#pragma once
/*
* Multiboot 2 header definitions and structures, see the GNU documentation:
* <https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html>
*/
#define MB2_SEARCH 32768
#define MB2_HEADER_ALIGN 8
/* The magic field should contain this. */
#define MB2_HEADER_MAGIC 0xe85250d6
/* This should be in %eax. */
#define MB2_BOOTLOADER_MAGIC 0x36d76289
/* Alignment of multiboot modules. */
#define MB2_MOD_ALIGN 0x00001000
/* Alignment of the multiboot info structure. */
#define MB2_INFO_ALIGN 0x00000008
/* Alignment of multiboot header tags. */
#define MB2_TAG_ALIGN 8
#define MB2_TAG_TYPE_END 0
#define MB2_TAG_TYPE_CMDLINE 1
#define MB2_TAG_TYPE_BOOT_LOADER_NAME 2
#define MB2_TAG_TYPE_MODULE 3
#define MB2_TAG_TYPE_BASIC_MEMINFO 4
#define MB2_TAG_TYPE_BOOTDEV 5
#define MB2_TAG_TYPE_MMAP 6
#define MB2_TAG_TYPE_VBE 7
#define MB2_TAG_TYPE_FRAMEBUFFER 8
#define MB2_TAG_TYPE_ELF_SECTIONS 9
#define MB2_TAG_TYPE_APM 10
#define MB2_TAG_TYPE_EFI32 11
#define MB2_TAG_TYPE_EFI64 12
#define MB2_TAG_TYPE_SMBIOS 13
#define MB2_TAG_TYPE_ACPI_OLD 14
#define MB2_TAG_TYPE_ACPI_NEW 15
#define MB2_TAG_TYPE_NETWORK 16
#define MB2_TAG_TYPE_EFI_MMAP 17
#define MB2_TAG_TYPE_EFI_BS 18
#define MB2_TAG_TYPE_EFI32_IH 19
#define MB2_TAG_TYPE_EFI64_IH 20
#define MB2_TAG_TYPE_LOAD_BASE_ADDR 21
#define MB2_HEADER_TAG_END 0
#define MB2_HEADER_TAG_INFORMATION_REQUEST 1
#define MB2_HEADER_TAG_ADDRESS 2
#define MB2_HEADER_TAG_ENTRY_ADDRESS 3
#define MB2_HEADER_TAG_CONSOLE_FLAGS 4
#define MB2_HEADER_TAG_FRAMEBUFFER 5
#define MB2_HEADER_TAG_MODULE_ALIGN 6
#define MB2_HEADER_TAG_EFI_BS 7
#define MB2_HEADER_TAG_ENTRY_ADDRESS_EFI32 8
#define MB2_HEADER_TAG_ENTRY_ADDRESS_EFI64 9
#define MB2_HEADER_TAG_RELOCATABLE 10
#define MB2_ARCHITECTURE_I386 0
#define MB2_ARCHITECTURE_MIPS32 4
#define MB2_HEADER_TAG_OPTIONAL 1
#define MB2_LOAD_PREFERENCE_NONE 0
#define MB2_LOAD_PREFERENCE_LOW 1
#define MB2_LOAD_PREFERENCE_HIGH 2
#define MB2_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
#define MB2_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
#ifndef _ASM_SOURCE
#include <gay/types.h>
/* implemented in boot/multiboot.S */
struct mb2_header {
u32 magic; /**< = MB2_HEADER_MAGIC */
u32 architecture; /**< ISA */
u32 header_length; /**< Total header length in bytes */
u32 checksum; /**< Sum of all 4 members % (1 << 32) = 0 */
};
struct mb2_header_tag {
u16 type;
u16 flags;
u32 size;
};
struct mb2_header_tag_information_request {
struct mb2_header_tag header;
u32 requests[];
};
struct mb2_header_tag_address {
struct mb2_header_tag header;
u32 header_addr;
u32 load_addr;
u32 load_end_addr;
u32 bss_end_addr;
};
struct mb2_header_tag_entry_address {
struct mb2_header_tag header;
u32 entry_addr;
};
struct mb2_header_tag_console_flags {
struct mb2_header_tag header;
u32 console_flags;
};
struct mb2_header_tag_framebuffer {
struct mb2_header_tag header;
u32 width;
u32 height;
u32 depth;
};
struct mb2_header_tag_module_align {
struct mb2_header_tag header;
};
struct mb2_header_tag_relocatable {
struct mb2_header_tag header;
u32 min_addr;
u32 max_addr;
u32 align;
u32 preference;
};
struct mb2_color {
u8 red;
u8 green;
u8 blue;
};
struct mb2_mmap_entry {
u64 addr;
u64 len;
u32 type;
#define MB2_MEMORY_AVAILABLE 1
#define MB2_MEMORY_RESERVED 2
#define MB2_MEMORY_ACPI_RECLAIMABLE 3
#define MB2_MEMORY_NVS 4
#define MB2_MEMORY_BADRAM 5
u32 zero;
};
typedef struct mb2_mmap_entry multiboot_memory_map_t;
struct mb2_tag {
u32 type;
u32 size;
};
struct mb2_tag_string {
struct mb2_tag tag;
char string[];
};
struct mb2_tag_module {
struct mb2_tag tag;
u32 mod_start;
u32 mod_end;
char cmdline[];
};
struct mb2_tag_basic_meminfo {
struct mb2_tag tag;
u32 mem_lower;
u32 mem_upper;
};
struct mb2_tag_bootdev {
struct mb2_tag tag;
u32 biosdev;
u32 slice;
u32 part;
};
struct mb2_tag_mmap {
struct mb2_tag tag;
u32 entry_size;
u32 entry_version;
struct mb2_mmap_entry entries[];
};
struct mb2_vbe_info_block {
u8 external_specification[512];
};
struct mb2_vbe_mode_info_block {
u8 external_specification[256];
};
struct mb2_tag_vbe {
struct mb2_tag tag;
u16 vbe_mode;
u16 vbe_interface_seg;
u16 vbe_interface_off;
u16 vbe_interface_len;
struct mb2_vbe_info_block vbe_control_info;
struct mb2_vbe_mode_info_block vbe_mode_info;
};
struct mb2_tag_framebuffer_common {
struct mb2_tag tag;
u64 framebuffer_addr;
u32 framebuffer_pitch;
u32 framebuffer_width;
u32 framebuffer_height;
u8 framebuffer_bpp;
u8 framebuffer_type;
#define MB2_FRAMEBUFFER_TYPE_INDEXED 0
#define MB2_FRAMEBUFFER_TYPE_RGB 1
#define MB2_FRAMEBUFFER_TYPE_EGA_TEXT 2
u16 reserved;
};
struct mb2_tag_framebuffer {
struct mb2_tag_framebuffer_common common;
union {
struct {
u16 framebuffer_palette_num_colors;
struct mb2_color framebuffer_palette[];
};
struct {
u8 framebuffer_red_field_position;
u8 framebuffer_red_mask_size;
u8 framebuffer_green_field_position;
u8 framebuffer_green_mask_size;
u8 framebuffer_blue_field_position;
u8 framebuffer_blue_mask_size;
};
};
};
struct mb2_tag_elf_sections {
struct mb2_tag tag;
u32 num;
u32 entsize;
u32 shndx;
char sections[];
};
struct mb2_tag_apm {
struct mb2_tag tag;
u16 version;
u16 cseg;
u32 offset;
u16 cseg_16;
u16 dseg;
u16 flags;
u16 cseg_len;
u16 cseg_16_len;
u16 dseg_len;
};
struct mb2_tag_efi32 {
struct mb2_tag tag;
u32 pointer;
};
struct mb2_tag_efi64 {
struct mb2_tag tag;
u64 pointer;
};
struct mb2_tag_smbios {
struct mb2_tag tag;
u8 major;
u8 minor;
u8 _reserved[6];
u8 tables[];
};
struct mb2_tag_old_acpi {
struct mb2_tag tag;
u8 rsdp[];
};
struct mb2_tag_new_acpi {
struct mb2_tag tag;
u8 rsdp[];
};
struct mb2_tag_network {
struct mb2_tag tag;
u8 dhcpack[];
};
struct mb2_tag_efi_mmap {
struct mb2_tag tag;
u32 descr_size;
u32 descr_vers;
u8 efi_mmap[];
};
struct mb2_tag_efi32_ih {
struct mb2_tag tag;
u32 pointer;
};
struct mb2_tag_efi64_ih {
struct mb2_tag tag;
u64 pointer;
};
struct mb2_tag_load_base_addr {
struct mb2_tag tag;
u32 load_base_addr;
};
#endif /* not _ASM_SOURCE */
/*
* This file is part of GayBSD.
* Copyright (c) 2021 fef <owo@fef.moe>.
*
* GayBSD is nonviolent software: you may only use, redistribute, and/or
* modify it under the terms of the Cooperative Nonviolent Public License
* (CNPL) as found in the LICENSE file in the source code root directory
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
* of the license, or (at your option) any later version.
*
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
* permitted by applicable law. See the CNPL for details.
*
* =============================================================================
*
* This file is derived from the FSF's sample multiboot2.h file:
* <https://www.gnu.org/software/grub/manual/multiboot2/html_node/multiboot2_002eh.html>
*
* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY
* DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
Loading…
Cancel
Save