#pmOS - microkernel OS for RISC-V, x86, and LoongArch
1 messages · Page 12 of 1
Nah, it's not that bad
And I can just use UEFI
Also, I don't normally use kvm anyway
Also 
Actually, no, it's about the same speed/ a bit slower
What did you change?
Bruh, how do I suddenly have so many ideas for async receive?
I think I can just do it with a ring buffer, between the kernel and userspace
Ok, I've kinda implemented it in kernel already, on RISC-V for now (to the point where the kernel compiles)
And I think both the userspace api and the implemention is quite clean
Also, this allows to share interrupts between drivers now...
(After I get it to work on risc-v, I'll do it elsewhere, since the toolchain takes several hours to compile on my laptop)
The interrupt signaling/IPC and EOI paths are now allocation free, and almost lock free (the locks are only taken to push stuff into the IPC queue)
Cool, this stuff basically almost fully worked the first time
9k/s 
You need a riac-v leaderboard 
Yeah, this looks like a scheduler skill issue
just tell people to use tcg on x86
Idk, I get a higher score in uACPI
Like 10x
I can't check because I don't have disk space on my laptop
qemu also uses tcg when running riscv
ok, what the fuck is going on with my kernel
All CPUs have ID 0 
Ok, after fixing this stupidity, this is fully working on risc-v...
(at least ahci and ns16550 drivers worked with no issues...)
Ok, I'm nuking risc-v build and building x86...
This is my i686 build in qemu with TCG, for example
And on RISC-V it was using SBI's timer, and on x86 it's using HPET
Is this why I couldn't use copilot and had to debug my shit myself? 
Also, this stuff also works on x86 (i686, I'll just trust that amd64 isn't broken
) now, with the same arch-independent impl
What the fuck are those offsets?
This is way pre-AI for it to confuse hex and decimal
This is fun
lmao
Just gonna leave this here, since everything else is broken
on loongarch
Oh no, my kernel is broken for some reason on loongarch64
and it panics before initializing the framebuffer
Ok, it was a dumb thing, that clanker found for me (but then started writing some insane code)
what's the point of inline without static?
multiple definitions of the same function?
ok, qemu is hammering all cores, which is a good sign
(address should have been ulong instead of u32)
static exists in c++
But inline means a different thing in C++
afaik
inline in c++ means "it's fine to have multiple definitions of this, and the linker will merge them together" more or less
(and having differing definitions is ub)
Does this stuff need to be aligned to something weird, or something like that???
no...
What the fuck
I wanna kms (figuratively)
The clanker was gaslighting me
(1 << 31) is 0xffffffff80000000
Because numbers are int in C(++)
did it tell you how awesome and smart you are in the process
I can't believe it, this shit works
No
Tbh every time I use AI I wish I didn't
you're kinda using it wrong tbh
How am I supposed to use it?
like u expect too much of it
what should I expect?
did you just tell it to debug your code?
Kinda
which model?
gpt 5.4 mini
ok lol
if u want it to do complex stuff like that u need the best one with a huge context window
at the very least
mini is complete shit for anything
It started hallucinating when it saw loongarch, then it tried to copy linux, and failed miserably at it, then it had found it once I basically did all of the debugging myself and pointed its nose at the problem
lol
Like sure, "you're giving it -1", then "0xffffffff comes from virtual addresses", then after I told it I was sure it was fine, it started reviewing my printf...
this is nice
this is gdb btw
though tbh I should probably update my gcc/binutils toolchain
omg, this shit is getting somewhere
But it's reading 0 out of mailbox 1 
why
something in qemu is clearing the mailboxes for some reason.......
are you sure it's qemu?
what else would it be?
maybe edk2, who knows
I mean, it shouldn't be https://github.com/qemu/qemu/blob/master/hw/loongarch/boot.c#L38
Official QEMU mirror. Please see https://www.qemu.org/contribute/ for how to submit changes to QEMU. Pull Requests are disabled. Please only use release tarballs from the QEMU website. - qemu/qemu
But I've looked at it in gdb, and it looked like different code was running
Ok, this build is saner and had actually booted https://github.com/osdev0/edk2-ovmf-nightly
Nightly images of EDK2 OVMF firmware for QEMU. Contribute to osdev0/edk2-ovmf-nightly development by creating an account on GitHub.
But it still clears the mailboxes
Ok, I've no idea who and why is doing that, but it looks like (from qemu traces) it passes the mailbox 3 into $a1, and the interrupt vector into $a0 ?
Unbelievable
(tbh, I need an IPI to stop other CPUs on panic...)
This is a very good sign?
(I mean it gets stuck...)

Cool, this stuff is basically fully working
What I'm missing is multiple interrupt controllers support
(because loongarch is fun, and you basically get a per-cpu lapic, where all of the vectors are shared, and then each cpu gets its own controller)
All I have now is one
Whats it used for?
SMP on loongarch
that particular screenshot is uACPI doing better on loongarch than on risc-v
No I mean the ged
Power button
Ah
Idk, I forgot I even implemented it, but somehow it didn't bitrot and survived a lot of changes and just worked
But like I ported to loongarch because risc-v didn't have ged for some reason...
and I didn't want to deal with arm
(I still don't want to deal with arm)
Ok, I think I can proclaim SMP to be officially fully working on my loongarch64 port
934/s 
i should add C++ exceptions to uacpi
Huh?
(
)
Ok, missing PCI is very concerning
It finds PNP0A03 but then nothing happends?
Yep, just nothing happends
@twilit talon ?
ok, clanker fixed it
what was the issue
It wasn't finding root bridges
Because loongarch doesn't publish them in south bridge
yeah find_devices_at doesnt return any error if nothing was found, u kind of know it wasnt if your callback wasnt invoked
managarm doesnt even support loongarch
But this might be a general issue, if I took this code from them
Or idk, idr why it'd write it like that
(like where this came from)
whats the issue part?
u mean in acpi?
Just \\PCI0
so weird
Does this violate any spec?
Like the second screenshot is how it discovered it
Yep, a bunch of other stuff is in _SB_, this is just \PCI0
the spec is toilet paper
is this qemu or real hw?
Qemu
Yeah, I probably stole this from Managarm https://github.com/managarm/managarm/blob/master/kernel/thor/system/pci/pci_acpi.cpp#L249
i think Managarm is correct here and qemu is wrong 
Yeah, I should just stop supporting qemu 
you could patch qemu
or send a patch upstream
it's probably because loongarch is rather obscure and essentially unused outside of china
would they care if linux probably doesn't?
did you test if linux works
linux might just do root relative search
No 
I mean their AP init code is also broken, but there's no spec and I couldn't find where in the sources
I think it just does for each from root and registers every device
but how can you do that if you need PCI for everything else?
it does but there are places where it checks for explicit names
so stuff may not work correctly if it's not below _SB
Yeah maybe
Cool, my SATA driver seems to be doing better with the latest changes to it...
But the MacBook is still trolling
how
I suspect the IPC layout is different between C and Rust
Yeah, it's saying 4096 physical and 512 logical for some reason, which makes no sense
how does that not make sense

physical is what is actually stored, logical is the smallest adressable unit
I'm dumb and that check is just wrong
LBA units are logical
Yeah
I'll ask clanker to fix 
nah
Cool, it didn't find ext4 partitions, because there were none on this MacBook
But like it read the disk and everything
cool
(also, how do I still get fascinated seeing my kernel boot on actual PCs and like not shit itself)
(Except the smp init on x86
)
I think I'll finally fix it, then push to main
Wait, do I not need to send INIT to APs?
Alternatively, following a power-up or RESET, since all APs are already in the “wait-for-SIPI state,” the BSP can broadcast just
a single SIPI IPI to the APs to wake them up and initialize them.
SDM says this
Can you not do this??
The SDM says it's read/write
The TPR (shown in Figure 13-18) is cleared to 0 on reset. In 64-bit mode, software can read and write the TPR
using an alternate interface, MOV CR8 instruction. The new task-priority class is established when the MOV CR8
instruction completes execution. Software does not need to force serialization after loading the TPR using MOV
CR8.
Ok, my cool new timer function is trolling
Oh no
Well, now I know my double fault handler is broken 
oh no, now it just tripple faults...
actually, it's gpfing in the gpf handler...
what the fuck
Smp init... FAIL
I'm having a skill issue adding a submodule to my git directory
What does it say
nothing
I think I've gotten it to add but idk
the files are there
I'm so done with this
why does it not work
how is it not finding it on my desktop while the same branch works perfectly on my laptop
did flanterm change its file structure again???
also, I think my keyboard is dying as well

All I want is to see kernel logs
also wtf 27 argument function
what is a struct anyway
that's flanterm for you
(what are you using in your kernel?)
(i just have a pl011 driver lol, pl011 is arm uart)
Unfortunately, that MacBook doesn't have UART, I'm afraid
Anyway, it just freezes when I try starting the APs 
Also, how does this macbook have smep but not smap?
should have gotten a newer mac
m1+ all have uart
i mean maybe this has uart as sell through the typical apple weirdness
it has firewire and thinderbolt though 
yep, this locks up after sending sipi
epic face reveal XD
This is better
Did you fix the bug
Me when no abortable instructions
actually, only in x2apic mode
because I'm dumb and was reading from the wrong register...
nevermind
Linux does this https://elixir.bootlin.com/linux/v7.0.1/source/arch/x86/kernel/smpboot.c#L851 ...
wait, what
init init startup?
could my error lvt just be broken or something?
Maybe I just shouldn't do parallel startup?
bruh?
wait a second...
I'm so dumb
Ofc it crashes in QEMU if I give 16GB of RAM
there is actually a funny way to do this without a silly lock carousel (i think youd still need to make an array of all of the capabilities though so it doesnt really let you remove the limit) but
you can make a global array of N locks where N is a number that feels right
Oh no
and then an objects lock is some_hash(object_addr) % N
and then you make a local N-entry bitmap which tells you which locks you need to lock
im doing this kind of really funny global lock hashtable for another thing in my kernel
Even more deadlock potential, how nice
nono this is actually deadlock-free
because with a bitmap you always acquire it in one order
If everything uses this
well obviously you only acquire one set of locks at a time
It's not nice on numa as well
You can make this per nuna cluster though
mm true
im just gonna target apple which is numa-free
and by "numa-free" i mean they stripe cache lines between numa nodes in hardware so that you dont have to care
How do they do it on M* Max stuff?
i think only ultra has meaningful numa?
but anyway yeah the cache lines are striped between numa nodes lol
Whichever one has 2 CPUs glued together
yeah
im doing this stupid lock sharding meme for a different thing in my kernel though
my async ops have a pointer to the queue that they belong to, but they cant hold a refcount to it because reasons
and this lets you acquire a lock by virtual address without actually requiring the target to be valid
I just use rcu
yeah but for that id have to actually implement rcu
and its also not something with a nice quiescent period
tbh my rcu needs some improvements as well
also this is much funnier anyway
lol yeah
It's almost done...
Cool...
I think this works both with limine and hyper...
(also, I've improved my x86 paging code in general...)
though this is unfun...
I think it's trying to enable 5 level paging, when it shouldn't be?
(pushed this stuff to main yesterday)
Also, I asked the clanker to check my paging code, and it had found a lot of embarrassing bugs in x86_64 paging stuff
And while I was in the mood for fixing paging, I've also finally implemented memory types (and their deduction from memory map for uACPI and whatnot) for physical memory mapping syscall
Which can maybe speed up the framebuffer?
though qemu kvm feels slower for some reason
the macbook does feel faster though
idk
Oh no, I think my smp init code is now broken on i686 
This is very dumb
Like lol why boot when you can just idle
it could have crashed, it could have deadlocked, but no, it just had enough and decided to idle()
(thankfully, this was an easy fix)
this stuff is refusing to work 
this is fun


this is trolling though
I'm declaring this a skill issue of the buildbot 
huh
actually, maybe it's a jinx's skill issue....
yeah, dry run doesn't expand the variables
(It would be great if I could choose which recipes to build, for each arch)
@left dew ?
?
i didn't make jinx
but you are right
i already brought it up to mint at some point
@vale hinge
Oh, sorry
Ok, I'm doing the filesystem
I need to figure out the namecache though
This is fun...
Ok, I think I'll merge VFS and process/posix together
because I think this stuff is too closely coupled
So I think I'll rewrite that from Rust to C++ before it's too late...
Yes
I'm writing VFS, and it's trolling me (and it crashed the kernel...)
Address misaligned...
How am I having a skill issue writing circular list stuff??
just dont use a circular list
for the list
like for the list itself? or for the list hook
for the list
for the list itself you are swapping one or two pointers idk its not hard
and in rust i cant really make them work properly anyway
also why swap
personally i would just SK_NO_COPY(CircularDoubleList); SK_NO_MOVE(CircularDoubleList); ngl but like its your code
#define SK_NO_COPY(T) T(const T&) = delete; T& operator=(const T&) = delete;
#define SK_NO_MOVE(T) T(T&&) = delete; T& operator=(const T&&) = delete;
I have no copy, but I think move is nice
ehh
I mean I didn't have them, and it destroyed my code with the default constructors
moving an intrusive ds like this CAN work butttt
wdym
I didn't delete the copy constructor, and I was accidentally copying the list map.emplace
no
they are very handy
especially because you basically always want to delete copy constructors tbh
Sometimes it's fine
Like for small structs
I mean most of the times
Like bit fields for paging 
I think I'm getting somewhere...
Ok, since I have the filesystem, I think the next steps would be
- Implementing timer rights
- Making send() optionally block (and then implementing async send as well?)
- Implementing pagers
- Mlibc and other posix stuff till I get bash?
So my plan for the timers is to have them be per-CPU, and then if the timer object is not on the right core, to IPI the other one to get its attention
I've gotten this to work on x86
(Like timer rights)
I nedd to implement this on risc-v and loongarch64 as well, but I'll do that later (since I can't test it on my laptop)
And I also need to get rid of the old syscall
btw @carmine nacelle does your pci daemon support pcie or just pci?
both
I mean pci is kinda broken at the moment because of some bs in my early pci init code
This is trolling
lol
(So, to continue the discussion in https://discord.com/channels/440442961147199490/1217009725711847465) I think, I'll allocate 2 pages of IO bitmap per process (when it requests it). Then, I'll map those into the per-CPU TSS, so they are naturally shared (with the shared memory)
and how do you exchange them?
exchange what?
huh?
like, if they are shared for whole per cpu tss, then every process / thread will have them, no?
No, the TSS will have 4 virtual page frames allocated for it (with the first one having the per-CPU data, the last one for the trailing byte). Then I will be swapping the middle two pages in the page tables, without changing the TSS itself
oh the phys pages
yeah...
yeah that could work tbh
Nevermind, fred is anoying, because of how my idle works...
Omg, my brain hurts, FRED is so inconsiderate
or maybe nevermind
lol its pretty easy actually
No
I've been using CS to know what was preempted by interrupts
I guess I should be abusing this
whats sti (stb)
sti instruction
but sti enables interrupts
basically, if interrupts were disabled, it means it's an unwarranted exception
I'm pretty sure it's interrupts
ah yeah its the thing they use for NMIs
isn't it only for smi though?
no, i mean
No, I need to switch stack if the exception/interrupt is coming from my idle, and stay on the same stack if it's from the kernel
because I treat my kernel threads as userspace threads
but if I check rflags, it'll break my SMP init code
don't ask why
Idk how to do this
Like I see the vision that you're just supposed to push everything onto stack, do your stuff, and return, without having to care about all of the special cases
But idk, I can't wrap my head around it
If I don't give my idle a separate stack, it will be eating kernel's stack as well...
Though I had an easy solution for this in risc-v
But I'd like not to branch if it's possible...
"nested level"
why is your idle special? Can’t you just treat it like a kernel thread too
Idk, I just feel depressed now
It has a separate stack
kernel threads don‘t?
I have one stack per CPU and not per thread
So I switch to a special idle stack when I enter it
oh ok
My x86_64 code is a very big mess and it just feels very bad
And then the one stack per CPU was a deliberate decision and kind off a differentiating factor, but I feel like I have to fight with hardware design of everything any time I change anything in the kernel...
Maybe it's time to get rid of it
(one stack per CPU)
But then the issue is that the whole kernel was written assuming it, so I'd probably need to redo a lot of locking stuff, implement proper mutex, etc.
And then it's gonna be implications on top of implications on top of implications
And like at the same time I already feel that I'm pouring too much time into something that's a hobby for me to be making any sort of "big" changes like this right now
Namely, I don't know how I'm gonna handle NMIs because of this stack switching nonsense
But also I wouldn't bother with fred until I can get my hands on hardware that actually has it
Which won't happen any time soon
(I mean I came up with the solution while writing this, which is a software interrupt if the kernel was preempted without installing a preemption point)
Zen 6 should have it, you can just buy a new CPU when it comes out
According to some news I read today while researching this
(sorry for the rant to anyone reading this lol)
This doesn't depend on whether I use FRED or not...
Yeah 2026 hardware has it
Including new Intel laptops
But I cant justify buying a 1k laptop for fred lmfao
Yeah
But you can probably upgrade your CPU and sell your old one
But yeah
You need a new motherboard for that
Didn't you have 9950X?
Probably
IIRC yes
They've been releasing new AM4 CPUs for like 8 or 9 years?
There's no new memory standard
So like they may pull Intel, but I'd expect them to release a couple more generations on AM5 before switching to a new platform
I think zen7 would be on AM6
Arround then is when ddr6 is getting up?
tbh this is salvageable for FRED
the frames are near identical to what the IDT stuff pushes so yes
they just add a bit extra
AMD has confirmed it will use AM5
Btw, do syscall/sysenter use the normal return address with FRED, or is it still some %r11 or whatever weirdness?
they do not fucke with rcx and r11
And it looks at the return type and returns from rcx/r11 instead?
Idk if I'm dumb, but I can't get it to detect FRED in qemu??
I've given it the +fred flag
do you have the vibe coded qemu patches?
no
otherwise QEMU TCG will not support it
and you need intel SIMICS

#resources message
Maybe because its not supported by qemu lmao
Simic's trolling
nope thats the firmware
$cpu_comp_class = "x86-experimental-fred
$iso_image="\\\\wsl.localhost\\Ubuntu\\home\\misha\\pmos\\build-x86_64\\pmos.iso"
run-script ./targets/qsp-x86/qsp-dvd-boot.simics
run

I wonder how angry SIMICS is at the WSL path
Also that stuff was only tested in Linux™
Iirc @marble steeple got it working on windows
lol never seen anyone use a wsl patth
nah it worked perfectly for me on windows
What packages did you install?
all of them
There's no gui
there is gui lol
what are u doing
but yeah simics is the worst least intuitive piece of software i have seen maybe ever
nothing happens?
When I'm in a wearing out my SSD as quickly as possible competition but my opponent is mishakov
lol
where do I get them?
simics is also refusing to work on my pc
Let me find them
If discord on my pc won’t crash
#1431140025805832343 message
@carmine nacelle
This seems to work?
I can toss you my ISO if you wana test to make sure it built right etc
Yeah but the patches are still well dubious
(my kernel I mean)
So testing would be good 
simics is trolling
idk what I'm doing wrong, but there's no gui
This is cool
(I think I've gotten it because it tried to iretq
but also it's 3:30 am so I'm going to sleep
(I've also implemented guard pages for the stacks...)
Also, somehow it seems to get to userspace without crashing with 8KB stacks...
how did you even manage it to run iretq 😭
yeah I did, I asked gpt how to do it, but I also installed the full package and it's package manager thing and let it just install everything it wanted, didn't try to point it at existing stuff on my system like python
why the offset comments
can't you just use offsetof with inline asm 
Because I haven't implemented it
You haven't seen my assembly...
I've gotten to the timer interrupt??
homeless stack traces are funny
yes
well u need a symbolicator since it seems u do unwind it
but it's a simple rip/rbp thing
not the proper dwarf2 one which unwinds through nullptr %rips
Like here
dwarf cant unwind through a nullptr, at least not the eh_frame unwind
i had to add special code for that
Bruh, I think GPT 5.5 has managed to get SIMICS to work?
Though there's still no GUI
Also, I think HPET wasn't the firmware...
it has managed to get GUI working as well...
Like there's no difference between kvm and tcg with fred
btw i can test in simics later if you need to make sure its not just the vibe coded qemu
I've managed to get it working, but it doesn't like my HPET code
so I can't really test fred
.
This is fun
Yeah, it seems to be fully working
And LASS !!
Now I just need shadow stacks 
If you wanna try it lol
yes but your line control is off 
Can you scroll up to right after the kernel loads to see if it's using it?
This is userspace ns16550
Cool
I think I'm gonna finish getting rid of the old usersapce timers API, implement proper IO ports rights, and push this to main
After which I think I'll leave this stuff for a bit, since I have exams in a few weeks
Btw when are you actually going to port shit
After I do proper mutex and port mlibc
Can you run something like bash now?
No
I mean I probably have enough kernel/usersapce stuff to do it if I implement enough stuff in libc
Also, I'd need an input subsystem for bash
(though I have ns16550)
I need to implement proper serial console with interrupts as well so I can use my kernel remotely over amt
But thats for later
My driver is fully interrupt driven for both input and output
U need interrupts for output?
You don't "need" them
for some serial yes
If you poll it
Because serial is very slow
Ah does it generate an irq when the output is empty or smth
Yes
What I do is I fill the queue, and wait for the interrupt to write it
you can get up to easily 1M+ baud
The isa com x86 has cant go that high lol
I think my kernel writes a 9600, and it takes like 5 seconds to boot just because of how slow it is
Lmao why
Can it not handle 115k
It can
I mean I had issues with it where the characters weren't arriving
But it think it was a Linux skill issue on the other side
Also serial has busy bits or however it's called, which lets you block the other side from sending if your buffer is full
But I haven't bothered with it
Looks like 115k baud is approximately 1 char each microsecond
So not really worth interrupts
CTS/RTS
Maybe I need to find contributors
Clanker had found gold in my PCI interrupt routing code...
And the funny thing is that everything dies if I fix it
Cool, new hardware discovered...
Bruh, I've looked at netbs and it's very easy
I basically already have something that's almost like that
yes
Just park/unpark and they fix the race with unpark setting a flag...
And userspace handles spurious wakeups
I don't really get the pointer hints though
But it looks like they don't even use it?
what are the netbsd park APIs?
lwp_park/lwp_unpark
smh just do block_on(future)
I think it comes from Sun
Huh
Managarm's kernel-internal primitive is also park / unpark
but this is only used to implement block_on(future) (also kernel-internal)
and block_on(future) is used to implement everything else (including futexes)
So it's basically the same thing?
Bruh, I'm having a giant skill issue with i8042 again...
Which is this
The i8042 is 2 ACPI devices...
but this is so anoying to deal with...
Do I just special case it like managarm?
Wait a second, ia64 has i8042??
Also, this is next level trolling from the kernel ("-ENOMEM")
I now have proper i8042 interrupts discovered from ACPI, maybe I can do shell 
I've no idea
That's what ACPI gave me for the keyboard PNP id
It's at LPC_ in simics
Lpc makes sense
what's lpc?
I mean sf8 probably does as well but idk what that object is
Yeah
My keyboard driver is also fully working again
The more I use my timers API the more I like it
Do I finally port mlibc?
do it 
My kernel doesn't meet the first requirement 
Why the hell is that even a prereq
sys_libc_log
I mean I kinda have all of this already...
https://github.com/managarm/mlibc/blob/master/sysdeps/demo/sysdeps.cpp
Portable C standard library. Contribute to managarm/mlibc development by creating an account on GitHub.
But I need to figure out how to bring the stuff I do in userspace in
Can't u stub it?
I mean yeah but if you have to stub a required sysdep I don't think it really counts as porting mlibc
I have it in userspace
But it's a bunch of IPC
Cool...
Can limine switch to a different git thing again? 
At least Github's ssh thing still works
Where do I put my kernel API?
Like should I split my libc into two libraries, or just reimplement everything from scratch in mlibc?
up to you
one thing that probably doesn't work terribly well is linking against a shared library
unless it's a VDSO
because ld.so will need some calls before it has processed all DSOs
I mean static library should be fine?
I also need to decide what to do with my signal thread
Because at the moment, my libc initializes itself, and then does pthread_create for the thread that actually calls main()
wait a second, is frigg header only?
the wonders of c++
Because then it's very easy to integrate
Btw @twilit talon is it normal that Hyper doesn't enable NX when booted with BIOS by default?
Yeah it doesn't use any memory protection at all
It doesn't enable WP in cr0 either
Enabled nx under UEFI is probably leftovers from edk2
Ok
I'm asking because limine seems to be enabling everything
(but like it's ok that it doesn't, my kernel was just triple faulting yesterday, and I found out that that was because I was assuming this to be done by the bootloader)
ah
i remap my kernel myself anyway
so these mappings arent really relevant for me
I do too, but I forgot to enable NX in EFER
skill issue 
And as usual, only in the x86_64 port 
Like idk why, but even though it's what I normally run, it has the biggest skill issue with everything
how do u even not have common paths for such features for both modes ☠️
I do
that has NX too tho
ah i see u just duplicated the cpu stuff also
Most of it is also common
the way i do it is a common setup_cpu() detects all features and sets a bit in supported_pt_mask
But stuff like gdt/IDT is different
nx is set unconditionally in pt_prot but cleared if its not supported by the mask
I check it in ultra_main
☠️
And now that I think of it, I don't enable it when booted with limine???
u support both protocols at the same time right
limine (the bootloader) probably always enables it, but idk if protocol gurantees it
Yeah
In the same binary
i might do that as well but too lazy
limine doesnt have a kernel binary memory type etc
its gonna be a bit annoying
Limine also does
yeah but im making my own direct map lol
It has a feature that gives you the kernel address
yeah but i will need to make a synthetic e820 entry and carve it out somewhere, which may be in the middle of kernel-and-modules or even crossing multiple of them
I've been planning to add it as an optimization though
I do create a synthetic e820 that's common for 2 protocols for my pmm init though
Yeah, I know
yeah id have to do that too
It's not that difficult
yes
But like my kernel doesn't need a separate kernel memmap entry, as long as it's in some kind of used region
Though multiboot2 is annoying because it doesn't do that
i wouldnt use multiboot2 without a huge prekernel
I wanted to implement it with an asm trampoline
I mean I had a prekernel before, but I've gotten rid of it...
Like it shouldn't be too bad, I just need to filter e820, and initialize paging
I need to figure out how to include a static library with a static library...
I think I'm losing motivation again
Do I call for contributors? 
ive still got a few even without the tag 
even more general helpers for stuff
You should throw on the tag though if you want
But you will still get them without it
But idk I'm worried about it since atm basically all of the code is mine (except the external libraries, etc.)
Just do code reviews and add a clang format etc
If you don’t like the code point stuff out etc
And talk to people when they are working on things etc
It helps a lot
I've updated the post
Ok, I said I was gonna leave pmOS for some time, but I'm suddenly in a mood to add mb2 support 
How am I having this skill issue?
check_exception old: 0xffffffff new 0xd
748: v=0d e=03f8 i=0 cpl=0 IP=0018:000000000000000f pc=000000000000000f SP=0020:0000000000064f5c env->regs[R_EAX]=00000000e85250d6
EAX=e85250d6 EBX=0000234a ECX=00071000 EDX=000003f0
ESI=00000004 EDI=00000001 EBP=00000000 ESP=00064f5c
EIP=0000000f EFL=00000003 [------C] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
CS =0018 00000000 ffffffff 00cf9b00 DPL=0 CS32 [-RA]
SS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
DS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
FS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
LDT=0000 00000000 00000000 00008200 DPL=0 LDT
TR =0038 00000000 00000000 00008900 DPL=0 TSS32-avl
GDT= 1fe75000 00000047
IDT= 00000000 000003ff
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=000000d6 CCD=ffffff32 CCO=SUBB
EFER=0000000000000000
check_exception old: 0xd new 0xd
749: v=08 e=0000 i=0 cpl=0 IP=0018:000000000000000f pc=000000000000000f SP=0020:0000000000064f5c env->regs[R_EAX]=00000000e85250d6
EAX=e85250d6 EBX=0000234a ECX=00071000 EDX=000003f0
ESI=00000004 EDI=00000001 EBP=00000000 ESP=00064f5c
EIP=0000000f EFL=00000003 [------C] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
CS =0018 00000000 ffffffff 00cf9b00 DPL=0 CS32 [-RA]
SS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
DS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
FS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0020 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
LDT=0000 00000000 00000000 00008200 DPL=0 LDT
TR =0038 00000000 00000000 00008900 DPL=0 TSS32-avl
GDT= 1fe75000 00000047
IDT= 00000000 000003ff
CR0=00000011 CR2=00000000 CR3=00000000 CR4=00000000
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=000000d6 CCD=ffffff32 CCO=SUBB
EFER=0000000000000000
check_exception old: 0x8 new 0xd
This is protected mode without paging
Looks like you're executing code at 0
No, thats the first exception
yeah
I'm dumb
Or no
Nevermind
time for bochs 
gdb refuses to work in protected mode for some reason
Nevermind, I fixed it lol
Why am I having such a hard time writing x86 assembly?
Having so little registers is unbearable
Ok, this stuff is almost working
I've gotten to the higher half, but it seems like my (self
) elf loader is broken
Or paging
Cool, this casual assembly insanity has gotten to higher half/C++
(Also, I've learned that gnu toolchain exposes symbols, which let you get pheaders for yourself without requesting it from the bootloader)
what were you doing?
Adding multiboot2 support 
Which ended up being 1k+ lines of assembly just to get to C++?
wtf
I'm not doing a prekernel
sounds totally maintainable
Also, the plan it to support all three protocols with the same binary
(I mean, it's kinda working, but Limine and Ultra have stopped booting, likely after my linker scritp changes)
even w/o a prekernel, it shouldn't take 1k lines to get from asm to C
also, from this progress thread I get the impression that you often have a ton of regressions
. maybe you should invest a bit of time to set up better automated testing
I mean it's a bit of an exaggeration probably, I have a bunch of comments and empty lines
But there are like 1.2k lines of text
Actually, no, I was right
Jinx is broken 
what does this code do? i'd probably just let it set up some initial pts and jump to C
It does that
Id KMS if I had to write so much at&t assembly
No, it's generic + x86_64 specific
oh
I don't have i686 trampoline yet
well
it does a lot more than that
why not just embed enough space for a few PTs in the BSS
It also prints to screen
yeah which is completely unnecessary
you know what its missing? a builtin kernel shell
Because it's not a prekernel, and I want to reclain that memory
do u have something like a free-after-init section?
No...
😭
I was thinking about it, but didn't bother with it yet
It feels like it's more trouble than what it's worth
(In terms of memory consumption)
i think it's mostly a waste of effort but yeah a free-after-init (or just re-using the PTs) is probably way simpler than this
too late now
I can larp it once I have bash 
(Also, I had bzt's shell thing in my kernel in the past 💀)
this seems incredibly overcomplicated and hard to maintain
you don't need output, dynamic allocation, any of that
just allocate a few page tables in .bss, map the lower 4G using 2M mappings, map the kernel image using __executable_start and _end without respecting phdr permissions, and call C
that's like 100 instructions at most
the C code can figure out the rest
Cool, it was broken because of a "broken" linker script, and now those two work, and multiboot can also remap itself
The obnoxious part now is filtering the memory map...
limine is trolling 
While the same exact binary does boot with limine protocol
I need to check grub...
Lol
Lol limine's trolling again 
Meanwhile multiboot2:
Multiboot e820:
0 - A0000 type 1
100000 - 800000 type 1
800000 - 808000 type 4
808000 - 80B000 type 1
80B000 - 80C000 type 4
80C000 - 811000 type 1
811000 - 900000 type 4
900000 - 1EAEC000 type 1
1EAEC000 - 1EC00000 type 2
1EC00000 - 1F8ED000 type 1
1F8ED000 - 1F9ED000 type 2
1F9ED000 - 1FAED000 type 2
1FAED000 - 1FB6D000 type 2
1FB6D000 - 1FB7F000 type 3
1FB7F000 - 1FBFF000 type 4
1FBFF000 - 1FEC1000 type 1
1FEC1000 - 1FEC5000 type 2
1FEC5000 - 1FEC7000 type 4
1FEC7000 - 1FEF4000 type 1
1FEF4000 - 1FF78000 type 2
1FF78000 - 20000000 type 4
E0000000 - F0000000 type 2
FD00000000 - 10000000000 type 2
Or maybe not?

Wtf am I supposed to do with LIMINE_MEMMAP_RESERVED_MAPPED ???
It's passed as reserved by multiboot2 and RAM by limine protocol...
This is trolling
Omg, why did they have to make multiboot2 so obnoxious?
yeah I have no idea why they decided to pass a copy instead of a pointer
what
do they mean RSDT?
How am I supposed to use the palettes with flanterm??
My kernel fully boots with mb2 now, but I'm missing the framebuffer
you don't
you pretty much need to assert that framebuffer_type == 1
bruh, even if you request modules to be page aligned, grub can allocate multiboot2 struct wherever it wants
Why...
and so it will intersect
Now I'm only missing bash to larp a kernel shell 
(Also, how do I send it as a video?)
You likely need to convert it to a mp4.
Cool, my i686 binary can also boot with multiboot2 now

Who said you can't use limine for ia32 
A small change 
I'm done with exams and stuff so maybe not dead os 
But I kinda don't have motivation for this either
W
i mean, pretty accurate
I think the time has come to implement lwp_park and unpark
Which means I have to implement thread/task rights
And I also need to move processes and signals to the kernel since what I have now is a mess
Or I don't even know what to do at this point
Though managarm also has thread groups?
I'm so lost
Managarm implements pthreads/processes/thread groups in userspace
the kernel has a concept of threads but no concept of processes
the kernel also doesn't have a concept of signals
My kernel is the same
Now do you deliver signals?
I've briefly looked at the code but didn't really get to it
The problem I had with this is tracking processes, and making sure there are no threads left hanging after the process dies, and so on...
signals are delivered by interrupting a thread, reading its register state, writing its register state to its stack, loading a new register state and resuming the thread
that's done by posix-subsystem
I have a signal thread for it... But doesn't it make all of the signal stuff IPC and thus very slow?
