1/*
2 * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#pragma once
8
9#define SEL4_MULTIBOOT_MAX_MMAP_ENTRIES 50
10#define SEL4_MULTIBOOT_RAM_REGION_TYPE 1
11
12typedef struct seL4_VBEInfoBlock {
13    char        signature[4];
14    seL4_Uint16 version;
15    seL4_Uint32 oemStringPtr;
16    seL4_Uint32 capabilities;
17    seL4_Uint32 modeListPtr;
18    seL4_Uint16 totalMemory;
19    seL4_Uint16 oemSoftwareRev;
20    seL4_Uint32 oemVendorNamePtr;
21    seL4_Uint32 oemProductNamePtr;
22    seL4_Uint32 oemProductRevPtr;
23    seL4_Uint8  reserved[222];
24    seL4_Uint8  oemData[256];
25} SEL4_PACKED seL4_VBEInfoBlock_t;
26
27/* the seL4_VBEModeInfoBlock struct is split into multiple parts to aid the C parser */
28typedef struct seL4_VBEModeInfoCommon {
29    seL4_Uint16 modeAttr;
30    seL4_Uint8  winAAttr;
31    seL4_Uint8  winBAttr;
32    seL4_Uint16 winGranularity;
33    seL4_Uint16 winSize;
34    seL4_Uint16 winASeg;
35    seL4_Uint16 winBSeg;
36    seL4_Uint32 winFuncPtr;
37    seL4_Uint16 bytesPerScanLine;
38} SEL4_PACKED seL4_VBEModeInfoCommon_t;
39
40typedef struct  seL4_VBEInfo12Part1 {
41    seL4_Uint16 xRes;
42    seL4_Uint16 yRes;
43    seL4_Uint8  xCharSize;
44    seL4_Uint8  yCharSize;
45    seL4_Uint8  planes;
46    seL4_Uint8  bitsPerPixel;
47    seL4_Uint8  banks;
48    seL4_Uint8  memoryModel;
49    seL4_Uint8  bankSize;
50    seL4_Uint8  imagePages;
51    seL4_Uint8  reserved1;
52} SEL4_PACKED seL4_VBEInfo12Part1_t;
53
54typedef struct seL4_VBEInfo12Part2 {
55    seL4_Uint8  redLen;
56    seL4_Uint8  redOff;
57    seL4_Uint8  greenLen;
58    seL4_Uint8  greenOff;
59    seL4_Uint8  blueLen;
60    seL4_Uint8  blueOff;
61    seL4_Uint8  rsvdLen;
62    seL4_Uint8  rsvdOff;
63    seL4_Uint8  directColorInfo;  /* direct color mode attributes */
64} SEL4_PACKED seL4_VBEInfo12Part2_t;
65
66typedef struct  seL4_VBEInfo20 {
67    seL4_Uint32 physBasePtr;
68    seL4_Uint8  reserved2[6];
69} SEL4_PACKED seL4_VBEInfo20_t;
70
71typedef struct seL4_VBEInfo30 {
72    seL4_Uint16 linBytesPerScanLine;
73    seL4_Uint8  bnkImagePages;
74    seL4_Uint8  linImagePages;
75    seL4_Uint8  linRedLen;
76    seL4_Uint8  linRedOff;
77    seL4_Uint8  linGreenLen;
78    seL4_Uint8  linGreenOff;
79    seL4_Uint8  linBlueLen;
80    seL4_Uint8  linBlueOff;
81    seL4_Uint8  linRsvdLen;
82    seL4_Uint8  linRsvdOff;
83    seL4_Uint32 maxPixelClock;
84    seL4_Uint16 modeId;
85    seL4_Uint8  depth;
86} SEL4_PACKED seL4_VBEInfo30_t;
87
88typedef struct seL4_VBEModeInfoBlock {
89    /* All VBE revisions */
90    seL4_VBEModeInfoCommon_t vbe_common;
91    /* VBE 1.2+ */
92    seL4_VBEInfo12Part1_t vbe12_part1;
93    seL4_VBEInfo12Part2_t vbe12_part2;
94
95    /* VBE 2.0+ */
96    seL4_VBEInfo20_t vbe20;
97
98    /* VBE 3.0+ */
99    seL4_VBEInfo30_t vbe30;
100
101    seL4_Uint8 reserved3[187];
102} SEL4_PACKED seL4_VBEModeInfoBlock_t;
103
104typedef struct _seL4_X86_BootInfo_VBE {
105    seL4_BootInfoHeader header;
106    seL4_VBEInfoBlock_t vbeInfoBlock;
107    seL4_VBEModeInfoBlock_t vbeModeInfoBlock;
108    seL4_Uint32 vbeMode;
109    seL4_Uint32 vbeInterfaceSeg;
110    seL4_Uint32 vbeInterfaceOff;
111    seL4_Uint32 vbeInterfaceLen;
112} SEL4_PACKED seL4_X86_BootInfo_VBE;
113
114/**
115 * Copy of multiboot mmap fields.
116 * https://www.gnu.org/software/grub/manual/multiboot/multiboot.html
117 */
118typedef struct seL4_X86_mb_mmap {
119    uint32_t size; // size of this struct in bytes
120    uint64_t base_addr; // physical address of start of this region
121    uint64_t length; // length of the region this struct represents in bytes
122    uint32_t type; // memory type of region. Type 1 corresponds to RAM.
123} SEL4_PACKED seL4_X86_mb_mmap_t;
124
125typedef struct seL4_X86_BootInfo_mmap {
126    seL4_BootInfoHeader header;
127    seL4_Uint32 mmap_length;
128    seL4_X86_mb_mmap_t mmap[SEL4_MULTIBOOT_MAX_MMAP_ENTRIES];
129} SEL4_PACKED seL4_X86_BootInfo_mmap_t;
130
131typedef struct multiboot2_fb seL4_X86_BootInfo_fb_t;
132
133