#Nullium
1 messages · Page 3 of 1
Because 32 bit
Okay let me look
absolute cancer i have
You are doing way too much lol
Also there is no reason to do any of this shit in an actual assembly file
fair
fair
I mean others may disagree with it, but all of the assembly stubs you have in that paging file are not necessary
Like
No need for a paging.asm
At all
honestly i dont really care what the others think currently lmao
fair enough
Well then fuck em lol
Just no need for that file at all
It’s basically just trivial mov statements
For parameters and shit
fair
asm volatile (why did it underline)
TIL i learned underlines exist on discord lmao
It’s like when you do bold
yes
Yeah that’s why many people type code within these blocks
true
Truth nuke
its like markdown language
literally?
mk
Tell me your dilemma ill brb
Triple faults when
as soon as paging is set
What instruction/line of code
unsure
Okay run qemu with these args
Run QEMU with following flags: -M accel=tcg,smm=off -d int -no-reboot -no-shutdown
Then when you crash, you should see the EIP value
no reboot no shutdown reminds me of "YOU WILL NOT LAUGH, YOU WILL NOT CRY!"
anyways aight
what do i use that for
Okay well from there
You’re going to use a cute program named addr2line
It’s extremely helpful
addr2line -e yourkernelexe 0x[EIP]
Yourkernelexe is just whatever your kernel executable is called
i wanna know where the fuck it pulls out the specific file and line from but mk
It’s fairly simple
You can actually add -f after your kernel executable to get the function name too
what the actual fuck
Well
There you go
You debugged for the first time lol
That’s very basic but
this is helpful but now i want to jump out the window
A good way to do it
the gdt is always evil
Glad to hear I could help
But that’s rudimentary debugging lol
I do that shit all the time
It’s a cheat for life fr
wait till bro gets race conditions 
"commit 897cb6: Introduce BKL to avoid race condition"
if i do anything other than a for loop it just goes to shit
For loop for what
the paging is always evil
Why are you doing the extern in the function
Thats interesting
I do worse things in my os tho lol
brain damage
Fair
moved it to header
Nice
But anyways
I could look through your paging code but
I think you would stand to learn some good things if you studied some more implementations
true maybe
I think I know what’s wrong with it but
show code i'll give it a shot
scroll up
here
^^^
no
It is yeah
yes
So it’s a bit diff
ok so try marking the pages present
But still
unpresent page causes fault
Or just use constants
idk im not an ia32 kid
ъ
still death
i might just want to rewrite this code
true
That is a horrible way of doing it
Just create a page attributes struct
You can just yoink mine
aight lemme find the intel manual im going insane
mk
typedef struct {
uint32_t present : 1;
uint32_t rw : 1;
uint32_t user : 1;
uint32_t write_thru : 1;
uint32_t cache_dis : 1;
uint32_t accessed : 1;
uint32_t dirty : 1;
uint32_t pat : 1;
uint32_t global : 1;
uint32_t available : 3;
uint32_t frame_addr : 20;
} page_attrs_t;
why does everyone always crashout when paging vro 🥀
bad idea..... unless you only compile with one compiler
bitfield layout is implementation defined
this could be fine with GCC and die on some other compiler
Yeah I only use one compiler
okay sure that is fine
literally all code might die with some other compiler
if you dont compile with gcc support isnt provided
if you compile with gcc no support either
(average user expects a working hobby os, he does not know that is impossible)
anyways
fair
But yeah don’t mark pages the way you were before
Just
I would rewrite tbh
Not saying what you did was shit
it was shit either way
yeah same
It’s okay, I rewrote my paging implementation a few times
fair
Okay I’m going out with my friend for like an hour or so
So I won’t be able to answer
But when I come back I’ll look at what you’ve done
mk i have to sleep now too probably
Yup
Look up
Mentos
MentOS
Extremely extremely solid 32 bit operating system
And very good to learn from
It’s almost perfect in my opinion
In terms of a hobbyist ia32 operating system, it is as perfect as it gets
found it
or learn from real kernels... 💔
I actually disagree
If you want to make a hobby kernel you need both to study real kernels and hobby kernels
linus torvalds
(registered trademark)
true
why
just read real kernels
maybe the real kernels are the friends we made along the way
real kernels are the ones that groups of people actually maintain long term and thus their code tends to be designed with some degree of maintainability in mind meanwhile we have hobby kernels like nyaux
No one is studying nyaux
and also real kernels, well, do things properly for the most part
I’m talking decent hobby kernels
unix-style war crimes
MentOS, managarm, astral, menix, mintia
but this can lead to stagnation where hobby kernels never look at what the real ones do and thus copy each other
Yeah but that’s why you keep a variety
Not just hobby or real kernels, study both
I’ve learned so much from MentOS
why do you gain anything from looking at the hobby implementation
why not just look at the real kernel
implementation is implementation
So you can see a vmm implementation without scrolling through 5 10000 line files
Like
Linux source tree is complicated
And sometimes it’s nice to see a smaller implementation
okay but said vmm would likely be highly suboptimal and maybe not include everything and the good vmms (mintia) are indeed around 15,000 loc
sooooooo 💥
Idk I just like studying a good mix
I mainly study BSD
70% of my source code studying is BSD
sure but you don't know if said smaller implementation is actually correct or optimal
what happened to daily linux reading
I do read Linux daily just not as much as before
I just fucking hate the drivers in Linux
Linux source looks scary lol
true
do you like reading it
I like reading it but it’s a bit overwhelming at times
I find that it tends to be okayish if you view it in an editor and sit down and read it well and good
not on github lol
I've seen a few snippets here and there
no actual code reading? 💔😔😔
are there any hobby kernels with numa aware allocators and other components because that's what I'll be doing soon
I was trying to read the page struct impl but I forgor
None that I know of
heartbreaking...
If you pull that off that’s insane
I'm only doing it for fun
Nah like not even NT had that for a long time
Hobbyist And Recreational
numa wasn't a big deal for a long time lol
but it's 2025 and it's everywhere
Welp, I guess I'm doing NUMA now, cause all the cool kids are doing it
on a serious note what are the actual benefits of NUMA
even on some """"consumer hardware"""
nothing if your system doesn't use it
only numa systems benefit
but those tend to be servers or 64 core desktop processors
ah, okie, might be lower on the priority list then
It’s fucking awesome
which are basically servers
uhh do be aware that this is very much a not easy thing to do and requires deep integration with the allocators and scheduler and other components
I'm doing it for fun
I don't think anyone else is doing it but imo they're just lame and missing out on fun
an aura loss as one may say
It’s definitely aura farming to implement numa
yeah, again probably pretty low on the priority list atm, since mine is supposed to be a desktop OS lol
wow what a helpful note
supah helpful
https://github.com/latentPrion/zambesii @hushed briar @wild glen @gloomy musk never mind, NUMA-aware hobby kernel located
bookmark ts fr
source tree low kinda funny im ngl
Ooooh, and non-UNIX :3
as opposed to a pig in fr*nce
I’m not even fucking kidding when I say this… I went to pick up my friend and outside his place there was a fucking gunshot
unc is in the hood
Just look up Chief Garry Park Spokane crime rate
I have a even more tree-structured drivers directory
io
-> io.h
-> serial
gfx
-> fb
-> vt
net
-> intel
-> e1000
I'll add timers
is there a point for something like this until your os supports at least 30000 video cards
and internet adapters
nah it just looks prettier
thats what i like to do
anyways except MentOS (int nuke_pagemap suggested it) are there any other good/ok paging implementations
i will combine them into an unholy abomination (joke)
break several open source licenses and cause the end of the universe as a whole (joke 2)
freebsd
i forgot that os existed
im somehow still surprised big projects are open source (freebsd, linux) im used to these just being gatekept to hell or not shared (windows)
yeah linux source code is a god send
RE NT easy peasy
drivers folder
why do strawberry and watermelon starbursts have basically the same color
i thought it was a misprint
(this should go to lounge 0)
is the standard for paging 4 KiB or 4 KB
if it's KiB someone is gonna be dying tonight
(kib = 1024 bytes, kb = 1000 bytes, i think)
i fucking hate humanity why cant we choose between 1000 or 1024 bytes
0x1000 bytes or 4000 bytes
iUEJKFQWHDKJQWDMKJQW
ok yeah time to actually look for myself
who made this bullshit
why cant it be 1000
power of 2 is always better
Both tables contain 1024 4-byte entries, making them 4 KiB each.

computers work on base 2
true but its still evil
nah, you get used to it
tbh i alr have 0x1000 in the page thing
anyways to convert a page index number to a memory address do i just multiply it by 0x1000?
not sure
i mean idk my itoa function outputs a little bit goofily
works but goofy
?
oh yeah
page is 4 kib (0x1000 bytes)
to make it from just a page number to an addr do i multiply number by 0x1000?
it's just a unit of measuring
ik
one page is 0x1000 bytes (in your case) so if you have to offset the address 0x6000 by one page it will become 0x6000 + (0x1000 * 1)
generically it's just address + (PAGE_SIZE * page_num)
im mentally fucked i dont have an offset but this seems right enough
paging is based on your PMM
true
reworked pmm so it will do kibibytes instead of "you have like 4 gb or something idk lmao enjoy
"
how necessary is paging and all that
THE thing that i want from it is program isolation
idk if i will actually use virtual memory and all that stuff
its probably quite necessary but i do not exactly want virtual memory because im quite ok with my current memory layout
you can write a kernel that runs without paging but it is an exceptionally bad idea
security?
it's """possible"""
no, literally everything is bad
like what
security is the least of your worries when you can't implement half the syscalls from posix
and also portability just dies
if you had an executable that only works with more than X amount of memory, and you have less than that, well ur outta luck
rip
*hardcoding physical memory addresses
what about it
nvm i remembered what that
I mean you can have a non posix OS but you'd have a lot of system calls similar to what posix has
stdio?
like winapi has tons of stuff that has "mirrors" in posix
have you ever looked at any of the system calls on a syscall table
windowing system is either hell or peace
and then compared it to other apis
ok go do that at https://syscall.sh
I literally used to write my syscall table is "blahblahblah | (my version of foo() in posix)" lol
wait this is just calling convention I forgor
how did vro not know about ts 💔
multithreaded preempting ti-84 operating system
💀
no i deadass learned c from a calculator and shitty directx tutorials
maximal throughput high performance low latency scalable ti-84 operating system kernel
anyways back to the point
this is information of all time
i mean they had to exist tho
otherwise like
pain
i am not adding all of these tho that would just be suffering (vm86 😭)
isn't this classic macOS thing
pretty sure they didn't do that either
bro copying them
whar
classic mac os wasnt even posix compatible at all
like no
like this project
absolute total no
💥
wait till you see literally anything in this project
its literally just mac os except "what if it ran on an x86 machine and wasnt shit in certain aspects and was even worse in others"
i want to make it not look like classic mac os except i got no ideas
theres a shit ton of windows clones already

wait do you need to set up virtual memory stuff for system commands
there's someone building a 16 bit real mode OS right now that has video games, a text editor, file browser, and more!
forget paging, you don't even need 32 bit to do this
fair
i made software interrupt now
INT 0x10
anyways uh
le paging
nvm
interrupt broak
ok i got software interrupts yooooooooo
vector 0x45
go convert that to decimal i fucking dare you 

do i add multiple interrupts that you can call or do i just add one really big one with all the commands and a shit ton of settings
or add like 5 really big ass interrupts and you have to call each to pass the arguments 
you need something like int 0x80 (or even better sysenter) to handle lots of commands with one interrupt
so that is a better choice?
registers are 64bit so you have a lot of space
one big interrupt?
one big beautiful interrupt
aight
0x45 is a nice number too (even more in decimal) its gonna ruin the thing if theres 0x46 or smth
isn’t 0x45 irq reserved?
pinky promise
this is isr 69 its def isnt reserved
you need space on your idt to allocate irqs
wtf did I write
wait what did that just say
phone keyboard autocorrect
.
from int 0x78 is safe
dos uses 0x21 but its real mode so idk

wiki says up to 77h
up to 77h are reserved?
but you can still allocate IRQs there
actually once got over interrupt 31 you are free to handle them how you want to
afaik you can associate any IRQ to any IDT entry when using APIC
or so i thought lemme check
0x45 != 45
im not interfering with any irq's
isr 69 my beloved
cool
you just need to keep a free list of IDT entries
ion wanna do that i just have them reserved right here and now so i wont do something stupid with the idt later
and/or me lazy
you might need entry allocation for pci drivers later
stolen image (yay)
anyway
one big ass interrupt
(causes collapse of universe)
im glad i joined this server
otherwise i would have so many damn misunderstandings of literally everything in osdev
https://wiki.osdev.org/SYSENTER
take a look at it, it’s the modern alternative to int 0x80 (0x45 in your case)
I do
i think that sounds like a good practice because there's def gonna be old grandpas using interrupts and normal people using the more modern stuff
linux i think still has the interrupt
just use syscall and sysret as it is common between amd and intel
it understands :0
i already have a crappy markdown file that ill put all the functions into
now commented
im gonna actually add paging when it doesnt drive me mentally insane
im kinda interested by the interrupts
i mean i have to add it eventually its just
ultimate procrastination
actually wait no
lemme just fucking add it i swear to god
also funny table
cool
no not yet
its more of a test
theres a single syscall
it doesnt do anything
literally 3 minutes worth of work
im gonna add paging when i get home
programs are gonna be pain theyre gonna think that everything starts at 0x000000
higher half programs at 0xC0000000 maybe? 
elf is evil
am i legally obliged to use elf
cant work on paging yet not home rn
ok nvm its a good format
all i really want is a portable asf format
too lazy to specify what exactly i want
no use mach-O for maximum LARP
apple's evil im not taking anything from them
-# (ignore everything else in this project that exists)
ok i triple checked that the physical allocator works
if paging shits itself i will not trust myself
(i already dont)
4096 byte pages
i think
anyways so i need a page directory and the page entry thing
wait
wtf is the explanation on the wiki
im confused
oh
nevermind i got it
its a bit weird
i thought the page directory had an address of the page table and the page table had access rights
i mean it has them both but its a bit funny
it works
officially
the last two columns show memory addresses now
i think that is a good enough pmm
currently
also it divides
i think it works
probably
does it
the page start is multiplied by 0x1000
page size is 0x1000 bytes
im gonna say it works it has no problems at all
at a glance
its already done except it was so ass i had to repair it
also its a freelist allocator apparently
wgat
👍
i hope the user wont have to just do "here's the number of your page bruh put it in a uint64_t and convert it to a memory addr no further explanation provided
"
ok so this is supposed page memory addresses in kibibytes
if you want bytes multiply that by 1024
then do whatever you want
(users writing drivers TOTALLY wont have a major pain in the ass)
for driver making theres gonna be a better way
outputs bytes
yay someone's following this :D
distracted by everything that exists
trying to do paging
wise choice, you’ll need paging a lot
true
i unfucked my pmm
it does 4 KiB pages
should help a lot with that
(triple fault go brrr
)
I wish I had your patience when I started osdev, I used to do everything swiftly and without reading specifications
well done so far 
man when i started osdev i was just like absolutely robbing everyone's code to make an abomination that is worse than the ultrakill mannequins
after dropping whatever tf that was thats when i actually didnt rob anyone's code
(that happened when the nullium thread started thats when i dropped that somewhat crappy piece of shit os)
anyways yay
le scrabthc
after paging ima mess around with making a window system
because yes 
pmm never works right
wait
nvm it works right
i thought pages could intersect
no lmao 
nvm they can
or can they
iOFKJASDJASKDHKJASDIOJWQDN
my brain too small
waht does diz mean
intersection
this doesnt happen apparently and i am happy
page 1 might take up some of page 2's space
intersection
what does "space" mean
memory
4kb pages must be 4kb large and 4kb aligned
yes
how do they intersect
yes
yes
it triple fault
:'(
>addr2line -e nullium.bin -f 0x0020490a
init_Paging
??:?
what died
i wanna know
lemme disasm it for shits and giggles
i cant find the address???
i wanted to disassemble and see where exactly it dies
behold
i am using gdb
me smort now
(my brain is a smore)
how it feels to break fn
how it feels to bt
i added -g into the make file and now the world is at peace
or whatever the debug option was
include debug symbols
i know exactly where it shits itself now
load_pd(pageDir);
enable_paging();
for(;;);
it dies right at the for loop
damn
i removed it and now it just dies at the function closing thing
it can load the page directory fine
ok it dies on the enabling paging instruction
it says it dies at line 59
made that last __asm__ a volatile
didnt help
lemme rework that piece of shit
i made it wonky as shit now
anyways so it crashes at the line after moving cr0 to eax
crash at:
mov %ebp, %esp
i did something really funny with the page tables probably
this is the init paging function
wait
ld_start might be the problem
modified to pageDir[0].table_addr = ((uint32_t)&pageTable + (uint32_t)&ld_start);
still death
removing it entirely
idk what was i thinking i doubt its even necessary
nope
dies
i used this struct
dont want to ping anyone
i bet 50000 i did THIS wrong
declarations
these are both 1024
im gonna de goofy that enable paging function
maybe the reason it's not working is because you aren't loading/mapping the kernel code so when you perform the jump it just crashes because the address isn't mapped anywhere
so i have to map it?
probably otherwise the computer doesn't know where that virtual address goes to
it would just not have a mapping
if you want
found this on wiki
you just make a PML4 (or whatever you do for ia32) and then set up all the entries in it and then load it
void vmm_init(struct limine_memmap_response *memmap,
struct limine_executable_address_response *xa) {
kernel_pml4 = alloc_pt();
if (!kernel_pml4)
k_panic("Could not allocate space for kernel PML4\n");
kernel_pml4_phys = (uintptr_t) kernel_pml4 - global.hhdm_offset;
memset(kernel_pml4, 0, PAGE_SIZE);
uint64_t kernel_phys_start = xa->physical_base;
uint64_t kernel_virt_start = xa->virtual_base;
uint64_t kernel_virt_end = (uint64_t) &__kernel_virt_end;
uint64_t kernel_size = kernel_virt_end - kernel_virt_start;
for (uint64_t i = 0; i < kernel_size; i += PAGE_SIZE) {
vmm_map_page(kernel_virt_start + i, kernel_phys_start + i,
PAGING_WRITE | PAGING_PRESENT);
}``` something like that
but with whatever you're using
fair
my kernel image is only 400kb so I only map it with 4kb pages and I don't expect it to grow to the extent that I need 2mb hugepages
also rq question in the pmm page start addresses have to divide by 4096?
mk
wat
needed to ask because i think im doing my allocator wrong
like page 1 is 0 and page 2 is 0x1000, 3 is 0x2000, etc
what does this mean though
is that how its supposed to be
it's supposed to be however you designed it to be
ok so i just map the kernel
if you want it to actually work after you enable paging, ya that would be the approach
you can just define these things in your linker script
offset?
(asking the stupidest questions in existence)
wdym how do you do an offset
wait
nvm
my kernel in its entirety is like 2.5 mb or smth (with the stack and all that other crap)
shouldnt be a problem actually because one table covers 4 mb
i think
that's a pretty big kernel
ya but 2.5mb kernel image is quite large I'd say
no there is probably BIOS stuff down below there
it's not a big deal you'll be fine
sure thing
pro tip: add -g to CFLAGS to get better addr2line infos
oh lol, predict
have you mapped the kernel before moving your page table to cr3?
if your kernel crashes right after loading cr3 it might be a bug in the page mapping code, but most of the times it's because the kernel code is unmapped
yall old macbooks are evil
yes they can run windows and yes they are pc compatible
however
no ps/2 emulation at all
you HAVE to add a usb keyboard driver
which sounds like fucking bullshit
also i feel like integrating 7zip or some other zip archiver into my system for shits and giggles once i finish literally everything
i think this is a good thing but ok
just write an xhci driver
my 2015 macbook air uses xhci
so fancy
then once you write the controller driver you just make a generic usb abstraction layer and write your usb driver
i have the same model :0
i guess
im talking as early as 2006 tho
and USB keyboards are indeed better than PS2 (that's why they exist)
tinyusb is a usb library that many people don't like, but it's a usb library
consider it if u want
nah not exactly
they're the same quality as ps/2 and MAYBE slightly worse
for advanced keyboards you can make a program for them because usb transmits literally everything so u can send data to the keyboard
so it has some advantages
one downside is that you cant press all the keys at one time
i dont really care about that though
who tf just pounds their keyboard like a monkey
what does quality mean
i mean not quality
I suppose PS2 being interrupt driven makes it better
i mean that usb has some slight disadvantages
but also
PS2 downsides:
no backlight
no rgbtq lighting
very important
they arent noticeable at all
no funky controllable lights :(
exatlclylsly....
to control the keybaord
what happens to a brain when you try to update windows vista :(
im not gonna be available for most of the day tomorrow
pain
anyways uh
paging time
i have 4095 byte pages
i hate my pmm
😭
what happened to the last byte 
idk
im not even sure if its 4095 or not
these are addresses of two pages near each other
so is it 4096 bytes of is it not
does it start at 0 and go to 4095 like arrays do
this is the most confusing problem in the history of mankind to me
iorijerwklfwekjlfewkjlewkjlfjlwlfjldsjsklfakjl
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
anyways
generally yeah you start from 0. So a page 4096 bytes long has bytes 0-4095
ok cool so i did it right
i hate my pmm less
(it always breaks somehow)
also random piece of code:
(void*)((uint64_t)palloc(1, true) * 1024) converts a page address in kib to bytes please someone check this if i start ranting about how paging triple faults in like a few minutes (i have doubts if this is right or not)
👍
palloc function prototype: palloc(uint32_t pages, bool returnMemoryAddr)
anyway
weird second argument but ok
usually returns a page number instead of a memory address
because im mildly stupid
ah yes the classic
void *malloc(size_t size, bool return_memory_address)
💥
you can turn a memory address into a page number and vice versa
#define ADDR_TO_PAGE(addr) ((uintptr_t)(addr) / PAGE_SIZE)
very astounding
not a malloc
im gonna add that later 
(palloc is the same thing except its fucking stupider)
(system use only :trl)
(emoji fail)
why is this necessary again
palloc returns kib instead of bytes because 
internal system functions can be as spaghetti as i want them to be
Your palloc sounds weird lol
you will not have a blast
truly
ok before it gets worse im just gonna make it return bytes i think this is pain
ok its un spaghettied
now returns bytes
im keeping the kib to byte macro though
no firmware flashing
how is paging going?
crashing on page table load?
redoing it now
im trying to redo it until im gonna fully understand it for some ungodly reason
i need a kernel mapping code afterwards too
I hate mapping existing memory before loading cr3, my code is totally obscure, I don’t even know why it works but it does
pagetable0[i] = (i * 0x1000) | 192; //11000000: present, read-write
any way to make this not look like some random ass magic number
can i just #define something then or (|) it with the pagetable item
Pretty sure that's what most people do ye
you can define stuff like PTE_PRESENT | PTE_WRITE
Look up the sdm pages
wait no idk how to word it (for google search (big stupid))
read the intel sdm for the page table structure if thats what you need
i know the page table structure
then what do you need then
(shitty wording) how do i | several values to get 192 or whatever other combination i want
so i wont have to go into a binary to decimal converter
bit shifting maybe??
You can do this, your code‘d look like this
(i*0x1000) | PTE_PRESENT | PTE_WRITE
yes thats what i want to do
also iirc present bit is 0, write is lower too? Why 192
11000000
first numbers
if its supposed to be backwards i can flip it
you read it right to left basically. Look at the bits on top of the table
yes
i know thats what i did
i read it from right to left
little endian
start from 0 end at 31
you‘re representing it wrong though. you set bit 0 and 1, not the high bits
right
right
huh
figured out how to make #defines for the table bits
#define PAGING_PRESENT (0x1UL)
#define PAGING_WRITE (0x2UL)
#define PAGING_USER_ALLOWED (0x4UL)
#define PAGING_ALL 0xFFFUL
#define PAGING_XD (1UL << 63) // E(x)ecute (D)isable
#define PAGING_PHYS_MASK (0x00FFFFFFF000UL)
#define PAGING_PAGE_SIZE (1UL << 7)
#define PAGING_UNCACHABLE (1UL << 4)
#define PAGING_NO_FLAGS (0)
#define PAGING_WRITETHROUGH (1UL << 3)
#define PAGING_2MB_page (1ULL << 7)``` kaboom
ignore ALL
dont use that like ever lol
spaghetti moment
XD
table
it sets flags on to the physical table my computer is on

tested it
it works
time to do the same for the page directory
you already have map/unmap functions right
uhhh
no 
whar
f
anyways uhhhhhh im gonna add these once i unfuck the initial paging setup code thing
you need to map pages of the kernel so you dont die after enabling paging
how did you get here thinking that you can just turn on paging like a switch and do nothing special before it 💀
💥
well this is done here in the setup thing
for (uint32_t i = 0; i < PAGE_TABLE_SIZE; i++){
pagetable0[i] = (i * 0x1000) | PAGETABLE_PRESENT | PAGETABLE_RW;
}
vro that doesnt do anything tho
damn
that's not how that works 💔

void vmm_map_page(uintptr_t virt, uintptr_t phys, uint64_t flags) {
if (virt == 0)
k_panic(":boom:\n");
struct page_table *current_table = kernel_pml4;
for (uint64_t i = 0; i < 3; i++) {
uint64_t level = virt >> (39 - (i * 9)) & 0x1FF;
pte_t *entry = ¤t_table->entries[level];
if (!ENTRY_PRESENT(*entry))
pte_init(entry, 0);
current_table = (struct page_table *) phys_to_virt(*entry & PAGING_PHYS_MASK);
}
uint64_t L1 = (virt >> 12) & 0x1FF;
pte_t *entry = ¤t_table->entries[L1];
*entry = (phys & PAGING_PHYS_MASK) | flags | PAGING_PRESENT;
}```
kablooey
this doesn't work for 32 bit don't copy the code
yes ik
but you will need something like this to map the kernel code so you don't jump to a nowhere address
💔
🥀
truly
🥀
it triple faults
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
found this (http://www.brokenthorn.com/Resources/OSDev18.html)
quite informative
is that the bite of 768
the resource i sent above says that the directory index (for 0xC0000000) is 768
idk im trying to write a thing that flags physical memory addresses to virtual
im just dumping whatever im doing here
peak progress report amirite
though for 1 mb i get "1"
0x00100000
makes sense i suppose
wait im doing it wrong
fuck it im assigning 0 to 0
patrick water jug.png
i have made some progress
instead of triple faulting as soon as paging is started
it triple faults when something happens after it
(how bad is everything that i am celebrating a crash right after the first one)
i may want a second table
oh
what the fuck
why is it 27 mb
WHY IS IT 27 MB
KJWEFM<WNEFKWJEFHJKWEF
DEADASS
WHAT
????????????????????????????????????????????????????
i was going to say a few bad words that are too bad for this server
what in the fuck
NO SHIT IT CRASHED WHO MADE THIS
(me)
sounds like an improperly mapped kernel perhaps?
maybe
the entire kernel is 27 fucking mb (IDK WHY I JUST CRASHED OUT OVER THAT)
and i only took 1 table
1 page table
thats not enough for this oversized fart 😭
i also allocated the 1mb before the actual kernel
that may or may not count
27 MB seems like waaaaaay too big lol
true
it starts at 1 mb but i also allocated everything before that 1 mb
maybe i dont have to allocate that
its probably not ever even used
i can just pretend it doesnt exist
should decrease size a lot
also note you can use info tlb and info mem to see your mappings
use where
qemu monitor