#OBOS (not vibecoded)

1 messages · Page 26 of 1

flint idol
#

git clone -b userspace-work https://github.com/OBOS-dev/obos

#

@limber wave

#

Which include build prerequisites

limber wave
#

in command promot#

#

?

flint idol
#

Yes

#

Luckily for you, if you have all the tools required, building on windows works

limber wave
flint idol
#

Clones the obos repository

limber wave
#

now what?

flint idol
#

Look at instructions in readme

limber wave
#

alr

#

Microsoft Windows [Version 10.0.19045.5131]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Xavier>cmake -GNinja -DCMAKE_BUILD_TYPE=Debug --toolchain=src/build/x86_64/toolchain.cmake -B build/x86_64 .chmod +x dependencies/hyper/hyper_install-linux-x86_64cmake --build build/x86_64scripts/generate_initrd-x86_64.shcmake --build build/x86_64
CMake Warning:
Ignoring extra path from command line:

"build/x86_64scripts/generate_initrd-x86_64.shcmake"

CMake Error: Unknown argument --build
CMake Error: Run 'cmake --help' for all supported options.

C:\Users\Xavier>

#

the 2 step doesnt work

flint idol
#

Copy one command at a time

limber wave
#

also

#

wheres the cloned repo

flint idol
#

In the directory you ran git clone in

limber wave
#

but it wont make it defualt system right?

flint idol
#

No

limber wave
#

when you type in the final step

#

alr

flint idol
#

Ofc not

#

Final step launches a vm

#

Using qemu

limber wave
#

ah alr

flint idol
#

Btw if any build errors happen, it is probably because you are missing a prerequisite tool

limber wave
#

also

#

is hyper v recommanded

#

as vm

flint idol
limber wave
#

so no/

flint idol
#

But yeah I'd recommend using hw accelerated vms

#

Because it's a lot faster

limber wave
#

Like vb

flint idol
#

Especially on debug mode

limber wave
#

alr

flint idol
#

Which is what those commands compile by default

limber wave
#

which file do i use

flint idol
#

Wdym?

#

@limber wave

limber wave
#

there are 4 files

flint idol
#

Yes and what are you tryna do

limber wave
#

which do i use to put in the vm

flint idol
#

ISO is stored under obos/out/obos.iso

#

Assuming the build was a success

limber wave
#

wait imm install again

flint idol
#

kk

#

Not any further than I was a couple days ago

#

Yup

#

No comment

limber wave
#

wen i slect add in virtual box they ask me the file name what is it

flint idol
#

If that doesn't exist your build failed

limber wave
#

yep

#

then imma reinstall it

flint idol
#

Make sure you have all prerequisites

flint idol
limber wave
#

brb

flint idol
#

Yeah I gtg too

#

Be back in 30 minutes

#

At the earliest

limber wave
#

i will

limber wave
#

w

limber wave
#

bruh

#

how do you install cmake

#

@flint idol

#

@flint idol

flint idol
#

Will assist you in 15 minutes

#

Currently in a crowded area

#

Aka masjid al haram

limber wave
#

blud is riding a camal

#

jk

flint idol
#

bru

#

It's far too crowded to ride a camel

#

Also I saw what you deleted

limber wave
#

...

#

forgive me

weak kestrel
#

or if you are on a sane distro just type cmake and it'll ask you if you want to install it

flint idol
#

Basically

#

Search cmake

#

Find installer on website

#

Use installer

limber wave
flint idol
#

I use debian

#

(Insert debian my beloved here)

#

L

#

Debian sid my beloved

limber wave
#

arach vs debian

flint idol
#

Boo

limber wave
#

i heard debian had a bug which uninstalled your graphics driver'

flint idol
#

Anyway gtg

limber wave
#

randomly

limber wave
#

alr

flint idol
#

I haven't had any major problems with debian

#

That were caused by debian itself

weak kestrel
flint idol
#

Yello guys

#

Kbye

weak kestrel
elfin wolf
flint idol
#

I was at umrah a day prior

#

Wait for file upload

#

@real pecan

real pecan
#

Acpi tables are built by qemu and not seabios

flint idol
torpid wigeon
weak kestrel
flint idol
#

Just start a chain of that until I get back to obos work

torpid wigeon
#

dont care

#

write better code

flint idol
#

Huh

torpid wigeon
#

oh wait

#

i thought you said "until i get obos back to work"

flint idol
torpid wigeon
#

reading fail

white mulch
#

make a multisyscall bytecode in obos troll

white mulch
#

I though it would be kinda funny, basically a syscall that you give a bytecode that can do more syscalls and move arguments/return values around

#

then you could write a hello world using one real syscall that combines print + exit (but with no additional context switch overhead)

#

or for a less cursed alternative just without the bytecode part like you though at some point KEKW

torpid wigeon
#

aml syscall

flint idol
#

Would be amazing if it weren't for the direct system access

white mulch
#

you could do security checks in the uacpi kernel api fns

#

to make sure that userspace supplied aml can't do reads/writes to anywhere in mmio/io/pci

torpid wigeon
#

just allow it

short mortar
#

Who cares about security

torpid wigeon
#

only nerds

flint idol
weak kestrel
flint idol
honest citrus
weak kestrel
flint idol
empty kernel
flint idol
sterile sparrow
flint idol
weak kestrel
flint idol
#

Don't think my pc should be doing that

#

Huh

#

It worked when I clicked a key

#

oh god

#

idk if it's because I haven't typed at this pace for a long time or that I somehow became faster at typing on my vacation

#

but my typing feels a lot faster

#

also I think osdev does make me go insane

#

I swear I felt a lot different before I left for vacation

#

probably just osdev and school driving me nuts

flint idol
#

time to get back on obos grind

flint idol
#

@white mulch I need you to test a seabios image

#

pls

#

make sure ur stuff works with it since it does the mmconfig

#

on suspend

white mulch
flint idol
#

kthx

#

hmm

#

it seems to use ioconfig

#

on resume for me

white mulch
#

actually yeah nvm lol, I were accidentally using the wrong run target that didn't use the bios

white mulch
#

yes

flint idol
#

kthx

flint idol
#

@real pecan my cousin decided to test obos on a laptop of his

#

and we'll see how uacpi works there

#

although currently it is refusing to go into obos

real pecan
#

nice

#

im going to merge the first batch of thread safety soon

flint idol
#

I told him to change the boot priority of the usb

real pecan
#

it also adds an absolute ton of convenience functions

#

and reworks a lot of api

flint idol
#

in case it was a bug with his bios' boot selector

flint idol
#

will be waiting

real pecan
#

inb4 obos dies too fast

#

are u back from vacation?

flint idol
#

yup

real pecan
#

did u enjoy it

flint idol
#

very

real pecan
#

nice

#

oh also the new version will have successfully loaded & executed 1 AML blob in 2ms (49 opcodes, avg 19483 ops/s) etc

flint idol
#

cool

#

more unneeded verbosity to my logs

#

(not complaining btw)

weak kestrel
flint idol
#
[  LOG  ] Arch_KernelMainBootstrap: Done early boot.
[  LOG  ] Currently at 8892 KiB of committed memory (1332 KiB pageable), 0 KiB paged out, 8756 KiB non-paged, and 0 KiB uncommitted. 16228 KiB of physical memory in use. Page faulted 933 times (0 hard, 933 soft).```
real pecan
#

im not sure if thats the final look

real pecan
#

i hate winter so some sand could be nice right now

#

@flint idol is there any way u could test the new pr before i merge it

#

i mean on real hw and qemu etc

flint idol
#

probably

#

does it change any namespace node api?

real pecan
#

yes

flint idol
#

how much?

real pecan
#

not a lot

#

one extra parameter, and u will have to call a different function

flint idol
#

I'll try tn

#

*rn

real pecan
#

thanks

flint idol
real pecan
#

that hasnt changed

flint idol
#

ok

#

I should be relatively good

real pecan
#

yeah

#

this is final api btw

#

i wont change it further probably

flint idol
#

big W

real pecan
#

if i stop being lazy af 1.0 could be a few weeks away

flint idol
#

cool

#

obos hangs on his laptop

real pecan
#

unlucky

#

do u know where it hangs approximately?

flint idol
#

not at all

#

only thing I know is it hangs after scheduler timer init

real pecan
#

more debugging to do i guess

flint idol
#

yup

#

but now I wanna test uacpi

#

's thread safety

real pecan
#

do it

#

now u should be able to enable events right away

#

it shouldnt race with init

#

things that are still racey: opregion install/uninstall, event handler install/uninstall

#

but only if done at runtime

#

the interpreter and namespace stuff should be fully thread safe now

flint idol
#

nice

real pecan
#

can try uefi mode too

flint idol
#

legacy didn't work

real pecan
#

ah

flint idol
#

uefi mode hung in obos

#

legacy didn't boot in the first place, just went onto booting into linux

real pecan
#

cursed laptop

flint idol
#

real

real pecan
#

very good RetarBIOS implementation

barren merlin
flint idol
real pecan
#

ye

flint idol
#

kthx

real pecan
#

uacpi_namespace_for_each_child is the full one, u can use uacpi_namespace_for_each_child_simple, which is more like the old api

flint idol
#

k

real pecan
#

but the former can filter by type etc which is convenient

#

also eval has a billion shorthands now

flint idol
#

since I'm only testing to see if it will work rn, I'll just use the one more like the old api

real pecan
#

ye

flint idol
#

@real pecan

#

actually

#

more so
shareable.c:(.text+0x236): undefined reference to uacpi_atomic_inc32' /home/oberrow/x86_64-elf-tools/bin/../lib/gcc/x86_64-elf/13.2.0/../../../../x86_64-elf/bin/ld: ../uACPI/libuacpi.a(shareable.c.obj): in function uacpi_shareable_unref':
shareable.c:(.text+0x2e0): undefined reference to uacpi_atomic_dec32' /home/oberrow/x86_64-elf-tools/bin/../lib/gcc/x86_64-elf/13.2.0/../../../../x86_64-elf/bin/ld: ../uACPI/libuacpi.a(shareable.c.obj): in function uacpi_shareable_refcount':
shareable.c:(.text+0x3de): undefined reference to `uacpi_atomic_load32'\

#

those ones

#

the others I know are my fault

real pecan
#

they're in platform/atomic.h

#

did u override it?

flint idol
#

probably not

real pecan
#

if not then it should be there

flint idol
real pecan
#

#define uacpi_atomic_inc32(ptr) __atomic_add_fetch(ptr, 1, __ATOMIC_ACQ_REL)

#

does ur atomic.h header have that?

#

ah nvm

#

it's because u override arch helpers

#

and arch helpers include atomic

#

and other files expected to get atomic through it

#

ill fix those but now u can just add that include

real pecan
real pecan
flint idol
#

yup

flint idol
#

uacpi_atomic.h

#

?

real pecan
#

in your arch helpers just add #include <uacpi/platform/atomic.h>

flint idol
#

kk

real pecan
#

u actually use uacpi's atomics here

#

so would be a good idea to include it anyway

flint idol
#

oh yea

#

I do

short mortar
real pecan
#

would be cool if u have time, but keep in mind its just a pr right now and not merged

flint idol
#

@real pecan It works

real pecan
#

real hw too?

flint idol
#

on qemu

#

real hw I will test shortly

real pecan
#

well thats nice anyway

flint idol
#

k rebooting now to test it

#

It appears to hang

#

Idk if that's my fault or yours

flint idol
#

@real pecan

real pecan
#

i mean idk either

#

can u add printfs or something

flint idol
#

I'll see if it hangs when I use uacpi master

real pecan
#

that wouldnt mean much

#

because it now uses mutex api and event api and stuff and maybe u handle some of that wrong

#

do u have deadlock detection in your mutexes?

flint idol
real pecan
#

then it's probably your skill issue that it hangs

#

only way it would hang in uacpi is mutex deadlock if some logic is wrong somewhere

flint idol
#

It does check for recursive locks

#

And asserts it

real pecan
#

u should add like

#

mutex acquire time outs

flint idol
#

Eventually

real pecan
#

so that it panics and dumps the waiters

real pecan
#

anyway more printffing is needed

#

yeah im looking at event code rn and dont see anything wrong instantly

flint idol
#

I decided to log every mutex acquire and release

#

This is gonna take a long time

real pecan
#

indeed

flint idol
#

It's been 4 minutes

#

Still no sign of it being close to that code

real pecan
#

lol

flint idol
#

Nearly 10 minutes

#

Still eating away at logs

#

Bruh

#

It hung outside of mutex code

real pecan
#

damn

#

well now u know its unrelated to mutexes

flint idol
#

Yup

real pecan
#

didnt u already have this bug before where events would hang or something?

flint idol
#

btw, what my kernel's idea of "event" is different than uacpi's idea, iirc, so I made some half-assed implementation

#

that I never tested

real pecan
#

events are only used for global firmware lock

#

well and aml Event objects

#

that code hasnt changed in a while

real pecan
#

did u figure it out?

flint idol
#

helping my cousin run an obos vm

real pecan
#

ah

flint idol
#

no

inland radish
#

im talking about infy

flint idol
#

unless you were talking to infy

#

o

inland radish
#

does UACPI acquire mutexes while having acquired mutexes

real pecan
#

In limited cases

#

Certainly not where it currently hangs in obos

inland radish
#

Does Windows handle that case by deadlocking?

real pecan
#

And yes abba aml acquires would hang in nt

#

But thats not what happens here

inland radish
#

ok, cool

real pecan
#

Well sane aml doesnt do that generally

flint idol
#

@real pecan this bug was there before I updated uacpi

#

The hanging

real pecan
#

So where does it hang exactly

flint idol
#

Still don't know

real pecan
#

Why did it work before

flint idol
#

On x86_64

#

But I fixed that

real pecan
#

Maybe thats why it also dies on your cousins laptop

flint idol
real pecan
#

So like this worked before because u had events disabled?

flint idol
real pecan
#

Lol

#

Obos curse from the past

flint idol
#

Wtf

#

It did work before

#

But checking out that commit

#

Only reveals the opposite

#

Bruh wtf

#

I swear it worked before

real pecan
#

Inb4 obos never even booted once and it was all a dream

flint idol
#

Btw, a seabios maintainer asked if they could add it to the beginning of pci_resume, to which I replied "yes," after asking qwinci to test it

#

God damn it discord

#

Why didn't discord reply to the god damn message

#

Meant to reply to this

real pecan
flint idol
#

Yea the bug was fixed

thick jolt
#

hihi

flint idol
#

@spark phoenix this thing is obos

#

anyway now that you're here

#

a star would be appreciated

spark phoenix
#

how on mobile

flint idol
#

broooooooooooo

#

I need to fix the hanging bug

#

but I don't wannaaaaaaaa

#

ah well

#

how sad

#

guess I have to

real pecan
#

fix it 😡

#

so i can be sure its not a uacpi bug

flint idol
#

Since it persists with uacpi master

real pecan
#

oh well

#

still debug

flint idol
#

Yeah

#

Thank God it isn't with gpes

#

@real pecan watdat mean

real pecan
#

u dont have a notify handler installed for this device

#

it doesnt really mean anything

flint idol
#

Oki

real pecan
flint idol
#

Remember the gpe bug I fixed a couple weeks back

real pecan
#

oh yeah

flint idol
#

I was scared that it manifested itself again

#

Which was why I added the logs in bootstrap irq handler

real pecan
#

@flint idol did u figure out the bug?

flint idol
#

Haven't worked on obos in days

#

So nope

real pecan
#

damn

#

what are u up to these days

flint idol
#

School

real pecan
#

f

torpid wigeon
#

just don't go

flint idol
#

I would never

torpid wigeon
#

how much school u got

flint idol
#

obos is love

torpid wigeon
#

i have a full time job and more time than you

flint idol
#

obos is life

#

Well some time is school

#

Some time is being tired after school

#

Some time is ignoring this bug

torpid wigeon
#

no time for tired

#

you can be tired when you're sleeping

flint idol
#

Most time is ignoring this bug

real pecan
torpid wigeon
#

whenever i encounter a bug i can't figure out i rewrite the system that's around it and that usually fixes it

#

its effectiveness is debatable

flint idol
#

For you, infy, I will debug this bug

torpid wigeon
#

inshallah 🙏

real pecan
#

this is a 5th obos rewrite

flint idol
#

Now if only

#

I could get KDE to work properly

#

It broken

torpid wigeon
#

kde user spotted

flint idol
#

After update

flint idol
real pecan
flint idol
#

So I hang after events are registered

#

Seemingly

#

It's not with gpe handling

#

What

#

It works on bios

#

And on uefi

#

@real pecan the bug has decided to disappear

real pecan
#

obos is stable once again

flint idol
#

Although my time keeping is broke

#

Whatever happened to this bug, idk

#

Maybe you accidentally broke something in uacpi and unknowingly fixed it

real pecan
#

you're using an outdated versin too

#

nah i doubt it's a uacpi problem

flint idol
#

Well bugs don't just fix themselves, do they

real pecan
#

hard reset the pc

flint idol
#

This is the commit where you added the ops/s

real pecan
#

wrong commit because i can see outdated formatting

real pecan
flint idol
#

I will try it a couple more times

#

And will remove my printf

real pecan
#

didnt u say even old uacpi was broken

flint idol
#

And update my uacpi

flint idol
#

Before you merged this branch

real pecan
#

yeah idk

flint idol
#

But at one point it also worked

#

Must be magic or smth

real pecan
#

curse

flint idol
#

Maybe I need to do an exorcism on obos

real pecan
#

well if it works it works

flint idol
#

Until it doesn't

#

Which is why I'm making sure it does

#

For now

real pecan
#

is this bug reproducable or gone completely?

flint idol
#

Gine

#

*gone

real pecan
#

pretty small aml

#

as a comparison, mint's latest pc mb is 16k ops

flint idol
#

Also I think I might know why obos' ops/s is so slow

#

I have ubsan and kasan enabled

real pecan
#

probably

flint idol
#

I turned that off and it's 9k ops a second

#

Which still sucks

#

But I can also blame that on my.. questionable timekeeping method for uacpi

#

Or in general

real pecan
#

true

#

a bit hehind keyronex at 750k

flint idol
#

So not very precise

#

3800 ops in 200ms

#

On real hw

#

Which is a big number when converted to ops/s

#

Although that's probably a broken number

real pecan
#

3800 * 5

flint idol
#

Damn camera

real pecan
#

yea...

flint idol
#

Idk what's up with ur calculation

real pecan
#
        uacpi_u64 ops = g_uacpi_rt_ctx.opcodes_executed;
        uacpi_u64 ops_per_sec = ops * UACPI_NANOSECONDS_PER_SEC;

        if (uacpi_likely(end_ts > begin_ts))
            ops_per_sec /= end_ts - begin_ts;
#

its literally this

flint idol
#

Well

#

Idk why the number is like that atm

real pecan
#
static uacpi_u64 elapsed_ms(uacpi_u64 begin_ns, uacpi_u64 end_ns)
{
    return (end_ns - begin_ns) / (1000ull * 1000ull);
}
#

maybe end ends up being less than begin in your case

flint idol
#

Bru

real pecan
#

and so it wraps around

flint idol
#

I hate how obos uses so much memory, and I have no idea where

#

Like how is 17M physical memory in use

#

Where is it being used???

#

Symbol table is one thing

#

Drivers are another

#

Albeit not that significant

#

In terms of memory usage

#

Maybe it's pagecache

#

Along with uacpi

#

Since that uses many memory

real pecan
#

allocate with tags

#

so u know

flint idol
#

Good idea

#

If I want to port obos to esp32, I need to get that count down

#

By a lot

lean glen
empty kernel
flint idol
#

I am not

#

I just throw it in hhdm and call it a day

#

(I shouldn't)

flint idol
empty kernel
#

consolidate any physical regions in the same page into one virtual allocation

flint idol
#

Ok so around 2M is page cache

#

110 kib is uacpi

#

158K by the kernel symbol table

flint idol
#

Todo add an option to the kernel's early bump allocator to configure the size of the region

short mortar
#

I'm just taking the largest region from the memory map, before I initialize my PMM

flint idol
#

I'm gonna try to tag allocations now

#

so I'll start with the new api

#
void* (*TagAllocate)(struct allocator_info *This, size_t nBytes, allocator_tag tag, obos_status* status);```
#
typedef enum allocator_tag
{
    ALLOCATOR_TAG_MISC,
    ALLOCATOR_TAG_ACPI,
    ALLOCATOR_TAG_VFS,
    ALLOCATOR_TAG_SYMBOL,
    ALLOCATOR_TAG_DRIVER_INTERFACE,
    ALLOCATOR_TAG_HANDLE,
    ALLOCATOR_TAG_HANDLE_TABLE = ALLOCATOR_TAG_HANDLE,
    ALLOCATOR_TAG_SCHEDULER,
    ALLOCATOR_TAG_IRQ, // include dpcs, timers, irq objects
    ALLOCATOR_TAG_ARCH,
    ALLOCATOR_TAG_DRIVER,
    ALLOCATOR_TAG_SYNC_PRIMITIVE,
} allocator_tag;```
#

there are my allocator tags

#

stuff like strings go into misc

#

the rest is self explanatory

real pecan
#

Could've just done 4 or 8 byte strings

#

Like nt

flint idol
#

tru

#

but I was also maybe thinking of a global variable

real pecan
#

U can compute this at runtime

flint idol
#

true

real pecan
#

By walking over every allocated range

flint idol
#

mhm

lean glen
#

crigne

flint idol
#

for reference:

#

that's my channel list on cherno server

#

the other channels are 💩

#

hotgarbage on top

#

the people who can take a god damn joke are in hotgarbage

#

and the rest are in the other channels

#

fun fact: that channel is the most active

flint idol
#
oberrow@AcerAIO:~/Downloads/obos-uacpi-test$ grep -n '>ZeroAllocate' `find src/ -name '*.c'` | wc -l
68```
Oh god
#

68 more allocations I need to tag

real pecan
#

acpica does it so no

flint idol
#

uhhh

real pecan
#

lol

flint idol
#

that's a near two month old message

real pecan
#

for some reason that was the message that was open on my pc

flint idol
#

and you already responded

real pecan
#

but enjoy ur answer

#

lmao

flint idol
#

#1141057599584878645 message

real pecan
#

oh well

#

i wonder how i ended up there

flint idol
#

I did link a message around that point

#

here

#

#1302525344095408171 message

#

maybe you clicked on it

#

and discord did discord stuffs

real pecan
#

yeah probably

flint idol
#

for future reference, tagging allocations is boring

#
timer* Core_TimerObjectAllocate(obos_status* status)
{
    if (!OBOS_NonPagedPoolAllocator)
        return OBOS_KernelAllocator->ZeroAllocate(OBOS_KernelAllocator, 1, sizeof(process), status);
    return OBOS_NonPagedPoolAllocator->ZeroAllocate(OBOS_NonPagedPoolAllocator, 1, sizeof(process), status);
}```
#

wtf

#

as we can see, a struct timer is quite obviously the same thing as a struct process

real pecan
#

did u expect it to be fun

flint idol
#

well no

real pecan
#

part of why obos is so stable

flint idol
#

copypasta

#

20 more to go

real pecan
#

i hope process is larger than timer

flint idol
#

it is

#

I think

#

a FAT dent

#

oberrow@AcerAIO:~/Downloads/obos-uacpi-test$ grep -n '>ZeroAllocate' `find src/ -name '*.c' ! -path "*mbr.c" ! -path "*disk_swap.c" ! -path "*gpt.c" ! -path "*slowfat/io.c"` | wc -l 0

#

finally

#

no more allocations to tag

real pecan
#

nice

flint idol
#

ok it built

#

it still boots

#

which is a good sign

#

now time to dump the tags

flint idol
#
Tag memory usage:
  UNKNOWN: 0 B
  PAGE: 247 KiB
  WS_NODE: 14 KiB
  PAGEINFO: 64 B
  PG_RANGE: 13 KiB
  WS_ENTRY: 44 KiB
  PCREGION: 608 B
  CONTEXT: 592 B
  CMDPARAM: 224 B
  PROC: 480 B
  THR_NODE: 288 B
  x86_64: 240 B
  CPULOCAL: 3 KiB
  THREAD: 1 KiB
  IRQ_NODE: 224 B
  IRQ: 272 B
  INITSWP: 14 KiB
  CLINEBMP: 16 B
  SYNC: 1 KiB
  ACPI: 113 KiB
  SYMNAME: 41 KiB
  SYMBOL: 98 KiB
  DRV_ID: 3 KiB
  DVINITRD: 33 KiB
  DRV_HDR: 2 KiB
  UART_STR: 16 B
  TMP: 80 B
  FD: 48 B
  FATFNODE: 64 B
  FATBPB: 704 B
  FATCACHE: 432 B
  FATDENT: 1 KiB
  DPC: 560 B
  SIGHDR: 3 KiB
  VFS: 6 KiB```
#

vmm context

#

I immediately see 80b leaked here

#

In TMP

#
[  LOG  ] Processing tagged memory allocations...
Tag memory usage:
  UNKNOWN: 1 KiB
  PAGE: 247 KiB
  WS_NODE: 14 KiB
  PAGEINFO: 64 B
  PG_RANGE: 13 KiB
  WS_ENTRY: 44 KiB
  PCREGION: 576 B
  CONTEXT: 240 B
  CMDPARAM: 224 B
  PROC: 416 B
  THR_NODE: 288 B
  x86_64: 240 B
  CPULOCAL: 3 KiB
  THREAD: 1 KiB
  IRQ_NODE: 224 B
  IRQ: 272 B
  INITSWP: 14 KiB
  CLINEBMP: 16 B
  SYNC: 1 KiB
  ACPI: 113 KiB
  SYMNAME: 41 KiB
  SYMBOL: 98 KiB
  DRV_ID: 3 KiB
  DVINITRD: 33 KiB
  DRV_HDR: 2 KiB
  UART_STR: 16 B
  TMP: 80 B
  FD: 48 B
  FATFNODE: 64 B
  FATBPB: 512 B
  FATCACHE: 432 B
  FATDENT: 1 KiB
  DPC: 48 B
  SIGHDR: 3 KiB
  VFS: 6 KiB
[  LOG  ] Mm_Allocator: 691 KiB in-use
[  LOG  ] OBOS_KernelAllocator: 1020 KiB in-use
[  LOG  ] OBOS_NonPagedPoolAllocator: 16 KiB in-use
[  LOG  ] Vfs_Allocator: 16 KiB in-use```
#

this is not making snese

#

all those tagged allocations combined are less than the amount used by the allocators

#

that were processed

#

and if I missed tagging some, it would be in UNKNOWN

#

well since this actually goes through each allocated block and accumulated the sizes that way

#

I'm going to assume those other numbers are buggy

flint idol
#

I should make a slab allocator for obos

#

I start now

#

@real pecan when uAllocator

weak kestrel
#

when obos can run managarm inside qemu/kvm

flint idol
#

tomorrow

weak kestrel
#

so in about 2-3 days

#

yes

flint idol
#
/*
 * include/slab.h
 *
 * Copyright (c) 2024 Omar Berrow
 */

#pragma once

#include <stdint.h>
#include <stddef.h>

// To be defined by user.

// Read-Write No-Execute
extern void *slb_map(size_t size);
extern void  slb_unmap(void* base, size_t size);

typedef struct slab_allocator slab_allocator_t;

int   slb_init(slab_allocator_t* state);
void* slb_alloc(slab_allocator_t* state, size_t size);
void* slb_calloc(slab_allocator_t* state, size_t objs, size_t szObjs);
void* slb_realloc(slab_allocator_t* state, void* blk, size_t newsize);
void  slb_free(slab_allocator_t* state, void* blk);
void  slb_getsize(slab_allocator_t* state, void* blk, size_t* sz);```
real pecan
flint idol
#

so far

lean glen
#

good

#

because that sucks

flint idol
#

now the actual allocation api is the same because idk how I would change it

weak kestrel
#

can you overload the new operator to take an extra argument

flint idol
#

in C, no

weak kestrel
#

like for what oberrow is doing

flint idol
#

in C++, no

weak kestrel
#

in C++

#

new(tag) type { };

flint idol
#

doubt

lean glen
#

I do that

flint idol
#

oh wait nvm

weak kestrel
lean glen
#

example

flint idol
#
#ifndef CACHE_SIZE_DEFAULT
#   define CACHE_SIZE_DEFAULT 4096
#endif

#ifndef slb_popcount
#   error Define slb_popcount. With GCC C extentions, this looks like __builtin_popcountll.
#endif

#ifndef slb_bsf
#   error Define slb_bsf. With GCC C extensions, this looks like __builtin_clzll.
#endif

#ifndef slb_bsr
#   error Define slb_bsr. With GCC C extensions, this looks like __builtin_ctzll.
#endif


#ifndef SLB_ALIGN
#   error Define SLB_ALIGN
#   define SLB_ALIGN(struct_, align_to)
#endif

// To be defined by user.
// Read-Write No-Execute
extern void *slb_map(size_t size);
extern void  slb_unmap(void* base, size_t size);

typedef struct slab_allocator *slab_allocator_t;

// Returns sizeof(struct slab_allocator)
size_t slb_allocator_size();

// NOTE: This is not thread-safe!
// Thread-safety must be added on top of these APIs.

// Returns zero on success, one on failure.
// maxSlabSize: The maximum slab size; must be a power of two greater than 32, and less than cacheSize. Hard limit is 0x40000.
//   cacheSize: The cache size; must be a power of two greater than maxSlabSize. If zero, CACHE_SIZE_DEFAULT is assumed. Hard limit is 0x40000
int slb_init(slab_allocator_t state, size_t maxSlabSize, size_t cacheSize);

void* slb_alloc(slab_allocator_t state, size_t size);
void* slb_calloc(slab_allocator_t state, size_t objs, size_t szObjs);
void* slb_realloc(slab_allocator_t state, void* blk, size_t newsize);
void  slb_free(slab_allocator_t state, void* blk);
void  slb_getsize(slab_allocator_t state, void* blk, size_t* sz);```
#

now the header is that

real pecan
#

idk how that works

lean glen
#

no

#

operator new(Tag) or whatever

real pecan
#

ah ok nice that u can overload that

flint idol
#

no

lean glen
#

that is not a slab 😭

flint idol
#

it's something

real pecan
#

SLOBOS

weak kestrel
#

I have no idea what this means

flint idol
#

because I ain't readin allat (yet)

real pecan
#

I think SLOB is the slab implementation Linux uses for embedded

flint idol
#

yes

#

but SLOBOS is some allocator for obos

real pecan
#

Yup

flint idol
#

which I'm hoping will be faster than whatever shit I have rn

vale nymph
#

call it slop

flint idol
#

not even a bad idea

#

because it's probably still gonna be shit

#

I'll call it slop

real pecan
#

How is it going

flint idol
#

Today I need to finish some school work

#

And prove my friend wrong

#

He thinks I can't write a Morse code translator in one day

real pecan
#

its literally a lookup table to ascii char?

flint idol
#

Exactly

#

But he doesn't know that

flint idol
#

But yeah

vale nymph
flint idol
#

I will after making that stupidly simple thing

real pecan
#

i bet u cant make the next year the year of obos desktop

flint idol
#

Ez

#

I just copy Windows syscalls

#

Vam

#

*bam

flint idol
#
void print_morse(const char* morse)
{
  for (int i = 0; morse[i]; i++)
  {
    digitalWrite(PULSE_PIN, HIGH);
    delay(pls);
    digitalWrite(PULSE_PIN, LOW);
    switch(morse[i])
    {
      case '.':
        delay(dit);
        break;
      case '-':
        delay(dah);
        break;
      case '/':
        delay(spc);
        break;
      default: break;
    }
  }
}

void serialEvent()
{
    int recv = Serial.read(); 
    if (recv == -1) 
      return;
    if (recv >= 127)
      return;
    const char* ent = table[recv];
    Serial.write(ent);
    Serial.write(" ");
    print_morse(ent);
}```
#

which was easy-ish

#

I also decided to mess around with power states so I could get an equivalent of x86's hlt instruction

#

table is just an ascii -> morse lookup table

#
const char* table[128] = {
    0,0,0,0,0,0,0,0,                                                 // 0-7
    0,0,0,0,0,0,0,0,                                                 // 8-15
    0,0,0,0,0,0,0,0,                                                 // 16-23
    0,0,0,0,0,0,0,0,                                                 // 24-31
    "/", 0,0,0,0,0,0,0,                                              // 32-39
    0,0,0,0,0,0,0,0,                                                 // 40-47
    "-----",".----","..---","...--","....-",".....","-....","--...", // 48-55
    "---..","----.",0,0,0,0,0,0,                                     // 56-63
    0,".-","-...","-.-.","-..",".","..-.","--.",                     // 64-71
    "....","..",".---","-.-",".-..","--","-.","---",                 // 72-79
    ".--.","--.-",".-.","...","-","..-","...-",".--",                // 80-87
    "-..-","-.--","--..",0,0,0,0,0,                                  // 88-95
    0,".-","-...","-.-.","-..",".","..-.","--.",                     // 96-103
    "....","..",".---","-.-",".-..","--","-.","---",                 // 104-111
    ".--.","--.-",".-.","...","-","..-","...-",".--",                // 112-119
    "-..-","-.--","--..",0,0,0,0                                     // 120-127
};```
now this is the actual table, beautiful, isn't it
flint idol
#

ok I was working on a new allocator last time I was here

#

so now I'll work on that more

#

ok I fixed some bugs with it

#

now for the real test case, uacpi

#

(I couldn't be bothered to write a proper test case)

#

((but this is probably good enough))

real pecan
#

why are u rewriting it again

flint idol
#

speed

#

this one is slow as balls

#

as in the old one

#

that is in use for obos

#

it's like O(n) to allocate, with n being the amount of allocated regions in the allocator

real pecan
#

i thought it was a normal slab allocator

flint idol
#

what is?

#

the one currently being used in obos?

#

no that one is a shitallocator

real pecan
#

yes

flint idol
#

I made it with the goal of it not crashing

#

which is going well
but as for its speed...

#

this allocator crashes after a bit of uacpi

flint idol
#
struct slobos* slobos = (void*)((uintptr_t)blk & ~(state->cacheSize-1));```
#

I have this line

#

to get a struct slobos from an allocation

#

now, if state->cacheSize were the page size, it should work

#

but it isn't

#

and since the slobos isn't guaranteed to be aligned to that margin, that line breaks

#

and idk how to fix it

torpid wigeon
flint idol
torpid wigeon
#

slopos

flint idol
#

Then abbix comes in and says not a slab allocator

lean glen
#

yes

real pecan
lean glen
#

idk I did too

real pecan
#

Slobos is my idea anyway

lean glen
#

slobos is such a bad name

#

sloberrow when

real pecan
#

Very much in line with the impl meme

flint idol
#

Abbix said it wasn't a slab allocator

flint idol
lean glen
#

or just

#

read the paper

#

😭

flint idol
#

No.

vale nymph
torpid wigeon
thick jolt
#

boo

flint idol
#

ahhhh

#

scary

flint idol
#

after having fixed the bug with freeing

#

I think it passes uacpi test

#

the allocator

#

there was one error, but that was because I didn't load any ssdts

#

loading ssdts fixed that

#

now to port this to obos

#

now unfortunately, this allocator will probably never support tagging

#

as the only metadata it has on an allocation is that it exists in a struct slobos somewhere

#

but because of that it (probably) uses a lot less memory than it actually needs

flint idol
#

we'll see

flint idol
#

to github

flint idol
#

I ported the allocator to obos and wrote the neccessary glue code

#

now I just gotta use it somewhere

#

aaand it page faults almost immediately

#

I am able to get it to run a bit further

#

until it page faults again

#

but I am 75% sure the page faults are a result of how I configured the allocator in this case

#

and not an allocator bug

#

ok now it got to uacpi init

#

where it hangs randomly

real pecan
#

id blame uacpi tbh

coarse elk
lean glen
#

lmao

#

change it to sloberrow

coarse elk
real pecan
#

bruh

flint idol
#

oh fun fact: basically all work I've done on obos for the past two weeks has been done using nano

empty kernel
#

why would you do that to yourself

flint idol
#

because I couldn't bother configuring clangd for the two other copies of obos I have

empty kernel
#

you use cmake right?

flint idol
#

yes

empty kernel
#

then clangd is easy

flint idol
#

and I also couldn't bother setting up my ide

empty kernel
#

what ide?

flint idol
#

well less of an ide

#

and more of an advanced text editor

#

Kate

empty kernel
#

ah

flint idol
#

the KDE editor thing

empty kernel
#

I know what it is, I've used KDE before

flint idol
#

it has LSP support, but with how I have it, it's pretty dodgy

empty kernel
#

why not use vscode or similar

flint idol
#

wasn't a fan of vscode

#

and I don't know of any other free IDEs for linux

empty kernel
#

you can get all the jetbrains ones using an open source license or a student license. They can be a bit buggy with clangformat though

weary hound
#

emacs :^)

flint idol
#

too much work

#

for both messages

empty kernel
#

there is always good old vim (or neovim)

flint idol
#

remove the 'good' part /j

lean glen
#

nano 💀

slow dove
#

nano is too good

#

how about echo "" >> "" trol

flint idol
lean glen
#

vim

#

or

#

emacs

flint idol
#

I wrote that allocator using nano

flint idol
coarse elk
#

nah bro ed is the shit

#

the standard Unix text editor

white mulch
thick jolt
white mulch
flint idol
#

tomorrow /j

torpid wigeon
#

🤨

weak kestrel
#

oberrow what do you have planned

torpid wigeon
#

do not the qwinci

flint idol
#

my debian install seems to be completely fucked

#

so I am reinstalling it

#

be back in a bit

#

Uh oh

#

deb boot strap decided to die on me

#

In the middle of install

#

Luckily debian still booted

flint idol
#

just reinstalled debian

empty kernel
flint idol
thick jolt
flint idol
#

kk I'm back

#

time to get back to pci interface

#

how fun, amiright

#

fuck it

#

I am refactoring the kernel entry

#

and init

real pecan
#

refactoring how?

flint idol
#

well for one

#

all timekeeping shit is in entry.c for some stupid reason

#

I moved that out of there

#

I said many moons ago that with the PCI interface redesign, I also make the ahci support multiple controllers

#

which has now been put off as a TODO

#

(aka never will do)

flint idol
#

ok time to get back to doing this nooo

flint idol
#

ok ahci driver ported

#

to new pci interface

#

except it's not fully done

#

so nothing will uhh

#

actually work

real pecan
#

does it support suspend now

flint idol
#

in the ahci driver

flint idol
#

in the new pci thing

#

oh wait it isn;t

#

*isn't

#

most stuff is

#

not all

#

I can update a resource in the pci config space

#

but I can't actually

#

identify any pci devices

#

and populate the trees n'stuff

#

4-5 months ago, I said I would be in userspace by the end of the month

real pecan
#

Lol

flint idol
real pecan
#

Well if you actually keep working

flint idol
#

if even astral has came back to life

real pecan
#

Astral is about to have full self hosting once gcc links

flint idol
#

cool sauce

#

obos will be there within the next 9 years, trust

real pecan
#

Chrome next

real pecan
flint idol
#
typedef struct pci_bus {
    uint8_t busNumber;
    pci_device* devices;
    size_t nDevices;
    struct uacpi_namespace_node* acpiNode;
} pci_bus;```
when I'm initializing this, I am wondering whether I should probe the bus twice, once to see the device count, and then initialize the actual devices, or to just realloc(devices) for each new device
real pecan
#

Why not have a linked list

#

Those should be fairly large structs

flint idol
#

so not too big

flint idol
#

probably because I won't be adding to the list after the bus is initialized

real pecan
#

Id do a linked list unless performance critical

flint idol
#

so insert and deletion isn't really important

lean glen
#

why do you need this

flint idol
#

abstraction

lean glen
#

why

#

just do driver probing at bus iteration time

flint idol
#

this is bus iteration time

#

I previously had no sane pci interface

#

just some irq stuff

lean glen
#

ok

#

doesnt answer my question

flint idol
#

and I'm not probing drivers either

lean glen
#

why do you need to keep a list of devices

flint idol
#

rn

flint idol
real pecan
lean glen
flint idol
lean glen
#

if a driver gets added

#

reiterate it

lean glen
lean glen
#

just do reiteration

flint idol
#

can't

#

the pci config space is ded

#

after resume from suspend

flint idol
#

all everything is

lean glen
#

ah

#

makes sense then

flint idol
#

I needed to keep all pci devices' config in memory, otherwise I wouldn't be able to use them after resume

real pecan
#

Why would the config be dead lol

flint idol
#

well like

#

the pci devices

#

idk what it's called

real pecan
#

Config is alive but bars are zeroed

flint idol
#

yeah

#

and iirc irq stuff

#

msi stuff

real pecan
#

So u can still enumerate them

flint idol
#

not msi-x

#

well maybe partially

#

msi-x

lean glen
#

ok so do that instead

#

reallocate bars

#

done

flint idol
vale nymph
flint idol
#

what about binutils

vale nymph
flint idol
#

whoa

#

and how long does this all take?

vale nymph
#

NaN

flint idol
#

bruhhhhhhhh

#

I have to relearn everything I figured out

#

about bars

#

and detecting their existance

#

actually

#

no

#

ignore that

flint idol
#

So I wanna do osdev

#

But I have to do homework

#

Now the question is what do I do

#

The correct answer is homework

#

But instead I will be flipping a coin

#

Tails is homework

#

Heads

#

Aw shucks

#

Guess I gotta do osdev now.

#
if (!module)
{
    OBOS_Warning("Could not load driver %s. Status: %d\n", module->name, OBOS_STATUS_NOT_FOUND);
    if (namelen != len)
        namelen++;
    iter += namelen;
    continue;
}```
oops
flint idol
#

oops

#

I accidentally broke the framebuffer in my PCI initialization code

flint idol
#

but anyway

flint idol
#

fixed

#

I have BAR info now

#

in the pci resource list thingy

#
[ DEBUG ] Arch_KernelMainBootstrap: Initializing PCI bus 0
[ DEBUG ] 00:01:00: Initialized 32-bit, prefetchable BAR (BAR 0). BAR ranges from 0x00000000fd000000-0x00000000fdfffff0
[ DEBUG ] 00:01:00: Initialized 32-bit BAR (BAR 2). BAR ranges from 0x00000000febd4000-0x00000000febd4ff0
[ DEBUG ] 00:02:00: Initialized 32-bit BAR (BAR 0). BAR ranges from 0x00000000feb80000-0x00000000feb9fff0
[ DEBUG ] 00:02:00: Initialized 32-bit BAR (BAR 1). BAR ranges from 0x00000000feba0000-0x00000000febbfff0
[ DEBUG ] 00:02:00: Initialized I/O BAR (BAR 2). BAR ranges from 0x000000000000c040-0x000000000000c050
[ DEBUG ] 00:02:00: Initialized 32-bit BAR (BAR 3). BAR ranges from 0x00000000febd0000-0x00000000febd3ff0
[ DEBUG ] 00:1f:02: Initialized I/O BAR (BAR 4). BAR ranges from 0x000000000000c060-0x000000000000c070
[ DEBUG ] 00:1f:02: Initialized 32-bit BAR (BAR 5). BAR ranges from 0x00000000febd5000-0x00000000febd5ff0
[ DEBUG ] 00:1f:03: Initialized I/O BAR (BAR 4). BAR ranges from 0x0000000000000700-0x0000000000000730```
real pecan
#

Nice

flint idol
#
static void initialize_capability_resources(pci_device* dev)
{

}```
now all that's left is this
#

which simply formulates a list of PCI capabilities

#

and puts them in the pci resource list

#

of the device

#

then I need to implement the more advanced pci initialize thing

#

Drv_PCIInitialize()

#

which initializes other buses

#

then I need to implement Drv_PCIUpdateResource

#

which simply reads the actual value of a resource in the config space, and updates the resource to that value

#

then I want to add PCIe support

#

then I will be changing my "pnp" thing to support the new PCI interface

flint idol
#

and I also added some more logs

#

becuz why not

#

for one device:

[ DEBUG ] PCI: 00:1f:02: Device HID: 01:06:01, Vendor ID: 0x2922, Device ID: 0x8086
[ DEBUG ] PCI: 00:1f:02: Initialized I/O BAR (BAR 4). BAR ranges from 0x000000000000c060-0x000000000000c070
[ DEBUG ] PCI: 00:1f:02: Initialized 32-bit BAR (BAR 5). BAR ranges from 0x00000000febd5000-0x00000000febd5ff0
[ DEBUG ] PCI: 00:1f:02: Found and registered MSI Capability.
[ DEBUG ] PCI: 00:1f:02: Found and registered SATA Data/Index Configuration Capability.```
#

imma change the capability log message

#
[ DEBUG ] PCI: 00:1f:02: Device HID: 01:06:01, Vendor ID: 0x2922, Device ID: 0x8086
[ DEBUG ] PCI: 00:1f:02: Initialized I/O BAR (BAR 4). BAR ranges from 0x000000000000c060-0x000000000000c070
[ DEBUG ] PCI: 00:1f:02: Initialized 32-bit BAR (BAR 5). BAR ranges from 0x00000000febd5000-0x00000000febd5ff0
[ DEBUG ] PCI: 00:1f:02: Found MSI Capability.
[ DEBUG ] PCI: 00:1f:02: Found SATA Data/Index Configuration Capability.
[ DEBUG ] PCI: 00:1f:02: Device has IRQ capabilities.```
#

Frick

#

It hangs on real hw

#

it hangs somewhere in the BAR initalization code

#

it could be a bug with how I handle 64-bit bars

#

since it says it initialized a 64-bit bar

#

then it simply hangs

#

BAR0 of the device at 00:02:00 was a 64-bit bar

#

therefore it should be skipping BAR1 since there isn't one

#

then it goes on to BAR2

#

I'm gonna add some printf

flint idol
#

bruhhhh

#

why does it hang

#

unless I accidentally mess something up causing the framebuffer to stop working properly

torpid wigeon
#

check serial vro

flint idol
real pecan