Build Your Own OS #8

OSDev wiki

Page Frame Allocation

ENTRY(loader)           /* the name of the entry symbol */    . = 0xC0100000          /* the code should be relocated to 3 GB + 1 MB */    /* these labels get exported to the code files */
kernel_virtual_start = .;
kernel_physical_start = . - 0xC0000000;
/* align at 4 KB and load at 1 MB */
.text ALIGN (0x1000) : AT(ADDR(.text)-0xC0000000)
{
*(.text) /* all text sections from all files */
}
/* align at 4 KB and load at 1 MB + . */
.rodata ALIGN (0x1000) : AT(ADDR(.rodata)-0xC0000000)
{
*(.rodata*) /* all read-only data sections from all files */
}
/* align at 4 KB and load at 1 MB + . */
.data ALIGN (0x1000) : AT(ADDR(.data)-0xC0000000)
{
*(.data) /* all data sections from all files */
}
/* align at 4 KB and load at 1 MB + . */
.bss ALIGN (0x1000) : AT(ADDR(.bss)-0xC0000000)
{
*(COMMON) /* all COMMON sections from all files */
*(.bss) /* all bss sections from all files */
}
kernel_virtual_end = .;
kernel_physical_end = . - 0xC0000000;
extern kernel_virtual_start
extern kernel_virtual_end
extern kernel_physical_start
extern kernel_physical_end
; ... push kernel_physical_end
push kernel_physical_start
push kernel_virtual_end
push kernel_virtual_start
call kmain
void kernel_virtual_start(void);    /* ... */    unsigned int vaddr = (unsigned int) &kernel_virtual_start;

Managing Available Memory

How Might We Access a Page Frame?

(768 << 22) | (1023 << 12) | 0x000 = 0xC03FF000

A Kernel Heap

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Good design from the ground up — how I/O library design can make or break IoT solutions

Looking to Host Your Own LMS System? Here’s What You Need to Know…

How to Get Technical Help From Strangers on the Internet

Don’t UNDERESTIMATE yourself!

git is eating the world

Sentiment Analysis using Twitter API and GCC

RiteTag 2.0: Hashtag suggestions for Instagram and 9 more features, same low price!

I will convert psd, xd, figma, sketch to html css bootstrap

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Niroshan Pushparaj

Niroshan Pushparaj

More from Medium

Final Project — Workflow and Creative Camera

8 best indoor games for your child’s mental growth

Zach Price — Social Media in Digital Productions

FanBaaS-Token Issuance Tool (2)