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
// 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.▼
// 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.
},▼
// 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,
//
// 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
.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
struct
// Check if the tag was actually found.
if (
// It wasn't found, just hang...
for (;;) {
Line 238 ⟶ 255:
}
// Let's get the address of the
// Now, let's assign this pointer to a function pointer which
// matches the prototype described in the stivale2 specification for
// the stivale2_term_write function.
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 ==
|