#Nyaux

1 messages ยท Page 15 of 1

surreal path
#

but with rust

#

can i do the same

#

or not

finite summit
#

you can

#

it's because you're taking the address of a symbol you set in the ld script

surreal path
#

i need both the kernel base and kernel bytes

#

which i will get

#

okay so limine gives me the base

#

which is a virtual address

#

and a physical address?

#

idfk

#

my old code is hard to read

#

not hard

#

okay i see

#

to do

#

then i map the hhdm

#

maybe first i should make a map function

#

okay i see a magic number here

#

im guessing this is to get the index to the next page table or page entry or whatever

#

right?

#

im guessing yea

#

okay i did something similar

#

i need to allocate a table

surreal path
#

what the hellllll

thorn bramble
#

pointer needs to be aligned

#

this isn't C

surreal path
#

wha

thorn bramble
#

what?

#

im sorry

#

what do you not understand?

#

i can try and help

surreal path
#

im confused, what needs to be aligned

thorn bramble
#

the pointer

#

you are dereferencing

#

any code you just added

#

audit it

#

you can read unaligned memory with some functions in core::ptr

surreal path
#

i do .offset

thorn bramble
#

okay, that will be aligned

#

assuming original pointer is aligned

#

and the type is correct

surreal path
#

its literarly a raw ptr to a u64

thorn bramble
#

do you know what code causes that

surreal path
#

im unsure

thorn bramble
#

then start commenting out code

#

or adding prints

#

see where it dies

#

literally binary search

#

start putting prints everywhere

#

once you stop seeing new prints go back and add prints inside the functions

#

until you narrow it down to that one pointer dereference

surreal path
#

for some reaosn

#

reason*

kind root
#

least cursed rust code

thorn bramble
#

true

#

start printing pointers

#

find out which pointer is unaligned

#

it really shouldn't be lol

surreal path
#

okay

thorn bramble
#

i would help if i could but im playing with friends rn so meme

#

cant really build your kernel and do it myself rn

frigid cliff
#

You wrote it wrong/hj

thorn bramble
#

he does not know how to write rust (yet)

#

give him a break

frigid cliff
#

I know lol

surreal path
#

lime im so confused

#

like*

frigid cliff
#

the way I would write it would be something like this (assuming it's setup similarly to this)

#

but in your original implementation, you did not need the (**q) because you were derferencing a reference and then dereferencing the pointer, but rust would do the first dereference for you because it's a reference and references are safe to use, so it would only be necessary to write (*q)

#

well I'm not 100% sure how your implementation works so leaving None in q.next's place might be wrong, but I think I have some near identical code to what I wrote above in a linked list in my OS somewhere

#

also the way that you write rust in Allman style nooo

surreal path
#

Isnโ€™t box used for allocating things on the heap

#

Also

#

This still doesnโ€™t explain why my kernel poops itself trying to map everything nooo

ionic jetty
#

give it a diaper

surreal path
#

bro ๐Ÿ˜ญ

surreal path
#

I just wannna understand

#

what the fuck is going on

median goblet
#

Like

void f()
{

#

instead of
void f() {

surreal path
#

BEST WAY TO CODE ๐Ÿ˜Ž๐Ÿ˜Ž

#

FIGHT ME

#

๐Ÿ˜ก

median goblet
#

I like it too

surreal path
#

W

#

what the fuck is going on

#

panics getting the memory map????

#

i didnt switch to the page table so what

#

what the fuck

#

commenting this out causes a triple fault

#

lovely

#

im STILL

#

not switching

#

to this page table

#

so like wtf

#

okay maybe its cause im blindly copying code from old nyaux without caring

#

ill just

#

make new code then whatever tf

#

so rust can stop being a meanie towards me

#

this better be worth it writing in rust

#

for all the "safety" features

#

do these addresses look aligned chat

#

they look aligned

edgy pilot
#

yes they do

surreal path
#

so what the fuck

#

wheres my all done over here print messages

#

what the fuck is going on

#

ummmm like

#

erm what the sigma

#

commenting out the map function

#

fixes the issue sooo

#

most be the map function right?

#

no???

edgy pilot
#

uuuuuuumm
I don't know rust but from the error message maybe try using usize instead of isize

surreal path
#

offset does not like usize

#

.offset

#

only takes in

#

isize for some fucking reason

#

help any big rust devs

#

what the fuck is going on

#

im dying

edgy pilot
#

do you have the code on github

surreal path
#

i will publish right now

surreal path
edgy pilot
#

unfortunately I won't be available at least for a few hours

#

so I can't take a look yet

surreal path
#

okay thats perfectly fine

#

glad your even gonna take a look for me ๐Ÿ˜ญ

#

my eyes alone cannot figure out the root cause of this issue, everything seems to be aligned

#

my guess is probs the rust compiler doing something i dont know thats weird

molten grotto
surreal path
#

making a slice

#

๐Ÿ˜ญ

#

and how am i supposed to fix that

#

.offset only takes isize

molten grotto
#

there is .add but it still can't be larger than isize max

#

Ill take a look at the code

surreal path
#

okay

molten grotto
#

its inside limine rs when it tries to create the memory map entry slice but idk why is the count so large and I am not home rn so I can't really do any further debugging

surreal path
#

so not my fault

molten grotto
#

eh it most likely is because its your kernel that contains the request where it gets the count from

surreal path
#

what?

molten grotto
#

the count it uses is from the mmap response limine gives and I don't think its an issue with limine rs (and certainly not limine itself)

#

anyway you can take a look at the request and the response in gdb and see if they look sensible (well most likely the response doesn't because of the garbage count)

surreal path
#

im not

#

modifying it

#

at all

#

like look at my pmm.rs code all i do is setup the pmm freelist with the memory map

#

its not even mutable

#

and it was only used once here

molten grotto
surreal path
molten grotto
#

I am not sure either

surreal path
#

I think i will

molten grotto
#

I still don't think its an issue with it

#

I can try to take a look when I get home in like 20min

surreal path
#

okay

#

also why is it any kernel i write is cursed

#

๐Ÿ˜ญ

molten grotto
#

lol

green elbow
#

every kernel is cursed

surreal path
#

based

green elbow
#

just wait until you get race conditions or stack corruption

#

thats where the real fun starts

surreal path
#

very fun sounds like

#

Totally did not experience stack corruption before when handling interrupts memedown

green elbow
#

good shit

surreal path
#

with old nyaux

haughty kite
#

but rust!

green elbow
#

character development

surreal path
#

yes

haughty kite
#

its safe!

surreal path
haughty kite
#

no race conditions are possible!!!

surreal path
#

indeed !!!!!

haughty kite
#

well i mean except the ones that are

#

lol

green elbow
#

unsafe has entered the chat

haughty kite
#

yeah

#

unsafe impl<T> Send for T {}

green elbow
#

rusts memory model is not ready for page tables being mangled

surreal path
#

Iโ€™m only doing it in rust for the build system tbh

#

crates are pretty nice to have

green elbow
#

cringe

#

meson is nice to have

haughty kite
#

lmfao

#

meson

#

nice

surreal path
#

rahhhh

green elbow
#

meson my beloved

haughty kite
#

this is like why nobody likes c

#

and c++

green elbow
#

this is why nobody likes you

#

yeah

#

that's right

haughty kite
#

meson is bad

#

its just bad

green elbow
#

no u

surreal path
#

I like C and c++ kinda but honestly build system is a mess

haughty kite
#

no functions?

green elbow
#

no fuck functions

#

leads to complexity

#

meson is the perfect mix between functional and declarative

#

why tf should you have functions

surreal path
#

one thing I like about rust is being able to have inheritance like c++ but not like c++

green elbow
#

lmao

#

I mean it's not inheritance

surreal path
#

itโ€™s new to me cause I come from pure C so

molten grotto
#

traits are nice yeah

surreal path
#

yea

haughty kite
#

idk man theres a reason literally all other build systems have those

#

and meson is just

#

not good for anything except what the authors decided you want

#

which sucks

green elbow
#

wtf are you doing that it required that much logic

surreal path
#

anyways you guys should move this to #programming this is kinda hogging nyaux chat lol

surreal path
haughty kite
#

with a bunch of settings that are shared

#

thats like literally enough to want to have functions

#

or how about idk like

#

symbol postprocessing?

green elbow
#

and can already be done easily in meson no need for functions for that

haughty kite
green elbow
haughty kite
#

in which case you have to do ugly hacks

#

also

#

compiling bytecode

#

or just partial compiling in general

#

e.g. compile half the codebase -> do some analysis -> compile the rest

#

v8 does that with torque

#

they first build the torque compiler, compile all the torque code, build turbofan and torque generated code, run it, embed the results into the final binary

green elbow
haughty kite
#

(because it forces a contradictory one)

green elbow
#

mlibc literally includes compiler search paths as part of its build system how much more do you need

haughty kite
#

etcetcetc

green elbow
haughty kite
#

and meson can and does pass some automatically with no way to disable it

#

other than MITM on the compiler invocation

#

like idk i would want a build system that like

#

lets me build how I want to build

#

not how the build system wants me to

molten grotto
surreal path
#

okay great!

unkempt relic
#

they even provide you with functions

haughty kite
#

so

#

i might try zig's build system, it's apparantly pretty capable?

surreal path
molten grotto
#

yes you are somehow zeroing the memory where the response is

surreal path
#

wtf

#

????

molten grotto
#

and there was at least one bug in the pmm but that didn't fix it, you were doing for e in 0..=page_amount when it should be exclusive (or else you are going to be writing one page past the free region)

surreal path
#

Oh right

#

but still wtf

molten grotto
#

doc for write_bytes:

Invokes memset on the specified pointer, setting count * size_of::<T>() bytes of memory starting at self to val.
and you are doing that on an u64, I bet this is the bug that's causing it to get zeroed

surreal path
#

Right so I should treat it as a pointer

#

when I write bytes

molten grotto
#

you need to divide the count by 8 because you are using an u64

surreal path
#

oh okay

#

4096 / 8

#

thank you for helping me with this qwinci as usual your very smart

molten grotto
#

also I'd make the pmm return usize or a wrapper struct instead of a pointer that you can't even access without first adding the hhdm offset

#

and then there is likely a lot of ub because you are dereferencing random memory addresses as a pointer without first writing anything to there (there is a .write method on pointers that can be used to create a new object in there)

surreal path
#

i did that for every pointer i use

#

memsetting it before ANYTHING

#

at all

#

anyways i need to map the HHDM

#

how do i do that again

#

i forgot

#

not epic smart 1000iq

#

so i need to go over the memory map

#

okay easy

#
pub fn new_inital()
    {
        let mut q = PageMap {
            head: None,
            rootpagetable: unsafe {PMM.alloc().unwrap()} as *mut u64,
        };
        unsafe {q.rootpagetable.write_bytes(0, 4096 / 8)};
        let size_pages = unsafe {&THE_REAL as *const _ as usize} / 4096;
ADDR.get_response().unwrap().physical_base(), ADDR.get_response().unwrap().virtual_base());
        for i in 0..=size_pages
        {
            // println!("mapping virt {:#x} to phys {:#x}", ADDR.get_response().unwrap().virtual_base() + (i * 4096) as u64, ADDR.get_response().unwrap().physical_base() + (i * 4096) as u64);
            q.map(
                ADDR.get_response().unwrap().virtual_base() + (i * 4096) as u64, 
                ADDR.get_response().unwrap().physical_base() + (i * 4096) as u64, 
                VMMFlags::KTPRESENT.bits() | VMMFlags::KTWRITEALLOWED.bits()).unwrap();
            
        }
        println!("mapped the kernel i supposeeee");
        println!("um");
        let entries = MEMMAP.get_response().unwrap().entries();
        let mut hhdm_pages = 0;
        
        for i in entries.iter()
        {
            match i.entry_type
            {
                EntryType::ACPI_NVS | EntryType::ACPI_RECLAIMABLE
                | EntryType::USABLE | EntryType::BOOTLOADER_RECLAIMABLE
                | EntryType::FRAMEBUFFER | EntryType::KERNEL_AND_MODULES =>
                {
                    let page_amount = align_up(i.length as usize, 4096) / 4096;
                    for e in 0..page_amount
                    {
                        q.map(
                            HDDM_OFFSET.get_response().unwrap().offset() + (e * 4096),
                            (e * 4096),
                            VMMFlags::KTPRESENT.bits() | VMMFlags::KTWRITEALLOWED.bits()
                        ).unwrap()
                    }
                }
            }
        }
    }

okay i think thats everything

#

switching to page map causing fault ๐ŸšŸ

#

๐Ÿ˜”

#

not epic

#

i mapped everything in the hhdm

#

it should

#

work :c

molten grotto
#

did you map the framebuffer (starting at the base in the fb response)

surreal path
#

entry type of framebuffer should map it?

molten grotto
#

its not in the hhdm tho

#

the address in the fb response

surreal path
#

oh what address do i map that to

molten grotto
#

or actually it is my bad

surreal path
#
q.map(
                            HDDM_OFFSET.get_response().unwrap().offset() + (e * 4096) as u64,
                            i.base + (e * 4096) as u64,
                            VMMFlags::KTPRESENT.bits() | VMMFlags::KTWRITEALLOWED.bits()
                        ).unwrap()

also fixed the function to where it uses i.base

#

still

#

faults sadly

molten grotto
#

whats the cr2

surreal path
#

sec

#

cr3 is

#

CR2=000000007ff57000

molten grotto
#

looks like you are trying to use something with its physical address

surreal path
#

i only call this function

#

which puts the address into cr3

#

of the root page table

molten grotto
#

and what do you do after that

surreal path
#

i know cr3 expects a PHYSICAL address

#

allocate something

#

just messing with the PMM

#

and using flanterm

#

i cannot debug the rip cause rust mangles symbols

#

i wish to disable that but i dont think i can globally disable that

#

RIP=ffffffff800108ad

#

rip is somewhere sane tho

molten grotto
surreal path
#

its happening in memset

molten grotto
#

with gdb you could get the backtrace

surreal path
#

most be happening in flanterm i suspecttttt

#

okay sec

#

here

#

it happens when something writes something with memset

#

i cannot debug it as its one function

#

thats called MANY times

#

it faults

#

i cannot

#

FIND THe damn

#

bug

#

๐Ÿ˜ญ

#

doesnt matter if i switch to the pagemap or not

wicked loom
surreal path
#

ask rust themselves

wicked loom
#

i am not sure rust provides that in a freestanding program?

surreal path
#

it does

molten grotto
#

it does

wicked loom
#

damn

#

that's weird

surreal path
#

it provides a lot of stuff for freestanding programs

#

which is nice to haves

molten grotto
#

also its not a problem with the memset, its a problem of using a physical address to access memory

surreal path
#

yep

#

happening somewhere in the loop

#
for i in entries.iter()
        {
            match i.entry_type
            {
                EntryType::ACPI_NVS | EntryType::ACPI_RECLAIMABLE
                | EntryType::USABLE | EntryType::BOOTLOADER_RECLAIMABLE
                | EntryType::FRAMEBUFFER | EntryType::KERNEL_AND_MODULES =>
                {
                    let page_amount = super::phys::align_up(i.length as usize, 4096) / 4096;
                    for e in 0..page_amount
                    {
                        q.map(
                            HDDM_OFFSET.get_response().unwrap().offset() + (e * 4096) as u64,
                            i.base + (e * 4096) as u64,
                            VMMFlags::KTPRESENT.bits() | VMMFlags::KTWRITEALLOWED.bits()
                        ).unwrap()
                    }
                }
                _ => {

                }
            }
        }

somewhere here

#

WAIT

molten grotto
#

just do -no-reboot -no-shutdown and then run it in gdb and you get the exact point where it faults

surreal path
#

changed it to this now

#

still doesnt solve it tho

#

๐Ÿ˜”

molten grotto
#

well that was the other bug

surreal path
#

yep

#

Still tho

cinder plinth
#

rust sucks!! It doesn't keep track of Page tables for you!!

surreal path
#

lol

molten grotto
surreal path
#

OH MY GOD

#

IM THE BIGGEST

#

FUCKING IDIOT

#

Iโ€™m not home but I need to test the code

#

is there a way I can

#

Work on my os on my phone memedown

molten grotto
#

I mean termux would probably work but it might suck

surreal path
#

I donโ€™t have termux cause this is an iphone

#

not an android sadly

wicked loom
#

running a jinx build in termux

#

phone catches on fire

surreal path
#

I wish I had something like termux but I have an iphone ๐Ÿ˜”

surreal path
#

Soon enough

molten grotto
wicked loom
#

yeah tbh phones nowadays are more than capable

molten grotto
#

and it only took a few hours

wicked loom
#

fuckers are literally almost more powerful than most PCs

molten grotto
#

also have more ram than eg. chromebooks or whatever

surreal path
#

can I at least edit my code and GitHub push it

#

Or something

#

Is there an app for that

wicked loom
#

github app :^)

surreal path
#

My family forcing me to go with them to the water park I just wanna osdev

#

oh yeah sec

#

downloading GitHub now

#

guys I think we will have user mode within week trust

#

10000%

#

world record speed run

#

If I donโ€™t fuck it up with my depression

wicked loom
#

you can always osdev when you're back home

surreal path
#

no :^)

#

Okay I fixed the code

#

Qwinci can you test it if you can Iโ€™m not home

frigid cliff
surreal path
#

NYAUX HAS VMM WORKING

#

!!!!

#

LESS GOOo

finite summit
#

LESGOoooooooooooooooooooooooooo

surreal path
#

LESGOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

finite summit
#

WWWWWWWW

surreal path
#

WELL MORE OF PAGE TABLE MANAGER, I STILL NEED TO READD THE WHOLE REGION SHIT BUT IMA DO THAT RIGHT NOW AND THEN WE DO WHATEVER IS NEXT UHHHHHH UACPI INTERGRATION MAYBE @kind root ?

finite summit
#

scheduler

surreal path
#

to which we need the lapic timer

#

to which we need to configure the apic

#

to which we need

#

uacpi

#

so uacpi is probs after

#

just lemme readd all my vmm region shi

finite summit
#

and you can still parse ACPI tables yourself

#

to this day obos hasn't used uACPI to get any tables

#

because the kernel only uses the MADT

#

and that code was written long before uacpi was intergrated

#

and it works so I couldn't be bothered with changing it

surreal path
#

wait wait wait

#

before anything

#

i dont have fucking slab allocation

#

shit

#

fuck shit pooper

#

okay lets do 2 things one at a time, slab allocation then the vmm region stuff

#

oh as well

#

i dont have an idt

#

๐Ÿ’€

#

or serial

finite summit
#

who needs serial :^)

surreal path
#

serial is easy

finite summit
#

my kernel didn't have it until 3-4 months after I started

surreal path
#

im not ur kernel coolmeme

finite summit
#

and it's only ever been used for my gdbstub

#

which is currently unused....

surreal path
#

im gonna use the same implementation of <4096 byte allocations as i have in my own kernel

#

as i am lazy

#

and we need to get to userspace FAST

finite summit
#

dam you do be speedrunning this

surreal path
#

fr fr any% speedrun

ionic jetty
#

best thread up to date

surreal path
#

guess whos getting there ๐Ÿ˜Ž

finite summit
kind root
#

at least its stable now ig

surreal path
#

nyaux will be far from stable most likely halfmemeleft

finite summit
elder shoal
#

Astral is pretty stable (until you increase the cpu count)

#

The cpu gets a new friend and becomes distracted and doesnt do stuff properly :(

finite summit
#

OBOS is stable with 4 cpus

#

any amount above is untested, but will get slower

#

even if the core amount is native

#

(I have a bunch of giant spinlocks because I only implemented mutexes 2-3 weeks ago)

ionic jetty
finite summit
#

nope, locks

#

probably also tlb shootdown

ionic jetty
finite summit
#

no idea

#

all I know is that there are ~82 spinlocks (based on find all) which are usually acquired at IRQL_DISPATCH

#

so a bunch of stuff in the kernel can't get preempted as much

#

causing other threads to get less execution time

ionic jetty
#

the problem isn't the AMOUNT of spinlocks but how much they're contended

finite summit
#

fair fair

#

idk, as I've never mesured

#

that

ionic jetty
#

make some cool statistics thing

#

when which lock is held for how long

finite summit
ionic jetty
#

the ever growing todo list nooo

finite summit
#

56 todos in the source

ionic jetty
#

amateur numbers

surreal path
#

me coding the slab allocator while yall talk

#

๐Ÿ˜Ž

ionic jetty
#

my life is 90% unfinished todos

ionic jetty
finite summit
#
if (Kdbg_Paused)
{
    asm("sti");
    // TODO: Fix 
    Arch_LAPICSendEOI();
    Kdbg_CallDebugExceptionHandler(frame, false);
    asm("cli");
    return;
}```
#

FIX WHAT

ionic jetty
#

my guess would be the eoi

#

you once asked about it

#

when to send it

#

you probably meant this

kind root
finite summit
#

(indirectly)

#
// TODO: Use a function that takes in a context.
OBOSS_GetPagePhysicalAddress((void*)curr->addr, &phys);```
#

for example that

#

userspace would be running in different "contexts"

#

and rn that function only supports getting the one for the current context

surreal path
#

its done

#

the slab allocator is done

#

time for vmm region shit

#

closer

kind root
#

is that your heap allocator?

surreal path
#

uhhh for pages bigger then 4096

#

yea

#

it maps a group of virtual addresses

#

to be contingious

#

and maps the apporite pages

#

and yea

#

once i get this done i will have working heap

kind root
#

yeah ucapi will destroy it

surreal path
#

not again ๐Ÿ˜ญ

#

nahh but i wouldnt be too worried

#

its the same implmentation from old nyaux

#

just written in rust this time

kind root
#

ah

surreal path
#

im doing that to save time cause im not fucking around with heap shangains for 12 hours again ๐Ÿ˜ญ ๐Ÿ™

kind root
#

someone should make a uHeap (not me because i suck at algorithm stuff)

surreal path
#

true

surreal path
#

NOT ME that is NOT fun

finite summit
#

also isn't that just liballoc

kind root
#

idk if liballoc is necessarily good

finite summit
surreal path
#

literarly me

finite summit
#

we need uAHCI

kind root
#

maybe after uGPU

#

wihhc is gonna take at least a few years

finite summit
#

I need to speedrun obos mesa port

thorn bramble
#

ahci is so simple i dont think you need a library for that

finite summit
kind root
#

lol

finite summit
#

just like I was the first with uACPI

thorn bramble
#

managarm was

#

:)

finite summit
#

nay

thorn bramble
#

no?

finite summit
#

it was my third kernel

kind root
#

oberrow integrated uacpi even before it had opregions implemented

finite summit
thorn bramble
#

damn lol

kind root
#

like before it was supposed to be integrated

finite summit
#

#1141057599584878645 message

surreal path
#

if yall wanna see nyaux development

#

im streaming in vc0

kind root
#

i didnt do it until way later

thorn bramble
#

that is both cool

#

and worrying at the same time

kind root
#

lol

finite summit
kind root
#

i barely even had helpers for anything at that point

#

it was like barebones interpreter

thorn bramble
#

would you say lil was better at that time?

finite summit
kind root
median goblet
#

Just wasn't needed

finite summit
#

yeah

edgy pilot
elder shoal
#

I just throw everything I need at 0xe9

#

If I end up writing a serial driver itll be to hook it up to the tty stuff

surreal path
# edgy pilot noice!

i am close just needing to figure out how to properly do the inline asm cause i suck at rust inline asm

#

any rust experts know how to get this to work

#

i fucking suck at inline asm

finite summit
#

basically what you do is:
ditch inline asm
make a new asm file
throw your asm in there

surreal path
#

vmm region works now

#

region allocation works

kind root
#

You speedrunning this shit again lmao

surreal path
#

yes lmao

#

i need an idt once i have an idt i will put in lovely uacpi

#

we all love uacpi

#

dont we

finite summit
edgy pilot
#

uacpi is love, uacpi is life

surreal path
#

real.

edgy pilot
#

uacpi and limine

surreal path
#

realreal.

#

mintsuki hear our prayers

magic kernel
#

Donโ€™t forget mlibc

surreal path
#

of course.

edgy pilot
#

yes

magic kernel
surreal path
#

mlibc our beloved.

magic kernel
#

Honestly the best side project Managarm made

edgy pilot
#

no operating system is complete without those three

finite summit
#

instead of limine

surreal path
#

i also just squashed a mosquito that had my blood in it

finite summit
#

you gave birth to a mosquito then killed it?

kind root
#

Drink it back then

magic kernel
#

Snort it

edgy pilot
kind root
#

Lol

#

Yeah thats a bannable offence

magic kernel
#

Rule 0: one shall use Limine, uACPI and mlibc

finite summit
kind root
edgy pilot
#

based

magic kernel
#

Yes

surreal path
#

oh shit

#

my laptop is about to run out of charge

#

NOOOOO BUT I WANTED TO WORK ON THE IDT AS WELL TODAY

#

FUCK

kind root
#

u dont have electricity?

surreal path
#

barely in the shitty hotel Iโ€™m at

surreal path
#

alright so as i remember with the IDT i need isrs

#

problem

#

i dont know how im gonna implment the same array of function pointers i did in nyaux in rust

#

im kinda screwed

#

before anything tho

#

lets get my allocator working with rust

ionic jetty
#

afaik these don't pair well so good luck

surreal path
surreal path
#

in rust?

molten grotto
#

well idk what exactly do you mean by that

#

but you can have an array of function pointers

surreal path
#

how does that look like

molten grotto
#
struct Whatever {
    arr: [extern "C" fn(a: i32, b: i32); 10]
}
haughty kite
#

also you gotta #[repr(C)] that struct

#

possibly

surreal path
#

do i have to do that with the interrupt frame struct as well?

#

for it to work well with assmebly

molten grotto
#

yes

haughty kite
#

yess

#

compile with RUSTFLAGS=-Zrandomize-layout

surreal path
haughty kite
#

it doesnt cause any ub

#

so

#

its always correct to use it

molten grotto
# haughty kite also you gotta #[repr(C)] that struct

well it depends on how you use it, if its not used in any asm then it doesn't matter (for an example how I do it in my kernel is that there is only one central irq handling function that the asm calls with the frame + number that then dispatches it further)

surreal path
#

that would be smarter

molten grotto
surreal path
#

to do

#

fuck you rust

finite summit
#

common rust L probably

haughty kite
#

also

#

jesus christ

#

have you heard of rustfmt

surreal path
#

whats rustfmt

haughty kite
#

its like the code formatter for rust

#

everyone uses it and its part of the toolchain etc

#

please for the love of god run it

#

also imagine static mut lol

surreal path
#

why not

haughty kite
#

and imagine using the alloc crate

surreal path
#

im not?

haughty kite
haughty kite
surreal path
#

from core?

haughty kite
#

ah

surreal path
#

implmenting it for rust?

haughty kite
#

still its L and cringe

finite summit
#

rust is cringe in general

#

C best language

surreal path
#

done now we have heap i think

finite summit
#

lesgo

#

there's no way you implement uACPI now

#

right?

surreal path
#

no not rn

#

i need an IDT

kind root
#

Or rather

surreal path
#

nah

kind root
#

Implement later

#

But yeah whatever

surreal path
#

but

haughty kite
#

for kernel stuff

elder shoal
#

The idt is one of the first things Id do

haughty kite
#

and like not regular userspace stuff in general

surreal path
haughty kite
surreal path
#

i think its fine

#

anyways

#

IDT time

finite summit
kind root
#

I dont like how its common for rust that u just shove 99999 crates into your project by default

#

Reminds me of js

haughty kite
#

yeah true

kind root
#

But ig im just not used to that mentality

haughty kite
#

but also heapless is just very useful

#

and like i COULD write my own on-stack vectors

#

but like

#

why

kind root
#

Depends if you want to do that or not

haughty kite
#

true

#

but its really not like the point of the project

#

so

kind root
#

Fair

surreal path
#

is there a way

#

to check

#

if an interrupt is an exception

#

instead of

#

having a billion asm stubs

haughty kite
#

its below 32?

#

lmao

finite summit
#

he probably means if it has an error code

molten grotto
#

just have a macro to generate the asm stub and then an if inside the macro that checks if the number is one of the few ones that push a code

kind root
#

Bro never heard of macros

surreal path
#

i dont know how it works with rust asm

#

the macro system

haughty kite
#

its just gnu asm

#

lol

surreal path
#

i dont write gnu asm

#

lol

haughty kite
#

or you can use normal rust at const???

kind root
#

U dont write them in rust

surreal path
#

i know

finite summit
#

use nasm

molten grotto
#

rust inline asm is fine, you just have to use gas directives with intel syntax (and you can have it in separate files using global_asm!(include_str!("myfile.asm"))

haughty kite
#

or again

surreal path
#

i dont know gas directives

haughty kite
#

use rust macros to construct your stubs

haughty kite
#

fucking

#

google

#

jesus christ

surreal path
#

okay i get it ๐Ÿ˜ญ

haughty kite
#

OR RUSTS FUCKING MACRO SYSTEM

#

OR THEIR COMPILE TIME EVALUATION SYSTEM ARGGHH

#

sorry

surreal path
#

chill ๐Ÿ˜ญ

kind root
#

Like if you're doing rust at least do shit in an idiomatic way

haughty kite
#

yeah

ionic jetty
#

yeah

haughty kite
#

or you know

#

which lets you run arbitrary rust at build time

finite summit
#

proposal: ditch rust, embrace C

kind root
#

Yup

finite summit
#

you wanted memory safety, we had a tool for that

#

it was called not having skill issue

#

(and also kasan)

#

((kasan has saved my ass on multiple occasions))

haughty kite
#

i dont think u should use rust for memory safety

#

its good for other reasons

surreal path
#

yea

#

thats why im using it

#

not cause of "memory safety"

#

thats called skill issue

haughty kite
#

because we all know thats bullshit

surreal path
#

yea

haughty kite
#

though the rust semantics are massively opaque

kind root
molten grotto
haughty kite
#

they are so much worse than c/c++

surreal path
kind root
#

Hes known to speedrun shit

surreal path
#

ill figure out getting nasm to link anyway with the binary

haughty kite
#

theres of course a nasm crate that does that for you btw

surreal path
#

real?

haughty kite
#

yes lmfao

surreal path
#

wtf

haughty kite
#

its rust

surreal path
#

yall never told me this

haughty kite
#

theres always a crate for everything

#

yeah because youre using rust so i assumed you knew you could copypaste a crate for it lol

kind root
#

Is there a kernel crate

haughty kite
kind root
#

Lmao

surreal path
#

bru ๐Ÿ˜ญ

kind root
#

Just import that

haughty kite
#

oh god

surreal path
#

ah yes

haughty kite
#

that crate is so skill issued

#

that group of rust osdev people are actually just

#

no

kind root
#

In a good way?

#

Oh

haughty kite
#

no in the worst way possible

kind root
#

Well their acpi crate fucking sucks so I expected as much

haughty kite
#

lol yes

#

x86_64 is very bad

finite summit
#

import kernel

kind root
#

Recursive and half of the opcodes are incomplete

haughty kite
#

its like maximally handholding

kind root
#

Almost cosmos framework

#

Or whatever its called

haughty kite
#

oh yeah its like cosmos

surreal path
#

lmao

haughty kite
#

basically

kind root
#

Lol

haughty kite
#

well its not that high level

#

but its quite close

#

they have come up with the stupidest abstraction ever

#

PhysAddr and VirtAddr

#

god

#

that shit is like cancer

#

its just bad

kind root
#

Lol

molten grotto
#

eh I don't think having wrappers for different address types is unreasonable

molten grotto
#

though ofc you could just use plain usize or whatever but I actually kinda like having a wrapper struct over it

haughty kite
#

you have a pointer type for pointers???

#

and a phys one is fine

#

but also like

#

userspace virt addrs are a thing too

haughty kite
molten grotto
#

for userspace ones it would be useful because then you can have all your safe load/store methods on it

haughty kite
#

yeah but then

#

its (a) contextually obvious what the userspace thingies are

#

(b) you cant add things to their types

#

(c) this is a thing that can easily leak to your whole kernel BUT its in an arch-specific crate!

molten grotto
#

yeah just make your own if you want that

haughty kite
#

you kinda always want that tho?

#

you never want THEIR one

#

oh and also

#

they obviously have a handholdy pagetable wrapper

molten grotto
haughty kite
#

so THEIR wrapper type is never useful

#

that kind of wrapper type COULD be useful tbf

molten grotto
#

yeah

surreal path
#

why no workie :c

#

i did exactly as it said

molten grotto
#

you didn't link it

#

unless it automatically links the library

haughty kite
surreal path
#

it doesnt help

flat nymph
#

What's with all the hate? (sorry for hijacking this thread) but I'm thinking of adding it to my OS (but may be it's a mistake so may be not)

flat nymph
kind root
flat nymph
#

Hmm

#

Perhaps

#

I'm talking about that limine bug

#

(also, how did I miss linuxmaster coming back a week ago?)

kind root
#

That was lapic id

#

Not address

flat nymph
#

The address is fine

#

Ok I misread the message ignore me everyone

flat nymph
finite summit
#

it's quite amazing

wicked loom
#

oh for christ's sake

flat nymph
#

I'm thinking I could support two protocols

wicked loom
#

what's even up with everyone wanting 32-bit support all of a sudden like holy shit

#

sure i will make 32-bit LBP okay?

finite summit
#

I might port obos to x86 (protected mode) eventually

wicked loom
#

sounds painful but i can also get it to work

flat nymph
#

My friend has 2 Intel atom laptops which are 32 bits only

finite summit
#

Find all and Replace: uint64_t -> uintptr_t

wicked loom
#

idk why you couldn't just use multiboot2 on 32-bit but god knows

flat nymph
flat nymph
#

But limine loads SMP

kind root
finite summit
flat nymph
wicked loom
#

does ultra just not map any usable memory on 32-bit or how does the memory map look?

wicked loom
#

what about mmio

kind root
#

What about it

flat nymph
#

Why do you need a memory map for it?

wicked loom
#

do you not map the framebuffer?

#

by default

kind root
#

Nope

finite summit
#

hyper doesn't do any sort of special mapping

kind root
#

Its provided as physical_address

finite summit
kind root
#

Well A20

finite summit
#

that's not hardware is it

kind root
#

Sorta

wicked loom
#

it's hardware

flat nymph
#

In my kernel I don't use direct mappings of any sorts

finite summit
#

my kernel didn't map the framebuffer as WT until very recently

#

maybe a bit after I was done the VMM

wicked loom
#

you must mean WC

finite summit
#

yeah WC

#

mb

#

mix them up in my head often

#

when the kernel is mapped in hyper, you don't get any sort of prot bits set, just RWE

#

so if you don't remap the kernel yourself, you'd need to

flat nymph
wicked loom
#

how do you allocate the page tables your vmm uses

#

because there's this funny thing called recursive mapping

#

that is often (read always) used on IA-32 due to the constraints you're working with

kind root
#

They're pretty similar protocols

#

At least on the base level

flat nymph
#

(after I switch to my own page tables)

wicked loom
#

do you just have those preallocated in the kernel binary?

flat nymph
#

No

flat nymph
wicked loom
#

ok so that's kind of what i was getting at

#

it's a sort of chicken and egg problem, that's what the hhdm is mainly designed to solve

#

at least at the beginning

#

along with providing an easy way to output to the framebuffer from the beginning instead of having to bootstrap at the very least a primitive vmm to map the framebuffer

#

doing all that on massively constrained 4gib of address space is... well

#

not sure how it'd work

flat nymph
#

Oh, for vmm I have 16 list entries in the kernel binary, and I allocate more as needed

wicked loom
#

yes

#

that is one way of solving the chicken and egg problem

#

it would still mean you get no framebuffer until you can map it yourself, on 32-bit architectures at least

flat nymph
wicked loom
#

also, the smp spin wait loops are in the hhdm too, so one would need to also figure out a way to handle those

flat nymph
wicked loom
#

anyways read: it's kind of complicated to provide a fully featured 32-bit version of the Limine protocol

#

without sacrificing any feature

kind root
flat nymph
kind root
#

To make it more uniform

wicked loom
#

imho it's just not worth it

#

to trim features out of the Limine protocol to make a handicapped 32-bit version of it

flat nymph
#

HHDM is the issue

wicked loom
#

which is why my idea is that people would just use multiboot2 if they cared that much about 32-bit support

kind root
#

Yeah, maybe a separate limine version would be better

kind root
#

Unless ur not planning to run in the top half

wicked loom
#

a tweaked multiboot2 with higher half support? :^)

kind root
#

Lol

wicked loom
#

i can do that with way less lines of code

#

tweaked mb2 with smp and higher half

flat nymph
kind root
wicked loom
#

ยฏ_(ใƒ„)_/ยฏ

#

i mean isn't that basically what ultra on 32-bit is?

#

what else does it provide that mb2 (with smp and higher half) would not?

flat nymph
wicked loom
#

i have no issue with gas

#

so it's not "everyone"

flat nymph
#

*a lot of people

wicked loom
#

my only issue with gas is when people don't call it through the compiler driver

kind root
#

Plus ultra has tons of extra features

#

To configure handoff state

wicked loom
#

like what

kind root
#

And like the mappings, whether lower half is mapped, or depth

#

It supports 32 bit with pae

#

Idk off the top of my head what mb2 does or doesn't have

#

But isnt limine multiboot with smp support as well then if u speak in those terms

molten grotto
# flat nymph What's everyone's issue with GAS?

I don't have an issue with gas itself but I do hate att syntax because its full of unnecessary annoying prefixes, non-obvious things like implicit memory accesses, cringe offset syntax and weird operand order than whats used literally everywhere else

wicked loom
#

what if i took Hyper and embeeded it into Limine

#

and then provided the Ultra protocol by just using Hyper

elder shoal
#

Limine subsystem for hyper

kind root
#

Lmaoo

#

Based ngl

wicked loom
#

i'll do it if you make Hyper build with limine-efi instead of whatever you have now and using makefiles

#

so the build system can be more easily integrated

#

it'll basically just result in embedded Hyper EFI executables

#

to chainload

kind root
wicked loom
#

the config can be generated on the fly and shoved in some EFI variable

kind root
#

But if u tell me how I could look into it

wicked loom
#

limine-efi is literally just headers + a small relocation magic that allows an elf to turn into a PE

kind root
#

Why are custom headers needed?

wicked loom
#

they are not

#

you can use your own

#

and just use the relocation code

kind root
wicked loom
#

as long as you use __attribute__((ms_abi)) for calls it's fine

#

for calls into UEFI i mean

kind root
#

Yeah I can just define that

wicked loom
#

if you don't have that in your EFI headers you should add it

kind root
#

I have the empty macros

#

So yes

#

Like EFI_API

#

Iirc

wicked loom
#

it's basically that, then build however you want, as long as you compile in the .c and .S files from limine-efi (it doesn't matter where, they just need to be in), then if you do that, and link with the linker script provided by limine-efi, you can use objcopy binary to turn the elf into a pe

finite summit
#

and I would be able to dual boot obos and linux meme

kind root
wicked loom
#

i promise i will do it if you do that (or add the option to do that)

#

i mean i could also do it downstream but it'd be easier if it was upstreamed

kind root
#

How will you embed it?

#

Like whats the mechanics for that

wicked loom
#

i'll just add it as another "submodule" in ./bootstrap and then build it as part of the limine build system and embed the resulting .EFI file into the limine binary

#

and then chainload it

#

if someone uses protocol: ultra

kind root
#

Ah I see

wicked loom
#

then i guess one would need to adapt the various config options you provide into limine config options for ultra

kind root
#

Ok nice ig