Xyris  0.5
Boot::Handoff Class Reference

#include <Handoff.hpp>

+ Collaboration diagram for Boot::Handoff:

Public Member Functions

 Handoff ()
 
 Handoff (void *handoff, uint32_t magic)
 
const char * CmdLine ()
 
const void * Handle ()
 
Graphics::FramebufferFramebufferInfo ()
 
HandoffBootloaderTypeBootType ()
 
Memory::MemoryMapMemoryMap ()
 

Static Private Member Functions

static void parseStivale2 (Handoff *that, void *handoff)
 

Private Attributes

void * m_handle
 
char * m_cmdline
 
uint32_t m_magic
 
Graphics::Framebuffer m_framebuffer
 
HandoffBootloaderType m_bootType
 
Memory::MemoryMap m_memoryMap
 

Detailed Description

Definition at line 88 of file Handoff.hpp.

Constructor & Destructor Documentation

◆ Handoff() [1/2]

Boot::Handoff::Handoff ( )

Definition at line 38 of file Handoff.cpp.

39  : m_handle(NULL)
40  , m_magic(0)
41 {
42  // Initialize nothing.
43 }

◆ Handoff() [2/2]

Boot::Handoff::Handoff ( void *  handoff,
uint32_t  magic 
)

Definition at line 45 of file Handoff.cpp.

46  : m_handle(handoff)
47  , m_magic(magic)
48 {
49  // Parse the handle based on the magic
50  Logger::Info(__func__, "Bootloader info at 0x%p", handoff);
51  if (magic == STIVALE2_MAGIC) {
53  parseStivale2(this, handoff);
54  } else {
55  panic("Invalid bootloader magic!");
56  }
57 }
+ Here is the call graph for this function:

Member Function Documentation

◆ BootType()

HandoffBootloaderType* Boot::Handoff::BootType ( )
inline

Definition at line 97 of file Handoff.hpp.

97 { return &m_bootType; }

◆ CmdLine()

const char* Boot::Handoff::CmdLine ( )
inline

Definition at line 94 of file Handoff.hpp.

94 { return m_cmdline; }

◆ FramebufferInfo()

Graphics::Framebuffer* Boot::Handoff::FramebufferInfo ( )
inline

Definition at line 96 of file Handoff.hpp.

96 { return &m_framebuffer; }

◆ Handle()

const void* Boot::Handoff::Handle ( )
inline

Definition at line 95 of file Handoff.hpp.

95 { return m_handle; }

◆ MemoryMap()

Memory::MemoryMap* Boot::Handoff::MemoryMap ( )
inline

Definition at line 98 of file Handoff.hpp.

98 { return &m_memoryMap; }

◆ parseStivale2()

void Boot::Handoff::parseStivale2 ( Handoff that,
void *  handoff 
)
staticprivate

Definition at line 66 of file Handoff.cpp.

67 {
68  Logger::Info(__func__, "Booted via Stivale2");
69  // Walk the list of tags in the header
70  struct stivale2_struct* fixed = (struct stivale2_struct*)handoff;
71  struct stivale2_tag* tag = (struct stivale2_tag*)(fixed->tags);
72  while (tag) {
73  switch (tag->identifier) {
74  case STIVALE2_STRUCT_TAG_MEMMAP_ID: {
75  auto memmap = (struct stivale2_struct_tag_memmap*)tag;
76  Logger::Debug(__func__, "Found %Lu Stivale2 memmap entries.", memmap->entries);
77  if (memmap->entries > that->m_memoryMap.Count()) {
78  panic("Not enough space to add all memory map entries!");
79  }
80  // Follows the tag list order in stivale2.h
81  for (size_t i = 0; i < memmap->entries; i++) {
82  auto entry = memmap->memmap[i];
83  uint64_t end = entry.base + entry.length - 1;
84  that->m_memoryMap[i] = Memory::Section(entry.base, end);
85  Logger::Debug(__func__, "[%zu] 0x%08LX-0x%08LX 0x%08LX", i, entry.base, end, entry.length);
86  // TODO: Make this a map that can be indexed
87  switch (entry.type) {
88  case STIVALE2_MMAP_USABLE:
89  that->m_memoryMap[i].setType(Memory::Available);
90  break;
91 
92  case STIVALE2_MMAP_RESERVED:
93  that->m_memoryMap[i].setType(Memory::Reserved);
94  break;
95 
96  case STIVALE2_MMAP_ACPI_RECLAIMABLE:
97  that->m_memoryMap[i].setType(Memory::ACPI);
98  break;
99 
100  case STIVALE2_MMAP_ACPI_NVS:
101  that->m_memoryMap[i].setType(Memory::NVS);
102  break;
103 
104  case STIVALE2_MMAP_BAD_MEMORY:
105  that->m_memoryMap[i].setType(Memory::Bad);
106  break;
107 
108  case STIVALE2_MMAP_BOOTLOADER_RECLAIMABLE:
109  that->m_memoryMap[i].setType(Memory::Bootloader);
110  break;
111 
112  case STIVALE2_MMAP_KERNEL_AND_MODULES:
113  that->m_memoryMap[i].setType(Memory::Kernel);
114  break;
115 
116  default:
117  that->m_memoryMap[i].setType(Memory::Unknown);
118  break;
119  }
120  }
121  break;
122  }
123  case STIVALE2_STRUCT_TAG_CMDLINE_ID: {
124  auto cmdline = (struct stivale2_struct_tag_cmdline*)tag;
125  that->m_cmdline = (char*)(cmdline->cmdline);
126  Logger::Debug(__func__, "Stivale2 cmdline: '%s'", that->m_cmdline);
127  parseCommandLine(that->m_cmdline);
128  break;
129  }
130  case STIVALE2_STRUCT_TAG_FRAMEBUFFER_ID: {
131  auto framebuffer = (struct stivale2_struct_tag_framebuffer*)tag;
133  __func__,
134  "Stivale2 framebuffer:\n"
135  "\tAddress: 0x%08LX\n"
136  "\tResolution: %ux%ux%u\n"
137  "\tPixel format:\n"
138  "\t\tRed size: %u\n"
139  "\t\tRed shift: %u\n"
140  "\t\tGreen size: %u\n"
141  "\t\tGreen shift: %u\n"
142  "\t\tBlue size: %u\n"
143  "\t\tBlue shift: %u",
144  framebuffer->framebuffer_addr,
145  framebuffer->framebuffer_width,
146  framebuffer->framebuffer_height,
147  framebuffer->framebuffer_bpp,
148  framebuffer->red_mask_size,
149  framebuffer->red_mask_shift,
150  framebuffer->green_mask_size,
151  framebuffer->green_mask_shift,
152  framebuffer->blue_mask_size,
153  framebuffer->blue_mask_shift);
154  // Initialize the framebuffer information
155  that->m_framebuffer = Graphics::Framebuffer(
156  framebuffer->framebuffer_width,
157  framebuffer->framebuffer_height,
158  framebuffer->framebuffer_bpp,
159  framebuffer->framebuffer_pitch,
160  reinterpret_cast<void*>(framebuffer->framebuffer_addr),
161  static_cast<Graphics::FramebufferMemoryModel>(framebuffer->memory_model),
162  framebuffer->red_mask_size,
163  framebuffer->red_mask_shift,
164  framebuffer->green_mask_size,
165  framebuffer->green_mask_shift,
166  framebuffer->blue_mask_size,
167  framebuffer->blue_mask_shift);
168  break;
169  }
170  default: {
171  Logger::Debug(__func__, "Unknown Stivale2 tag: 0x%016LX", tag->identifier);
172  break;
173  }
174  }
175 
176  tag = (struct stivale2_tag*)tag->next;
177  }
178 
179  Logger::Debug(__func__, "Done parsing Stivale2 tags");
180 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ m_bootType

HandoffBootloaderType Boot::Handoff::m_bootType
private

Definition at line 107 of file Handoff.hpp.

◆ m_cmdline

char* Boot::Handoff::m_cmdline
private

Definition at line 104 of file Handoff.hpp.

◆ m_framebuffer

Graphics::Framebuffer Boot::Handoff::m_framebuffer
private

Definition at line 106 of file Handoff.hpp.

◆ m_handle

void* Boot::Handoff::m_handle
private

Definition at line 103 of file Handoff.hpp.

◆ m_magic

uint32_t Boot::Handoff::m_magic
private

Definition at line 105 of file Handoff.hpp.

◆ m_memoryMap

Memory::MemoryMap Boot::Handoff::m_memoryMap
private

Definition at line 108 of file Handoff.hpp.


The documentation for this class was generated from the following files:
Boot::Handoff::parseStivale2
static void parseStivale2(Handoff *that, void *handoff)
Definition: Handoff.cpp:66
Graphics::FramebufferMemoryModel
FramebufferMemoryModel
Definition: framebuffer.hpp:16
Memory::ACPI
@ ACPI
Definition: MemorySection.hpp:21
STIVALE2_MAGIC
#define STIVALE2_MAGIC
Definition: Handoff.cpp:26
Memory::NVS
@ NVS
Definition: MemorySection.hpp:22
Memory::Bad
@ Bad
Definition: MemorySection.hpp:23
Logger::Info
static void Info(const char *tag, const char *fmt,...)
Definition: Logger.cpp:81
Boot::Handoff::m_handle
void * m_handle
Definition: Handoff.hpp:103
Boot::Handoff::m_bootType
HandoffBootloaderType m_bootType
Definition: Handoff.hpp:107
Memory::Reserved
@ Reserved
Definition: MemorySection.hpp:20
Memory::Section
Definition: MemorySection.hpp:29
Graphics::Framebuffer
Definition: framebuffer.hpp:21
Boot::Handoff::m_magic
uint32_t m_magic
Definition: Handoff.hpp:105
Logger::Debug
static void Debug(const char *tag, const char *fmt,...)
Definition: Logger.cpp:71
Boot::Handoff::m_framebuffer
Graphics::Framebuffer m_framebuffer
Definition: Handoff.hpp:106
panic
void panic(const char *msg)
Halt the system and print the provided message on the panic screen.
Definition: Panic.cpp:82
Boot::Handoff::m_memoryMap
Memory::MemoryMap m_memoryMap
Definition: Handoff.hpp:108
Memory::Kernel
@ Kernel
Definition: MemorySection.hpp:25
Memory::Available
@ Available
Definition: MemorySection.hpp:19
Memory::Unknown
@ Unknown
Definition: MemorySection.hpp:26
Boot::Handoff::m_cmdline
char * m_cmdline
Definition: Handoff.hpp:104
Boot::parseCommandLine
void parseCommandLine(char *cmdline)
Parse a command line for registered arguments.
Definition: Arguments.cpp:17
Memory::Bootloader
@ Bootloader
Definition: MemorySection.hpp:24
Boot::Stivale2
@ Stivale2
Definition: Handoff.hpp:19