Stivale Bare Bones: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
m Add some missing flags that -elf cross compilers require
For stivale2, use the builtin terminal to print "Hello World" to screen instead of printing a line of pixels.
Line 162:
// is found in the stivale2 specification.
 
// stivale2 offers a runtime terminal service which can be ditched at any
// As an example header tag, we're gonna define a framebuffer header tag.
// time, but it provides an easy way to print out to graphical terminal,
// especially during early boot.
static struct stivale2_header_tag_terminal terminal_hdr_tag = {
// All tags need to begin with an identifier and a pointer to the next tag.
.nexttag = 0{
// Identification constant defined in stivale2.h and the specification.
.identifier = STIVALE2_HEADER_TAG_TERMINAL_ID,
// If next is 0, it marks the end of the linked list of header tags.
fb_addr[i].next = 0xff;0
},
// The terminal header tag possesses a flags field, leave it as 0 for now
// as it is unused.
.flags = 0
};
 
// We are now going to define a framebuffer header tag, which is mandatory when
// using the stivale2 terminal.
// This tag tells the bootloader that we want a graphical framebuffer instead
// of a CGA-compatible text mode. Omitting this tag will make the bootloader
// default to text mode, if available.
static struct stivale2_header_tag_framebuffer framebuffer_hdr_tag = {
// Same as above.
// All tags need to begin with an identifier and a pointer to the next tag.
.tag = {
// Identification constant defined in stivale2.h and the specification.
.identifier = STIVALE2_HEADER_TAG_FRAMEBUFFER_ID,
// IfInstead next isof 0, thenwe thisnow markspoint to the endprevious ofheader thetag. linkedThe listorder of tags.in
// which header tags are linked does not matter.
.next = 0
.next = (uint64_t)&terminal_hdr_tag
},
// We set all the framebuffer specifics to 0 as we want the bootloader
Line 198 ⟶ 215:
.flags = 0,
// This header structure is the root of the linked list of header tags and
// points to the first one (and in ourthe case,linked only)list.
.tags = (uintptr_t)&framebuffer_hdr_tag
};
Line 226 ⟶ 243:
// The following will be our kernel's entry point.
void _start(struct stivale2_struct *stivale2_struct) {
// Let's get the framebufferterminal structure tag from the bootloader.
struct stivale2_struct_tag_framebufferstivale2_struct_tag_terminal *fb_str_tagterm_str_tag;
fb_str_tagterm_str_tag = stivale2_get_tag(stivale2_struct, STIVALE2_STRUCT_TAG_FRAMEBUFFER_IDSTIVALE2_STRUCT_TAG_TERMINAL_ID);
 
// Check if the tag was actually found.
if (fb_str_tagterm_str_tag == NULL) {
// It wasn't found, just hang...
for (;;) {
Line 238 ⟶ 255:
}
 
// Let's get the address of the framebufferterminal write function.
uint8_tvoid *fb_addrterm_write_ptr = (uint8_tvoid *)fb_str_tagterm_str_tag->framebuffer_addrterm_write;
 
// Now, let's assign this pointer to a function pointer which
// Let's try to paint a few pixels white in the top left, so we know
// matches the prototype described in the stivale2 specification for
// that we booted correctly.
// the stivale2_term_write function.
for (size_t i = 0; i < 128; i++) {
void (*term_write)(const char *string, size_t length) = term_write_ptr;
fb_addr[i] = 0xff;
 
}
// We should now be able to call the above function pointer to print out
// a simple "Hello World" to screen.
term_write("Hello World", 11);
 
// We're done, just hang...
Line 467 ⟶ 487:
==Conclusions==
 
If everything above has been completed successfully, you should now have a bootable ISO or hard drive/USB image containing your 64-bit higher half stivale(2) kernel and Limine to boot it. Once the kernel is successfully booted, you should see a small row of white pixels in the top left of the screen when it comes to stivale1, while for stivale2 you should be seeing "Hello World".
 
== See Also ==