#SnowOS

1 messages · Page 5 of 1

narrow storm
#

and most things by default target it for non MSVC compilers etc

hushed spire
#

fair

#

anyhow Imma go write a todo list for today :3

narrow storm
#

on windows ABI you cannot pass a 128 bit return value

#

and only 4 registers are used for arguments

#

otherwise its not as bad as i rememeber?

void elm
#

it doesnt allow to pass struct fields as registers

#

so e.g. string_view or similar gets a lot more expensive than on sysv

narrow storm
#

what does it do in that case?

#

dump it onto the stack?

void elm
#

pointer to the struct on the caller's stack i think

narrow storm
#

also sysv is generaly just nice to work with in assembly imo

#

like look at this stack crap

hushed spire
#

lol

narrow storm
#

On sysv I never really have to touch the stack for like most things

#

Esp for tiny leaf functions im making

#

Like this

hushed spire
#

uhhh, is there a flag to tell clang to use ths SysV ABI? I'd rather not spam __attribute__((sysv_abi)) everywhere

narrow storm
#
  1. its the default in 99% of cases
  2. its a compile flag
hushed spire
#

ah okay

narrow storm
#

You also want to disable the redzone

#

Because it’s a fancy part of the ABI

#

And for kernels interrupt handlers will fuck up the redzone

#

It’s basically a part of the stack for leaf functions to use as scratch space and not need to allocate from the shack

#

And IRQ handlers may push shit inside of it

#

🫠

#

Well

hushed spire
#

uh 💀

narrow storm
#

Rather the CPU will

narrow storm
#

That won’t support sysv

hushed spire
#

I just told clang "make PE" pepekek

narrow storm
#

sysv is a lot more of a Unix thing

hushed spire
narrow storm
hushed spire
#

uhhh, I think that's it? Not particularly interesting but eh pain

[] - Tweak Spinlock Implementation
[] - Clean up code some
[] - Timer Interrupts

narrow storm
#

use LAPIC for timer IRQs

#

:3

#

its garunteed on all x86-64 chips

#

just needs clibration from another timer

hushed spire
hushed spire
narrow storm
#

waow based based based based based

narrow storm
#

then if the TSC is constant calibrate that

#

then use that for clibrstion of LAPIC

hushed spire
#

oh ye, I keep forgetting about the ACPI timer 😆

hushed spire
#

Oh! I also need to update to Limine 11

hushed spire
#

I think this should work?

static inline VOID SpinlockAcquire(PSPINLOCK Lock)
    {
        // Get the state of the IF before disabling interrupts
        Lock->IntsEnabled = HalInterruptsEnabled();

        __asm__ volatile ("cli" ::: "memory");

        while (true)
        {
            if (!__atomic_exchange_n(&Lock->Flag, 1, __ATOMIC_ACQUIRE))
            {
                return;
            }

            while (__atomic_load_n(&Lock->Flag, __ATOMIC_RELAXED))
            {
                __asm__ volatile ("pause" ::: "memory");
            }
        }
    }

    static inline VOID SpinlockRelease(PSPINLOCK Lock)
    {
        __atomic_store_n(&Lock->Flag, 0, __ATOMIC_RELEASE);
        if (Lock->IntsEnabled)
        {
            __asm__ volatile ("sti" ::: "memory");
        }

        else
        {
            __asm__ volatile ("cli" ::: "memory");
        }
    }
narrow storm
#

i wouldnt store it in the lock

#

it should be a return value

#

and you have the atomics reversed to be proper

#

and the return

#

🥀

#

also i hatr this code style but trl

hushed spire
narrow storm
#

somthing takes the locks with IRQs disabled

#

then somthing takes it with them enabled

#

then when the first one returns

#

they get enabled

#

💥

#

using the [[nodiscard]] attrbute makes it so you cannot ignore the return value

hushed spire
#

ah

#

okie then

narrow storm
#

making you pass it to the unlock funcion or similar

hushed spire
# narrow storm making you pass it to the unlock funcion or similar

this better?

[[nodiscard]]
static inline BOOL SpinlockAcquire(PSPINLOCK Lock)
{
  // Get the state of the IF before disabling interrupts
  BOOL IntsEnabled = HalInterruptsEnabled();

  __asm__ volatile ("cli" ::: "memory");

  while (true)
  {
    if (!__atomic_exchange_n(&Lock->Flag, 1, __ATOMIC_ACQUIRE))
    {
      break;
    }

    while (__atomic_load_n(&Lock->Flag, __ATOMIC_RELAXED))
    {
      __asm__ volatile ("pause" ::: "memory");
    }
  }

  return IntsEnabled;
}

static inline VOID SpinlockRelease(PSPINLOCK Lock, BOOL IntsEnabled)
{
  __atomic_store_n(&Lock->Flag, 0, __ATOMIC_RELEASE);
  if (IntsEnabled)
  {
    __asm__ volatile ("sti" ::: "memory");
  }

  else
  {
    __asm__ volatile ("cli" ::: "memory");
  }
}
narrow storm
#

yes i think so

hushed spire
narrow storm
#

But please

#

Reconsider this coding style

#

🥀

hushed spire
#

no trl

narrow storm
#

You don’t even need the brackets

hushed spire
#

what about it?

narrow storm
#

You can do an if and else

hushed spire
#

which brackets?

narrow storm
#
static inline VOID SpinlockRelease(PSPINLOCK Lock, BOOL IntsEnabled) {
  __atomic_store_n(&Lock->Flag, 0, __ATOMIC_RELEASE);
  if (IntsEnabled)
    __asm__ volatile ("sti" ::: "memory");
  else
    __asm__ volatile ("cli" ::: "memory");
}
#

thats valid

hushed spire
#

I personally don't really like how that looks, hence why I didn't do it KEKW

narrow storm
#

But why do you make it take like 3x likes of code

#

is it just to get your stats up

hushed spire
narrow storm
#

No

#

I just can’t read it that well

hushed spire
#

lol

narrow storm
#

I hate gnu styles

hushed spire
#

I mean ig I can change it zerotwoshrug

#

I mean there's nothing for the other CPUs to do but hey KEKW

narrow storm
#

What’s the bootstrap allocator for?

#

For a freelist PMM and a buddy you can store the freelist nodes inside of the free pages themselves ;3

hushed spire
#

allocating pages for the PFNdb and mapping said PFNdb

narrow storm
#

Ahh so not a bump allocator etc

#

Just a PMM

hushed spire
#

no it is a bump allocator 🤣

#

also If I decide to go down the route of "scheduler inits before everything else" I'm pretty sure I need a bootstrap allocator as well

narrow storm
#

I mean you could just delay it until you have a heap setup

#

Do GDT IDT (to catch faults and panic) PMM/PFNDB VMM Heap -> scheduler

hushed spire
#

ik but liam said it was a good idea to setup the scheduler first before pretty much anything else :3 (ofc I'm doing it the easier way first because my brain can't handle that order of operations right now pain)

narrow storm
#

Why would you want a scheduler before you can do basic memory management?

hushed spire
#

lots of things depend on the scheduler, or so I've been told zerotwoshrug

narrow storm
#

My kernel inits the schedular very late lol

#

You also possibly want timers before the scheduler

hushed spire
#

I found it

#

I really should just take a screenshot of it at this point

#

so I don't have to go searching for it every time 🤣

narrow storm
#

How would you setup the scheduler if you cannot allocate memory properly?

hushed spire
#

Ask liam not me KEKW but from my understanding, the scheduler doesn't really rely upon process creation to work, all it does is look a queue and say "yup, that thread gets to run next" pepekek

hushed spire
#

yikes

#

okay both Limine and Flanterm should be updated now :3 lemme push the commit

#

there! party

hushed spire
#

I'll uh, work on timer interrupts now ^w^

#

was debating on whether or not to support the PIT. On one hand, I would think any modern PC would have the HPET/ACPI Timer/TSC, on the other hand, I presume the PIT's fairly simple so it's kind of seems silly to not support it zerotwoshrug

#

would ACPI be a Hal thing or a Ke thing, or maybe something else? GuraThink

#

idk I'll put it in Hal for now and I can move it somewhere else later if I need to

hushed spire
#

siiiiigh

hushed spire
#

huh? 😭

#

nothing is ever simple

#

what if I just copy the header to freestnd-c-hdrs trl

#

no

#

once again, clang posing as MSVC is causing problems (at least I think that's the issue, intrin.h seems to be a MSVC thing)

#

okay wait hol' up

#

haha! I shrimply commented out the include in compiler.h KEKW

hushed spire
#

I'm guessing it's mapped with the HHDM?

#

seems like it

hushed spire
#

I really gotta implement proper VA allocation

#

in fact

#

I'll probably start on that right after timer interrupts

#

I'm just now seeing an issue with this code pepekek

#

big oof

#

I'll read the vmem paper tmrw

hushed spire
hushed spire
#

I can't wait to work on scheduling :3

#

fricking context-switching is what thwarted me the last time I tried to write SnowOS 😭

#

as evidenced by my crashouts trl

visual walrus
#

you probably don't want to auto enable interrupts, lol

hushed spire
hushed spire
#

I just didn't really have the energy to work on this today

#

pepepray tmrw for sure

hushed spire
#

I should implement a ring buffer for logging GuraThink

narrow storm
#

I’d probably have a staging page or a few on BSS to log before your allocator is up

#

Then allocate a larger buffer

#

And copy it and reclaim the old buffer

#

Then you can let userspace read it

#

Ala dmesg

hushed spire
#

ahhh, okie

#

seems simple enough :3

narrow storm
#

Make sure that it’s page aligned on the linker script

#

And that it’s padded properly etc

#

Though you could maybe use attributes

hushed spire
narrow storm
hushed spire
#

I dunno how to write one for PEs 😭

narrow storm
#

Why do you need to use a PE for the kernel

hushed spire
vivid helm
vivid helm
hushed spire
#

I'm going on a road trip party

#

Which means SnowOS time!!!! letsgo (or at least til my laptop dies in the car KEKW)

hushed spire
#

I should probably consider writing some unit tests

hushed spire
#

Okay wait, my old Slab impl doesn't really sound like the same thing the paper describes. It seems like I pretty much wrote a Slab but just without object caching, which... seems like it kind of defeats the point of a Slab 😅

hushed spire
#

I should also take a looksie at how Windows does this thinkong

hushed spire
#

Okay Vmem doesn't seem too dreadfully hard (I'm still too dumb to completely understand it but oh well trl)

hushed spire
#

I should also read up on UVM :3

narrow storm
#

Let me know

hushed spire
narrow storm
#

Don’t be scared

#

I only skimmed it while I was half asleep

#

💀

#

That’s why I don’t get it to be clear

hushed spire
#

oh lol

#

it's still confuzzling me tho KEKW

narrow storm
#

It dosnt look too bad

#

I think it’s like for virtual allocations?

hushed spire
#

ye (resource allocation in general it seems, but virtual allocations seems to be the big thing)

narrow storm
#

Virtual allocations will be heavily wanted by Userspace iirc?

#

For the kernel I plan to use my buddy allocater for large allocations for kernel stacks etc

hushed spire
#

well, while I try to wrap my head around vmem, imma implment page unmapping functions, and maybe try to figure out how I can make the hal a dll thinkong

narrow storm
#

Btw page unmap can be the same as mapping a page except setting its PTE to zero and doing a tlb invalidation

#

And maybe checking if that level is empty etc

#

(If you want to free the tables as you go but that can be seperate)

hushed spire
narrow storm
#

Nice :3

hushed spire
#

okay so an arena is just a range of integers, simple enough

#

but like this I don't understand
The slab allocator can provide object caching for any vmem arena

#

doesn't the slab depend upon vmem?

#

how is it providing object caching then? 😭

lunar vortex
#

vmem has this quantum caching thing that uses the slab allocator

#

I don't think it's worth it tho

#

Here's my implementation from a while ago

hushed spire
#

thx! I'll take a look at it :3

lunar vortex
#

It kinda sucks tho

#

Well it's not that good

#

it's fine

hushed spire
#

can't suck anymore than whatever I'll end up writing pepekek

narrow lake
hushed spire
#

okie, back to trying to implement vmem :3

hushed spire
#

is there some reaons this needs to return a pointer confusedshiki

#

cuz like, doesn't that mean I need some way to allocate a vmem arena

#

oh wait

#

ah

At compile time we statically declare a few vmem arena structures and boundary tags to get us through boot.
#

well I guess there's my answer

lunar vortex
hushed spire
#

I was thinking that too GuraThink

#

okie dokie :3

hushed spire
#

well I have a function that chucks stuff into a vmem arena struct

#

not much

#

but better than nothing KEKW

hushed spire
#

make to the osdev grind

#

maybe I'll actually do something useful today KEKW

hushed spire
#

I'm on vacation gimme a break lol

#

I will actually try today tho

hushed spire
#

gonna write a generic linked list impl

#

should class names be the same style as struct names or in PascalCase like I usually do? GuraThink

hushed spire
#

function overloading! Everyone's favorite KEKW

#

having data in the second overload is actually kind of redundant now that I think of it

#

actually overloading might be annoying for debugging now that I think about it

#

ofc I can't debug my kernel rn anyhow so pain

hushed spire
visual walrus
#

it works somewhat well

hushed spire
#

sure zerotwoshrug

hushed spire
#

oh ye, I forgor I can overload new thinkong

hushed spire
#

also seems like the segment list needs to be ordered

hushed spire
#
range to use for the kernel heap``` okay so clearly this is the arena for VAs used for the kernel heap
#

Once we have the heap arena, we can create new boundary tags dynamically but then I can suddenly allocate things now that I have it? Even though it doesn't actually allocate pages

#

am I supposed to start the slab after creating the heap_arena?

#

I would think?

hushed spire
#

also pretty sure I need to use a hashmap for this

#

so I need to learn about those

#

ah, they don't seem that complicated

hushed spire
#

I shouldn't be having this much trouble trying to implement this sadge

#

what if I just try to do a more naive implementation of a VA allocator and come back to this later pepekek

#

just so that I can get to do other things

#

eh screw it I think I'll do that zerotwoshrug

mellow current
#

sub title should be winter will come

hushed spire
#

I'm officially announcing that SnowOS will be completely rewritten into Rust! party

hushed spire
#

SnowOS - A modern OS written entirely in Rust

hushed spire
#

SnowOS

#

I'm pulling y'all's leg pepekek

#

I don't think you could pay me enough to use a different language for this lol

#

anyhow

hushed spire
#

I really would like to get VA allocation setup to day 😔

hushed spire
narrow storm
#

25 grand

#

When I get a job

hushed spire
#

C++ foevaaaaa!!! >:3

narrow storm
#

You mark a hard bargain

#

200 grand when I get a load and take 3 mortgages on my house

#

That’s my final offer

hushed spire
#

no :3

hushed spire
#

okie I'm finally getting somewhere party

#

userspace impl of vmem is going well

#

I can't imagine actually implementing it in the kernel will be much harder :3

hushed spire
#

also might make the code style slightly less NT-pilled, for personality

hushed spire
#

oh ye

#

still wanna make Hal into a DLL

#

think I might get started on that

hushed spire
#

okay I think I'll focus on vmem for now, this seems slightly harder than I initially thought 😅

narrow storm
hushed spire
#

been a kind of slow few days lol

#

hopefully I'll get something working today

hushed spire
#

guess my insertion code isn't working meme

#

ah hah! Fixed it :3

hushed spire
#

gonna be heading back home today

#

maybe I'll actually get some work done :p

#

currently working on the freelists for an arena

#

I think I'll make my goal for this month to be to launch a userspace process

#

Surely I can get the scheduler done by the end of the month trl

visual walrus
#

but now i can do that!

hushed spire
#

Mine didn't even work the last time I tried KEKW

visual walrus
#

the big problem i had was to compile llvm's libc++ and mlibc

#

for my OS

hushed spire
#

ahhh

#

I still wanna try and look into porting mlibc GuraThink

visual walrus
#

it's not that bad

hushed spire
#

if your POSIX-compliant maybe not pepekek

#

we're getting somewhere!

hushed spire
#

oh hey

#

I've apparently reached my first 1000 loc party

hushed spire
#

Might clean the code up some before I continue

hushed spire
hushed spire
#

if I ever try to change to code-style again, please yell at me pepekek

#

I do think I like this style better though

#
extern "C" void keMain(void *snowbootInfo)
{
    keRunConstructors();

    hal::initialize();
    hal::printString("Snow Operating System (c) 2025, 2026 UtsumiFuyuki\r\n");
    ke::print("Yuki Kernel Version %d.%d.%d\r\n", YUKI_VERSION_MAJOR, YUKI_VERSION_MINOR, YUKI_VERSION_PATCH);
    ke::print("Booted by: ");
    
    if (snowbootInfo == nullptr)
    {
        ke::print("Limine %s\r\n\r\n", hal::blVersion());
    }
    else
    {
        ke::print("SnowBoot\r\n");
    }

    hal::initCpu();
    mm::earlyInit();
    hal::initializePaging();
    mm::initialize();
    mm::initializeVmm();

    // We're done, just hang...
    hal::haltCpu();
}
narrow storm
hushed spire
#

Why is that an issue? 😭

narrow storm
#

nothing

#

i just dislike it

hushed spire
narrow storm
#

its too gnu

#

also why are you putting \r\n in every line

#

when your printf can convert \n to \r\n

hushed spire
#

I don't think I've ever seen a line of gnu code so I wouldn't know zerotwoshrug

hushed spire
#

more pressing matters

narrow storm
narrow storm
#

🥀

hushed spire
# narrow storm

Fine I'll change it 😛 for what it's worth I flip between the two anyhow trl

narrow storm
#

That’s straight up nasty 😭

#

At least get a clang format file

hushed spire
#

I'm trying to find mah style sigmapepe

narrow storm
#

Fair

#

I’ve been doing TS over like 6 years now prolly?

hushed spire
#

coolio :3

visual walrus
#

i hate it XD

hushed spire
#

bmlflllaldjks

#

okay

#

I think I'm done refactoring for now

#

pushed the commit

serene lake
#

could have sworn i was following this already

#

i am now 😄

hushed spire
#

yay

#

And this thread has reached 20 stars! party2

#

I definitely don't deserve it but eh pepekek

serene lake
#

the font makes your name look like O++ Shill

#

barely any black separating space, because of the glow

hushed spire
#

Oh it does KEKW

serene lake
#

maybe its a special secret blood type

#

i am O positive positive

#

😄

hushed spire
hushed spire
#

when'd I start trying to implment vmem?

#

like a week ago pain

#

anyhow

#

think I hafta implement vmemFree now

#

just trying to get something simple setup :3

#

also need to figure out what the heck I do about sources 😭

hushed spire
#

freeing is a bit more complicated than allocating lol

lunar vortex
#

freeing is simpler imo

#

You just have one logic

#

Allocation has three policies

lunar vortex
hushed spire
#

I only have instantfit implemented at the moment lol. Though bestfit and nextfit don't seem that complicated

hushed spire
#

WE GOT SOMETHING WORKING!!! letsgo

hushed spire
#

took a break :3

#

anyhow

#

now I'm gonna make it actually coalesce segments now

hushed spire
#

seems to work! ^w^

#

I guess I'll find out later if it's broken trl

#

Anyhow now I have to make it actually put the newly freed segment back onto the freelist, because currently I'm only manipulating the segment list

hushed spire
#

this is so messy KEKW

#

granted this is my first time writing a coalescing, ordered freelist, so I guess it's bound to be a little messy

lunar vortex
#

what are you having trouble with

hushed spire
#

nothing in particular I just think the way I'm doing it is really messy pepekek

lunar vortex
#

this is what I do

lunar vortex
#

why are you using pow

#

you can very quickly get one size's freelist using log2

#

and log2 is pretty damn fast

hushed spire
#

uh, is there an issue with pow?

#

wut's log2?

lunar vortex
#

yes

#

dont do that

lunar vortex
hushed spire
#

ah

lunar vortex
#

you can implement it very cheaply using ctlzl

hushed spire
#

yeah I dunno how to do logarithms so that probably explains why I didn't think of it pepekek now that you say it though that does make more sense

lunar vortex
#

you dont ever need to iterate over 64 freelists

lunar vortex
hushed spire
#

I don't even know what "rotor" means 😭

lunar vortex
#

it's for next fit

#

it's the last allocated segment

hushed spire
#

ah

#

okie :3

#

okay I went ahead and pushed the commit, I'll work on the freelist manipulation tmrw :p

hushed spire
#

aight, Imma go work on my math some, and then by like, 7 or 8 I'll do some more OSDev >:3

hushed spire
#

Aight, I need to write a log2 function, uh, however I'm supposed to do that zerotwoshrug

serene lake
#

feel free to look at mine, be aware it isn't my work. it's a combination of freebsd code and questioning an LLM to kind of understand the concepts as a non mathematician

#

but I know it works, and didn't didn't want to spend time making maths stuff

narrow storm
#

According to stackoverflow if you just need it to work for integers

#

Or looping methods

hushed spire
#

ah okie! neat :3

serene lake
#

it's more work for floating point

hushed spire
#

I can't be bothered to do floating point rn KEKW

serene lake
hushed spire
serene lake
#

I needed it to work with double, and didn't know my naive approach was wrong until I tried to make an xm player

lunar vortex
serene lake
hushed spire
serene lake
#

the 2nd one never increments index so is an infinite loop

narrow storm
lunar vortex
#

Sorry clzl

serene lake
#

isn't there an sse2 log2?

hushed spire
lunar vortex
#

Integer log2 is really cheap idk why you'd use sse or something more complex

narrow storm
#

Crap

#

Is that the right one?

#

I cant find the ones your mentioning

lunar vortex
#

Yeah but use gcc intrinsics

serene lake
hushed spire
#

just to ask, is there a reason I shouldn't use std::countl_zero()?

lunar vortex
serene lake
#

if you're implementing libm you'd need it

lunar vortex
#

He's not implementing libm

serene lake
#

well they haven't said what the use case of log2 is

hushed spire
#

what's libm? confusedshiki

serene lake
#

generic maths lib

hushed spire
#
that is, freelist[n] contains all free segments
whose sizes are in the range [2n, 2n+1). To allocate a
segment we search the appropriate freelist for a
segment large enough to satisfy the allocation.```
serene lake
#

isn't this just bit shifts

#

it's <<

#

and yeah lzcnt

#

I use the bit count intrinsics in my FS driver

lunar vortex
#

What you wanna do is 64 - clzl(num) - 1

hushed spire
#

okay yeah, figured :3

#

it works! party

#

uhhhh, how do I actually coalesce the block though pain because it's getting chucked onto the freelist the block it was allocated from isn't on

#

actually do I have to change the freelist a block is on upon allocation? Since it's size has changed?

lunar vortex
#

hmm?

hushed spire
#

Like, my initial free segment has a size of 0xF0000000 and get's put on freelist 31. And say eventually after some allocations it's size goes down to 0x70000000, which should now be on freelist 30, even though it should be on freelist 30 now, it remains on freelist 31, which seems like it would kind of defeat the point of having a size segregated freelist GuraThink

lunar vortex
#

You would split it

hushed spire
lunar vortex
hushed spire
#

okay figured 👍

#
segment we search the appropriate freelist for a
segment large enough to satisfy the allocation.```
Slight question, I would *presume* that I also check freelists above n, in the case that freelist[n] is empty. I don't get the feeling I'm supposed to just fail the allocation if freelist n is empty, wouldn't make much sense ![KEKW](https://cdn.discordapp.com/emojis/913708372329644042.webp?size=128 "KEKW")
lunar vortex
#

Yes

hushed spire
#

okay I think I just have to fix this?

#

And then I should have an, albeit janky, technically working vmem implementation

#

Emphasis on the "technically" KEKW

#

it'll probably break eventually, but I'll cross that road when I get there

hushed spire
#

I have awoken!

#

Back to implementing vmem :3

narrow storm
#

No FRED implementing trl

#

I mean it would be a decent break

#

It’s actually not too bad to implement imo

#

Though it does look like your vmem is going well

hushed spire
#

FRED I'll either try to implement after this or after I work on scheduling some GuraThink

#

I really wanna work on scheduling >:3

narrow storm
#

FRED does swap up how you may do some of that with entry into userspace :3

#

(It’s not bad tho)

hushed spire
#

uhh, as incomplete as my vmem implementation is I know that shouldn't be happening pepekek

#

time to spam printfs trl

hushed spire
#

ah yes, vmemAllocate is broken, idk why I did it the way I did KEKW

#
for (auto *currentNode = arena->segmentList.getHead(); currentNode != nullptr; currentNode = currentNode->next) {
        // Find corresponding node in segment list
        if (currentNode->data.segmentBase == head->data.segmentBase && currentNode->data.type != VMEM_SEGMENT_SPAN) {
            if (currentNode->data.segmentSize == size) {
                currentNode->data.type = VMEM_SEGMENT_ALLOCATED;
                return currentNode->data.segmentBase;
            }
            auto *allocatedNode = &initNodes[nextFreeNode];
            allocatedNode->data.segmentSize = size;
            allocatedNode->data.segmentBase = currentNode->data.segmentBase;
            allocatedNode->data.type = VMEM_SEGMENT_ALLOCATED;

            currentNode->data.segmentBase += size;

            arena->segmentList.insert(currentNode, allocatedNode);
            nextFreeNode++;
            return allocatedNode->data.segmentBase;
        }
    }
``` for some reason I do this, which would *usually* work, except because the freelist doesn't get coalesced properly (working on figuring out how to do that) there's no longer a "corresponding node" and it just returns 0 lol
#

pretty simple fix tho :3

hushed spire
#

freeing must also be broken I suppose pain

#

how it's broken idk kongoudisgust

#

but evidently uACPI is not happy

#

eh, I'll figure it out later :p

#

I honestly may work on scheduling some rn thinkong

#

since I don't actually need a timer

hushed spire
#

well that ain't very helpful =/

hushed spire
#

boy I sure wish LLDB would work lol

lunar vortex
hushed spire
#

ah well that worked! :3

#

weird

#

I shouldn't be calling any uACPI functions atm =/

#

I'm guessing my context switch is screwed up in some way then pepekek

lunar vortex
hushed spire
#

ah yeah

#

oh god I'm dumb

#
mov rsp, [rcx+128]

mov rax, [rcx+8]
mov rbx, [rcx+16]
mov rcx, [rcx+24]
mov rdx, [rcx+32]
``` gee, I wonder what the issue here could possibly be ![pepekek](https://cdn.discordapp.com/emojis/1255025354276470846.webp?size=128 "pepekek") (does it matter if I move in values from a thread struct into the gp regs, or should I put them on the stack?)
#

hmm, yeah seems like they should be on the stack GuraThink

narrow storm
#

/ what’s the context for this

hushed spire
#

context switch

narrow storm
#

And Intel or Nasm

hushed spire
#

intel

#

or well

#

nasm

#

what's the difference? confusedshiki

#

doesn't nasm use intel syntax?

narrow storm
#

Wait fuck

#

I meant Intel or att

hushed spire
#

lol

narrow storm
narrow storm
#

extern void thread_switch(spinlock_t* spinlock, int irqs, uint64_t* old_sp, uint64_t new_sp);

#

then after calculating the thread its a

    uint64_t* old_rsp = &previous_thread->krsp;
    uint64_t  new_rsp = next_thread->krsp;
    thread_switch(&scheduler_spinlock, lock1r, old_rsp, new_rsp);
hushed spire
#

aren't you supposed to iret?

narrow storm
#

Not for a thread switch

hushed spire
#

ah

narrow storm
#

That’s for when you need a privelege change

narrow storm
#

And pre push things initially

hushed spire
#

uhhh, what does ret pop off the stack again?

narrow storm
#

The instruction pointer

#

Call pushes the IP to return to

hushed spire
#

okie

narrow storm
#

And I push many function pointers there

#

So when one returns it goes to the next etc

narrow storm
#

And this will also break if you try and switch to the same exact thread iirc?

hushed spire
#

so wut happens when there's only one thread in the queue?

narrow storm
#

My schedular checks if the next thread is the same as the previous

#

And if so it won’t run switch

#

But just return

hushed spire
#

ah

narrow storm
#

this is the trampoline i use to make it properly follow sysv aswell

#

and this is to jump to CPL3 just to be complete

#

Oh btw sorry @hushed spire for dumping code

#

😅

#

I should have asked

hushed spire
#

all good lol

#

coolio sigmapepe

narrow storm
#

Yooooo

#

Make one print A and the other B

#

or even better

#

make them take arguments proper etc

#

to control the behavior at thread start

hushed spire
#

now uhh, lemme implement the rest of the switch, because currently it only does half the work KEKW

narrow storm
#

(use malloc if you do a string)

hushed spire
hushed spire
narrow storm
#

Or any kind of memory allocation

#

Because you can’t give it a local reference to a new thread

hushed spire
#

true

narrow storm
#

and you can only pass word sized values

#

Btw what ABI did you end up with?

hushed spire
#

The Microsoft one I'm pretty sure

narrow storm
#

My code is for sysv ABI

#

Because it’s actualy sane

#

Your gonna need diff code then

hushed spire
#

ye figured

#

I couldn't figure out how to compile a PE with the SysV ABI 😭

#

x64 ABI hasn't gotten in my way that much yet tho so zerotwoshrug

narrow storm
#

Fingers crossed

#

Just tweak the code to save and restore and swap the right registers

hushed spire
#

Okay, I'm gonna draw some, read OSTEP some, then I'll work more on thread-switching :3

#

after that I think I'm gonna go through the code and see if there's anything I can clean up

hushed spire
#

Aight letsgo

narrow storm
#

What did OSTEP tell ya?

hushed spire
#

I should just start reading it before I leave at this point KEKW

narrow storm
#

FWIW it probably won’t effect your task switching code

#

Maybe your thread structs

hushed spire
#

I feel like it's never not windy

narrow storm
#

But not the low level code that’s required as per ABI and architecture

hushed spire
narrow storm
#

And esp if you make static asserts for the position if things

#

So your assembly won’t magically fuck up

hushed spire
#

anyhow I think it should maybe work rn GuraThink in theory anyways. Current conundrum is that setupStack well, pushes things onto the stack, and when I try to preform the switch the old thread will push things onto the stack (because it doesn't know it's already been setup) and then 💥

narrow storm
#

No

#

When you switch to the stack for the first time

#

It pops them off

hushed spire
#

I'm thinking maybe just write a small trampoline zerotwoshrug

narrow storm
#

That’s why you push them on the first time

#

And then when the initial thread gets preempted

#

It pushes things into the empty stack

#

So it just kinda works

#

it saves things on the current stack. swaps stacks. then returns

#

When you first setup scheduling

#

And enable it

#

The thing that gets preempted

#

Gets saved first

#

So it’s a bit funky but it works out for me

#

You can control that more specialy by making a dummy thread to get populated when it switches from it

narrow storm
#

Or it returns into the dummy things you put into the stack

hushed spire
narrow storm
#

anything can call the scheudle function

#

not just an interupt

#

thread A -> calls task switch
the return value is pushed onto the stack
the asm pushes a bunch of things onto the stack
it swaps stacks
restores off of thread B's stack
Returns

#

thread B would have had the return value on its stack from when it called task switch

#

or if you had just made it

#

it wiuld have the things you pushed

#

for return to pop from

#

and jump to

hushed spire
#

okay, so what happens if I had just made thread A and thread B for the first time, and then tried to switch to one of them? confusedshiki

narrow storm
#

how i have it here is not the best for SMP as shouldSchedule should be CPU local but

#

the idle thrread

#

thats the first thread the schedular will try and use

#

the kmain function then gets assigned

#

to that bit

#

because it does a save state

#

so the stuff you allocated and pushed to it dosnt matter

#

it just gets reused into the idle loop

#

in the rewrite id make it more intentinal but

#

it just sorta plays out fine

#

though it caused me confusion

#

and some issues now knowing it did that

#

@hushed spire because the task switch function says. okay im gonna save the currently running codes state on this stack. swap stacks. and then restore as if i had saved state before

hushed spire
#

hmmm, okay Imma just guess I wrote schedule() wrong or something then zerotwoshrug

narrow storm
#

when you make a thread. you push things onto the stack so it can "restore" state when its the first time running

#

so you can do it blindly

hushed spire
#
void ke::schedule() {
    if (queue.empty()) {
        ke::log(__FILE__, "Can't schedule anything, sadge =(\r\n");
    }
    else {
        LL_NODE<THREAD_CONTROL_BLOCK> *oldThread = currentThread;
        currentThread = currentThread->next;
        contextSwitch(&oldThread->data, &currentThread->data);
    }
}
narrow storm
#

and context switch?

#

you prolly want a bit more than that tho

hushed spire
#
contextSwitch:
    mov rsp, [rdx+128]

    ; Save current context
    push r15
    push r14
    push r13
    push r12
    push r11
    push r10
    push r9
    push r8
    push rbp
    push rsi
    push rdi
    push rdx
    push rcx
    push rbx
    push rax

    mov [rdx+128], rsp
    mov rsp, [rcx+128]

    pop rax
    pop rbx
    pop rcx
    pop rdx
    pop rdi
    pop rsi
    pop rbp
    pop r8
    pop r9
    pop r10
    pop r11
    pop r12
    pop r13
    pop r14
    pop r15

    ret
``` I don't think I have to push *every* gp registers, but not sure if that matters for correctness
narrow storm
#

it would be alot easier if you did a

    uint64_t* old_rsp = &previous_thread->krsp;
    uint64_t  new_rsp = next_thread->krsp;
    thread_switch(&scheduler_spinlock, lock1r, old_rsp, new_rsp);

then its just

thread_switch:
    ; push crap
    ; swap stacks
    mov [rdx], rsp
    mov rsp, rcx
    ; unlock schedular when its safe and enable preemption if lock does so
    call spinlock_unlock_nil
    ; pop same crap
    ret
#

it puts the RSP into the thread strcuture

#

then it just needs to load the new one

#

doing it like this also lets the C/++ code do more of the work

#

for the compiler to do its job and optmise

hushed spire
#

fair

narrow storm
#

also makes it harder toi fuck up

#

if you do need magic offsets in ASM make sure to annotate them and add static asserts in the high level defintions too

#

so if you change things

#

you get reminded to fix the assemblt

#

else you will have bad things happen™

hushed spire
#

speaking of which I need to write assert() meme

narrow storm
#

thats part of the C standard btw

#

atleast for static assert

hushed spire
#

well I did kind of have to do a hack to get it to work, but poggers

#

now I'm cleaning my code up before doing anything else pepekek

hushed spire
#

ig maybe I should have a main kernel thread?

narrow storm
#

not really

#

I don’t use one

#

I spawn the other threads

#

And then they call into kernel code where needed

#

Either via syscalls or if it’s a kernel thread just by calling it

#

You don’t need a “game loop”

#

You just spawn a thread for that sub system

#

Like for an NVME driver that may need to wake up and do work when it gets an interrupt

#

And some drivers are simple enough to just in on an interrupt context without its own thread for its own things

#

(Serial PS/2 somtimes)

hushed spire
#

How would I get the ball rolling then? GuraThink because trying to preform a context switch when there's no context to save it doesn't really like that 😅

#

Anyhow, I'll clean the codebase up some and then probably get started on FRED support if I haven't decided I've coded enough for one day thinkong

narrow storm
#

FRED is god

#

FRED is the savior

lunar vortex
hushed spire
narrow storm
lunar vortex
#

no

#

it would just load the register state

narrow storm
#

huh

#

a context switch without the other half?

lunar vortex
#

yes

narrow storm
#

when would you want that?

lunar vortex
#

you might

#

for example, my CPUs load into their idle thread

hushed spire
#

was playing kirby :p

#

now I'll actually clean up the codebase some

#

anyone who has the time to take a looksie through the codebase and suggest improvments would be appreciated :3

hushed spire
#

I'm awake :3

hushed spire
#

The agenda for today will probably mainly be FRED

#

I'll also probably work on vmen some more if I have the time

#

Oh, I also think my PFNDB is mapping more pages than it's actually using, so I should fix that.

hushed spire
narrow storm
#

@hushed spire

#

So how’s that FRED going

hushed spire
#

but when I get back... FRED TIME!!! letsgo

narrow storm
#

Yoooooo

#

Remember if you need help

#

Press the triangle key on your keyboard for help

hushed spire
#

I'll read the FRED spec in the car trl

narrow storm
#

56 pages or so yeah

narrow storm
#

All kernels must FRED

#

(Let’s lay off a bit tho lmfaooo)

hushed spire
#
FRED event delivery is always to ring 0 and ERETU returns only to ring 3, it is not 
possible to enter ring 1 or ring 2 while FRED transitions are enabled.``` Lmao, even Intel knows rings 1 and 2 are useless ![pepekek](https://cdn.discordapp.com/emojis/1255025354276470846.webp?size=128 "pepekek")
narrow storm
#

Whaaaaat nooooo

#

Honestly they would be less useless if they had more protection things you can apply :x

#

But no they can still access all ram

#

And they barely lock anything off

hushed spire
#

heck is a shadow stack? confusedshiki

narrow storm
#

its seperate and hidden

#

all call and ret functions also push there

#

and it verifies that and the normal stack match

hushed spire
narrow storm
#

Return-oriented programming (ROP) is a computer security exploit technique that allows an attacker to execute code in the presence of security defenses such as executable-space protection and code signing.
In this technique, an attacker gains control of the call stack to hijack program control flow and then executes carefully chosen machine inst...

hushed spire
#

Ah

hushed spire
#

@narrow storm where were those QEMU patches again?

narrow storm
#

You will never find them

#

You must use SIMICS

hushed spire
narrow storm
#

#resources message

#

@hushed spire have fun

hushed spire
#

lets see here...

#

ah wait

At least 16 GB of RAM
#

I might want my beefier laptop

narrow storm
#

Yeah it by default dedicated 8gb to the VM

#

lol

#

Also I hope that laptop has an Intel CPU

hushed spire
#

both my latitude and MSI have an intel yes lol

narrow storm
#

Then you should install thier custom kernel module

#

Which makes it less slow

hushed spire
#

ah, okie

narrow storm
#

Me on AMD

#

(It’s 3 times slower than TCG)

narrow storm
hushed spire
narrow storm
#

Now how much do you hate SIMICS

hushed spire
#

I mean it actually wasn't that bad zerotwoshrug

narrow storm
#

It’s mostly the docs that are annoying tbf

#

Oh also you know what I picked for my bootstrap allocator?

#

Lazy free list

#

And tracking how much I’ve allocated into it

#

So then later when I do the later stage PMM

#

I can know what memory to not use from the mem map (as it’s bootstrap stuff)

#

And I can reclaim what’s left on the freelist after going through the memory map

hushed spire
#

oh cool, I just use a bump allocator tbh pain

narrow storm
#

Mines basically that but it supports free so you can use it as primary if desired. Since you shouldn’t be freeing on bootstrap stuff it’s “the same”

#

But it also handles cross memory map regions etc

hushed spire
#

I really got to clean up my code pepepray I'm sure there's a bunch of small stuff I haven't implemented pepekek

narrow storm
#

We’ll get ready for FREZ

#

FRED

#

Do you wana do it in a hacky way

#

Or a non hacky way

#

Since the interrupt frames differ on the stack

hushed spire
#

non hacky way preferably. I think I do things in a hacky way enough as is lmao

narrow storm
#

You may wana use some magic 🪄

#

Which is chopping up the frame

#

Refer to how I did it because it’s nice

#

But basically I split the vector the registers saved and the frame pushed by the CPU

#

And then I pass the arguments through assembly for the IDT seperatly

#

Then in FRED it goes to C code which does the decoding and then sends it off with pointers to the right parts

#
    push r12
    push r13
    push r14
    push r15

    mov rdi, rsp         ; irq_saved_regs_t ; also same as lea rdi, [rsp + 0]
    lea rsi, [rsp + 128] ; irq_cpu_frame_t
    mov rdx, [rsp + 120] ; uint64_t vector

    cld
    sti
    call dispatch_interrupt
    cli

    pop r15
    pop r14
    pop r13
#

For example this for IDT

#

Which id rework first to use this system

#

And to edit your C side structures where possible

#

void dispatch_interrupt(irq_saved_regs_t* regs, irq_cpu_frame_t* frame, uint64_t vector)

hushed spire
#

okie :3

narrow storm
#

Afaik this is the best way for performance and keeping it sane on both sides so

#

Nobody has corrected me

#

(Please correct me and show me benchmarks or proof)

hushed spire
#

fixed my cpuid function :3

narrow storm
#

You need to make sure the leaf and subleaf

serene lake
#

simics isnt that slow on my AMD pc

#

not fast, but bearable for testing

#

wouldn't want to do rendering on it

hushed spire
#

fair

#

imma head to bed

#

more fred in da morning

serene lake
#

better bed than fred

hushed spire
#

I have awoken

#

After I finish with my school stuff I might work on this some more :3

narrow storm
serene lake
#

ok not a lot

narrow storm
#

whats your CPU?

serene lake
#

maybe 15fps? but that is gif streaming and gzip decompression

narrow storm
#

also my bad apple demo runs in CPL3 and uses SSE and other things. and its RLE compressON

#

so context switch overhead etc

#

esp for the mass of syscalls it spams for audio

serene lake
#

its not fully utilising it

#

bear in mind, its running on an interpterer, too

narrow storm
#

Maybe on windows they use hyperv instead of a custom driver

serene lake
#

if they did, fred wouldn't work?

narrow storm
#

They can still decide to trap and emulate some stuff ig?

#

Idk how hyperv works

serene lake
#

badly lol

#

I don't think it's hyperv, qemu runs under hyperv for me and that's blazingly fast

#

but a pain to get working at all

serene lake
narrow storm
#

Nope

#

But I didn’t try and enable it

#

I only do PC speaker

serene lake
#

ah yeah that will cause syscall spam

#

you're sending each note

narrow storm
#

and checking for the time etc

hushed spire
#

I'm finished with my school stuff, gonna give my other projects some love first tho :3

hushed spire
#

okie dokie

#

time for more fred ^w^

#

I uh, need to figure out what I'm actually doing next tho lol

narrow storm
#

You can always ask

hushed spire
#

okie, what should I do next evalyn KEKW

narrow storm
#

FRED

hushed spire
#

oh wait

narrow storm
#

After that

#

I need a list of your current doings

hushed spire
#

I might need rdmsr and wrmsr functions KEKW

narrow storm
#

Steal mine

#

Not like il break your knees

hushed spire
narrow storm
#

Ahh

hushed spire
#

although I will take suggestions lol

narrow storm
#

Well first you want to tweak the IDT path to be more normalized

#

Like how I have it

#

So it can work with FRED easier

hushed spire
#

normalized? confusedshiki

narrow storm
#

Since you want them to both end up calling the same dispatch function

hushed spire
#

ah

#

fair

narrow storm
#

But are similar enough

#

So you can get away with splitting it up into 3 things

#

The things you push. The vector and what the CPU pushes

hushed spire
#

okie dokie :3

hushed spire
#

So a FRED stack frame would look something like this right? GuraThink

narrow storm
narrow storm
#

My new kernel is actually a good reference for FRED this time too (well it will be perfect once I get userspace up soonish)

hushed spire
#

how come you clear the direction flag here btw?

    cld
    sti
    call dispatch_interrupt
    cli

narrow storm
#

It’s required by the systemv ABI

#

And things can be really bad if they aren’t compared to most other flags

hushed spire
#

ah

narrow storm
#

Eg making string operations run in the wrong direction

hushed spire
#

okay I think the interrupt dispatch code should be good now ^w^

#

Kind of late now so I think I'll start on actually implementing fred tomorrow

hushed spire
#

...the class? confusedshiki

narrow storm
#

This channel

#

It’s a saying

#

I wana see lol

hushed spire
#

ohhhhh

#

sorry I'm tired lol

narrow storm
#

Real

#

It’s almost 1am

hushed spire
#

I mean it's pretty much the same as yours except for some minor naming differences zerotwoshrug

keInterruptDispatch:
    push r15
    push r14
    push r13
    push r12
    push r11
    push r10
    push r9
    push r8
    push rsi
    push rdi
    push rbp
    push rdx
    push rcx
    push rbx
    push rax

    mov rcx, rsp
    lea rdx, [rsp + 128]
    mov r8, [rsp + 120]

    cld
    sti
    call keInterruptHandler
    cli

    pop rax
    pop rbx
    pop rcx
    pop rdx
    pop rbp
    pop rdi
    pop rsi
    pop r8
    pop r9
    pop r10
    pop r11
    pop r12
    pop r13
    pop r14
    pop r15

    add rsp, 16
    iretq
narrow storm
#

So if you ever change it it causes a compile time error

#

(Because then the assembly will break if you don’t fix it)

hushed spire
#

ah no, lemme do that :p

narrow storm
#

patpat

#

Static asserts are very nice for stuff esp for things that may be compiler/platform specific

#

(And ofc ASM interop)

hushed spire
#

aight, there we go :3

narrow storm
#

Now go to sleep

hushed spire
#

i'm up :3

#

fredrick time letsgo

narrow storm
#

@hushed spire what’s your plan for rdmsr and cpuid abstractions?

#

(You need both)

hushed spire
narrow storm
#

Well rdmsr and cpuid is arch specific

#

But you want to abstract it to make it not annoying to use

hushed spire
#

ah, uhm

#

I just kind of wrote wrapper functions

narrow storm
#

tis what i do. instead of seperate functions for it all

#

then its a cpuid_check(CPUID_HAS_FRED) etc

hushed spire
#

ah, yeah mine is slightly less abstracted lmao

narrow storm
#

may i see?

hushed spire
#
namespace hal {
    namespace x64 {
        static inline CPUID_REGISTERS getCpuid(uint64_t rax, uint64_t rcx) {
            CPUID_REGISTERS cpuidRegs{};

            __asm__ volatile (
                "cpuid" :
                "=a"(cpuidRegs.rax),
                "=b"(cpuidRegs.rbx),
                "=c"(cpuidRegs.rcx),
                "=d"(cpuidRegs.rdx) :
                "a"(rax),
                "c"(rcx)
            );
            return cpuidRegs;
        }
    }
}
``` I also need to add a check for whether or not CPUID is actually supported :p
narrow storm
#

All x86-64 CPUs have it

hushed spire
#

I mean I would think I don't really need a check in that case GuraThink

narrow storm
narrow storm
#

CPUID is on late 486s and all 586s

#

So like

#

Your fine lol

#

CPUID can also tell you your inside a virtual machine and what kind it is

#

And the CPU name and vendor

hushed spire
#

coolio sigmapepe

lunar vortex
lunar vortex
narrow storm
lunar vortex
#
pub const CpuFeatures = struct {
    x2apic: bool,
    five_level_paging: bool,
    gib_pages: bool,
    tsc_deadline: bool,
    fxsave: bool,
    xsave: bool,
    invariant_tsc: bool,
    nx: bool,
    pcid: bool,
    smap: bool,
    smep: bool,
    pge: bool,
    vendor: CpuVendor,
    family: u8,
    brand_string: [48]u8,
};
#

I fill this

hushed spire
#

I was thinking of doing something like that thinkong

void elm
#

Same, I just pre parse all features I care about into bitmaps

hushed spire
#

@narrow storm what's up with the OR with 3 here? confusedshiki

uint64_t star = ((uint64_t)(0x18 | 3) << 48) | ((uint64_t)0x08 << 32);
narrow storm
#

That sets it as a ring3 selector

#

As this is related to the GDT

hushed spire
#

ah

narrow storm
#

The bottom 2 bits of the segment selector/register set the CPL

#

And if that’s incorrect there

#

Your kernel uhhhh

#

And have fun tracking it down to that

#

And it also depends on your CPU brand if it will or won’t do that too

hushed spire
#

oh how come I can't use an or here? :p

"bts $32, %%rax\n"
#

actually wait I may have just made a typo lol

#

but anyhow

#

@narrow storm poggers

narrow storm
#

You may want a bit more boot logs lol

hushed spire
#

I'm sure the code isn't perfect and I'll have to tweak it some, but it works! party

hushed spire
narrow storm
#

Ah

#

I like big logs scrolling on my screen lol

#

But fair

#

Does your serial driver work on real hardware?

visual walrus
#

never checked XD

hushed spire
#

I have no way of testing it at the moment I'm afraid 😔

narrow storm
#

(Next time I go and use it want me to test yours too)

narrow storm
#

Also @hushed spire you may wana trigger a page fault for testing this

#

As you get a non zero error and vector

#

Also use format spesifiers to make your printfs look consistent

hushed spire
narrow storm
#

Sick :3

hushed spire
#

So, now that I've done that side-quest, I think I'll go back to finishing up my vmem implementation (for the time being), then move on to writing the Slab allocator, and then after that... working on the Object Manager maybe? GuraThink

hushed spire
#

aight, pretty sure my vmem implementation is complete enough that I can start on the slab allocator :3

#

Think I may just axe object caching and only cache object size for now GuraThink

fading talon
#

ho sorry by my fault this passed on 4950

lunar vortex
#

insane

hushed spire
hushed spire
lunar vortex
lunar vortex
hushed spire
fading talon
hushed spire
#

fair lol

fading talon
lunar vortex
#

well

#

there's a lot of stuff

fading talon
hushed spire
lunar vortex
#

also there seems to be NT larp but the code style is inconsistent

hushed spire
#

I did this all manually 💀 so yeah there's bound to be some screw-ups in places lol

lunar vortex
#

idk why youd larp the code style tho

#

it's like the worst part of the thing

hushed spire
hushed spire
#

procrastinated a tad bit sigmapepe

#

I'll work on slab for a lil bit before heading to bed

hushed spire
#

I presume the slab can allocate from itself for the bufctls for large slabs

#

also interestingly

#
of all its slabs. The slab list is partially sorted, in
that the empty slabs (all buffers allocated) come
first, followed by the partial slabs (some buffers
allocated, some free), and finally the complete slabs
(all buffers free, refcnt == 0).``` It seems my old slab impl used three seperate freelist instead of one partially sorted one
#

surely having three separate lists would be better though no? GuraThink

hushed spire
#

honestly I think imma just clean this up some first

hushed spire
#

wasn't really in an osdevving mood yesterday

#

I'll try to get some work done today tho :3

#

Now if only I had enough braincells to figure out what to fix kongoudisgust

hushed spire
#

I don't really know where to start so.... cleaning up my page frame allocator it is I suppose?

#

I should also make it SMP-friendly

#

Surely just using a spinlock should be good enough for this shoddy kernel trl

#

I also have 0 clue how to benchmark any of this stuff :p

hushed spire
#

gosh fricking dang it

#

here I am wondering "hmmm, why isn't this booting on real hw"

#

I haven't updated Limine on my machine 😭