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