1
0
Fork 0
mirror of https://gitlab.com/bztsrc/bootboot.git synced 2023-02-13 20:54:32 -05:00
bztsrc--bootboot/dist/bootboot.h

145 lines
4.9 KiB
C
Raw Normal View History

2018-06-05 14:34:03 -04:00
/*
* bootboot.h
*
2021-01-15 15:07:25 -05:00
* Copyright (C) 2017 - 2021 bzt (bztsrc@gitlab)
2018-06-05 14:34:03 -04:00
*
* 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 THE AUTHORS OR COPYRIGHT
* HOLDERS 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.
*
* This file is part of the BOOTBOOT Protocol package.
* @brief The BOOTBOOT structure
*
*/
#ifndef _BOOTBOOT_H_
#define _BOOTBOOT_H_
#ifdef __cplusplus
extern "C" {
#endif
#define BOOTBOOT_MAGIC "BOOT"
/* default virtual addresses for level 0 and 1 static loaders */
#define BOOTBOOT_MMIO 0xfffffffff8000000 /* memory mapped IO virtual address */
#define BOOTBOOT_FB 0xfffffffffc000000 /* frame buffer virtual address */
#define BOOTBOOT_INFO 0xffffffffffe00000 /* bootboot struct virtual address */
#define BOOTBOOT_ENV 0xffffffffffe01000 /* environment string virtual address */
#define BOOTBOOT_CORE 0xffffffffffe02000 /* core loadable segment start */
2019-02-12 18:13:22 -05:00
/* minimum protocol level:
* hardcoded kernel name, static kernel memory addresses */
2018-06-05 14:34:03 -04:00
#define PROTOCOL_MINIMAL 0
2019-02-12 18:13:22 -05:00
/* static protocol level:
* kernel name parsed from environment, static kernel memory addresses */
2018-06-05 14:34:03 -04:00
#define PROTOCOL_STATIC 1
2019-02-12 18:13:22 -05:00
/* dynamic protocol level:
* kernel name parsed, kernel memory addresses from ELF or PE symbols */
2018-06-05 14:34:03 -04:00
#define PROTOCOL_DYNAMIC 2
2019-02-12 18:13:22 -05:00
/* big-endian flag */
2018-06-05 14:34:03 -04:00
#define PROTOCOL_BIGENDIAN 0x80
2019-02-12 18:13:22 -05:00
/* loader types, just informational */
2020-09-16 22:41:14 -04:00
#define LOADER_BIOS (0<<2)
#define LOADER_UEFI (1<<2)
#define LOADER_RPI (2<<2)
#define LOADER_COREBOOT (3<<2)
2018-06-05 14:34:03 -04:00
2019-02-12 18:13:22 -05:00
/* framebuffer pixel format, only 32 bits supported */
2018-06-05 14:34:03 -04:00
#define FB_ARGB 0
#define FB_RGBA 1
#define FB_ABGR 2
#define FB_BGRA 3
2019-02-12 18:13:22 -05:00
/* mmap entry, type is stored in least significant tetrad (half byte) of size
* this means size described in 16 byte units (not a problem, most modern
* firmware report memory in pages, 4096 byte units anyway). */
2018-06-05 14:34:03 -04:00
typedef struct {
uint64_t ptr;
uint64_t size;
} __attribute__((packed)) MMapEnt;
#define MMapEnt_Ptr(a) (a->ptr)
#define MMapEnt_Size(a) (a->size & 0xFFFFFFFFFFFFFFF0)
#define MMapEnt_Type(a) (a->size & 0xF)
2019-03-10 09:24:26 -04:00
#define MMapEnt_IsFree(a) ((a->size&0xF)==1)
2018-06-05 14:34:03 -04:00
2019-02-12 18:13:22 -05:00
#define MMAP_USED 0 /* don't use. Reserved or unknown regions */
#define MMAP_FREE 1 /* usable memory */
2019-03-10 09:24:26 -04:00
#define MMAP_ACPI 2 /* acpi memory, volatile and non-volatile as well */
#define MMAP_MMIO 3 /* memory mapped IO region */
2018-06-05 14:34:03 -04:00
2019-02-12 18:13:22 -05:00
#define INITRD_MAXSIZE 16 /* Mb */
2018-06-05 14:34:03 -04:00
typedef struct {
2019-02-12 18:13:22 -05:00
/* first 64 bytes is platform independent */
uint8_t magic[4]; /* 'BOOT' magic */
uint32_t size; /* length of bootboot structure, minimum 128 */
uint8_t protocol; /* 1, static addresses, see PROTOCOL_* and LOADER_* above */
uint8_t fb_type; /* framebuffer type, see FB_* above */
uint16_t numcores; /* number of processor cores */
uint16_t bspid; /* Bootsrap processor ID (Local APIC Id on x86_64) */
int16_t timezone; /* in minutes -1440..1440 */
uint8_t datetime[8]; /* in BCD yyyymmddhhiiss UTC (independent to timezone) */
uint64_t initrd_ptr; /* ramdisk image position and size */
2018-06-05 14:34:03 -04:00
uint64_t initrd_size;
2020-09-16 22:41:14 -04:00
uint64_t fb_ptr; /* framebuffer pointer and dimensions */
2018-06-05 14:34:03 -04:00
uint32_t fb_size;
uint32_t fb_width;
uint32_t fb_height;
uint32_t fb_scanline;
2019-02-12 18:13:22 -05:00
/* the rest (64 bytes) is platform specific */
2018-06-05 14:34:03 -04:00
union {
struct {
uint64_t acpi_ptr;
uint64_t smbi_ptr;
uint64_t efi_ptr;
uint64_t mp_ptr;
uint64_t unused0;
uint64_t unused1;
uint64_t unused2;
uint64_t unused3;
} x86_64;
struct {
uint64_t acpi_ptr;
uint64_t mmio_ptr;
2018-06-28 06:43:27 -04:00
uint64_t efi_ptr;
2018-06-05 14:34:03 -04:00
uint64_t unused0;
uint64_t unused1;
uint64_t unused2;
uint64_t unused3;
uint64_t unused4;
} aarch64;
2019-02-13 11:06:55 -05:00
} arch;
2018-06-05 14:34:03 -04:00
/* from 128th byte, MMapEnt[], more records may follow */
MMapEnt mmap;
2018-06-28 06:43:27 -04:00
/* use like this:
* MMapEnt *mmap_ent = &bootboot.mmap; mmap_ent++;
2018-06-05 14:34:03 -04:00
* until you reach bootboot->size */
} __attribute__((packed)) BOOTBOOT;
#ifdef __cplusplus
}
#endif
#endif