#Nyaux

1 messages · Page 28 of 1

surreal path
#

real

kind root
#

wait did i miss a convo

finite summit
kind root
#

damn

finite summit
#

currently I have gotten it down to:
his computer is haunted

kind root
#

i wanna see an obyaux kernel ngl

finite summit
#

or rewriting obos

#

so he should come work with me on obos :^)

kind root
#

yeah

finite summit
#

he can uhh

#

not write drivers

kind root
#

maybe nyaux should just work on obos instead

finite summit
kind root
#

(if hes okay with that)

finite summit
#

ye

finite summit
finite summit
#

(not even I'd let myself mess with the vmm)

#

I mean there is one relatively simple thing in the vmm that could be done

#

which is updating the swap to disk interface

#

and it's actually like really simple

#

you'd just need to reimplement 5 functions

#

set some function pointers

#

shite

#

I never rewrote Mm_ChangeSwapProvider

#

anyway, I'll stop literring the nyaux thread

cinder plinth
#

come work on my kernel meme

finite summit
cinder plinth
#

yes

#

nyaux

#

nyx

#

perfect

finite summit
#

nyaux without the au

cinder plinth
#

fwiw the name Nyx existed way before he did

#

so

finite summit
#

nyaux but not australian

elder shoal
finite summit
#

O_O

elder shoal
#

they were passing the timeout to ppoll wrong

finite summit
#

actually some sysdeps in obos might translate into multiple syscalls

#

which require you to like know the kernel in-and-out

finite summit
#

like fork

#

probably will translate to like 10 different syscalls

#

idk the exact number

#

1 to fork the current vmm context
1 to create a new process object
2 to make a new thread + one bootstrap function to get the thread in the same state as the thread doing the fork
1 to allocate a stack for said thread
1 to clone the handle table unto the new process

kind root
#

sounds slow

finite summit
# kind root sounds slow

if I did it in the kernel, the only difference is that there would be less switches from ring3->ring0

haughty kite
#

yeah which is the expensive part of a syscall

#

lol

#

youd also save a bunch of syscall validation

#

honestly just do batch syscalling :^)

kind root
#

io_uring in obos

finite summit
haughty kite
#

dont think so

#

iouring isnt quite the same thing

kind root
#

u can extend it to do arbitrary syscalls

edgy pilot
#

syscall_uring

finite summit
#

what's the man page for io_uring

haughty kite
#

man io_uring

#

big brain

finite summit
edgy pilot
finite summit
#
struct obos_syscall_args
{
    uint32_t number;
    uint64_t pars[5];
};
void Sys_RunSyscalls(struct obos_syscall_args* syscalls, size_t nSyscalls):```
#

or even better

#

use AML

#

so I can chain syscall results

edgy pilot
#

randomise them

finite summit
#

genius

#

or I can be sane and just have a Sys_Fork in-kernel

#

to save ring 3 -> ring 0 switches when forking

kind root
finite summit
#

and not make a batch syscall mechanism

kind root
#

i mean a kernel worker thread

finite summit
#

I'll just design a bytecode mechanism to batch syscalls (not)

edgy pilot
#

run everything in ring 0 and you won't have to do cpl switching

finite summit
#
(pseudocode)
NewCtx = RUN_SYSCALL Sys_HandleClone, HANDLE_CURR_VMM_CONTEXT
RUN_SYSCALL Sys_ProcessStart, newCtx, HANDLE_INVALID```
#

anyway that's enough schizophrenia while doing osdev

#

(for the day)

edgy pilot
#

5343 packages to upgrade lapfedmoment

finite summit
#

I now must go implement PCI

finite summit
edgy pilot
#

I'm just upgrading fedora 40 -> 41

finite summit
#

tomorrow I have school nooo

edgy pilot
#

me too death

finite summit
#

ofc when I actually want to work on OBOS

#

school comes

#

and then after school and homework and shit I'm too tired to work

#

on OBOS

edgy pilot
#

but I need to sleep

finite summit
#

go to sleep

elder shoal
#

imagine having motivation for osdev

finite summit
#

and being bored of porting shit

#

the fun stuff lies in your first couple ports and writing the kernel

#

or just come work on obos

edgy pilot
#

kerneldev is fun
osdev is not

finite summit
#

this

plush hearth
edgy pilot
#

Irish

plush hearth
#

Ah

flat nymph
edgy pilot
#

if only I was working on this kernel with someone

surreal path
#

no im working on nyaux

#

myself

surreal path
#

♫ 99 little bugs in the code ♫
♫ 99 little bugs ♫
♫ take one down, patch it around ♫
♫ 137 little bugs in the code ♫

#

♫ 99 little bugs in the code ♫
♫ 99 little bugs ♫
♫ take one down, patch it around ♫
♫ 137 little bugs in the code ♫

#

nyaux theme song

next tusk
silver yarrow
#

♫ 99 little bugs in the code ♫
♫ 99 little bugs ♫
♫ take one down, patch it around ♫
♫ 137 little bugs id♫i♫
♫,g♫ goll ♫♫ behi tepl 3wo9
nt ioutaul♫
ete9h sitttcdno9kch 7ceed ee cu u19e t ond♫tbo sa e a regn tb h
nnli♫tls tdi

edgy pilot
#

somebody forgot to use locks

crystal scarab
#

mmm

surreal path
#

Hi guys got a stomach bug rn

#

I don’t think I can today

#

Maybe tmrw if it gets better

#

I hope anyways

#

Anyways love y’all !!!!

#

cya tmrw :D

edgy pilot
#

debug your stomach

surreal path
#

LMAOOOO

frigid cliff
surreal path
#

bug has been solved

#

uacpi now works

kind root
#

what was the bug

#

also welcome back

surreal path
#

someone on the osdev forums helped me spot it

#

was with the hhdm pages being incorrectly set cause of one stupid fucking variable

#

it was with the page tables

#

so

#

yea

#

no more vmm region corruptiuon uacpi boots

#

i will try turning on ksan

#

ksan still doesnt work

elder shoal
#

2097152

surreal path
#

what

#

yea thats the length of a 2mb entry

#

thats 2mb

elder shoal
#

girl the gods gave you macros use them smh

#

magic numbers are CRINGE smh

surreal path
#

no :)

#

anyways i want a break for today i had a really bad mental breakdown cause everyone was making fun of me in valorant earlier and i was crying and stuff

#

im not in the mood to do much rn

#

tmrw ill work on scheduler

#

sorry timers*

#

then smp then scheduling

#

ykyk

surreal path
#

they were

surreal path
#

really fucking mean

#

they said a lot of things, they even found my parents facebook

#

and made fun of my family

#

and they were like

surreal path
#

yea

tender gorge
#

yeah they're giant assholes

surreal path
tender gorge
#

sorry you had to go through that

surreal path
#

people on valorant are actually horrible people

surreal path
kind root
#

cool

surreal path
#

yea

surreal path
# kind root cool

are u like mad at me or anything (sorry if this is a stupid question)

kind root
#

not really lol

#

why

surreal path
kind root
#

nah

surreal path
#

okay thats good that ur not mad

#

either way going forward nyaux wont be stuck anymore

#

and i hope to reach bash soon

surreal path
#

ive learned from my hell

kind root
#

thats good

cinder plinth
thorn bramble
#

had a similar experience once but i only witnessed it, it wasn't directed at me but my friend, there was this guy on our team and he was so bad everyone just kept flaming and insulting him but for some reason he decided to bully my friend lol

#

he found my friend's ig and tried finding more info but just ended up embarrassing himself, said he'd type some fucked up stuff to her mom but ended up doing nothing, later i found his discord and it turned out he was selling some shitty minecraft hacks to 12 year olds or something lol

surreal path
#

i kinda wanna steal the linux hashmap implmentation

#

cause i cant find any good hashmaps that work well in a freestanding c enviorment

surreal path
#

what do u guys think

cinder plinth
#

just make your own 😎

surreal path
#

nah im too lazy for that 😎

cinder plinth
#

its like

#

200 lines

#

max

#

but sure

surreal path
#

nah ima steal it :)

#

FACEBVOOK

#

fucking facebook

#

yk what

#

ill make my own

#

:)

finite summit
#

but I found some hashmap library online

#

and did some stuff to make it work

#

freestanding*

surreal path
#

lemme see

surreal path
#

i think ill just make my own

surreal path
#

forgot about hashmaps

#

ill just use a 2d array

#

no nvm

#

ill just use a slow linear array

#

idfk

#

anyone have the elf spec for x86 64

#

all im finding on google is i386

#

(32 bit)

cinder plinth
#

man elf

surreal path
#

i am not using man pages

cinder plinth
#

its the best spec

#

and why not

surreal path
#

cause i swear to god there was a better spec

#

that was for x86 64

#

and shit

#

idfk where that spec has gone

cinder plinth
#

enough to make a loader

surreal path
#

no thanks

#

ima just keep looking for the damn spec

tawdry mirage
surreal path
#

for x86 64

#

describes everything abt elf

#

all im seeing is this garbage 32 bit specs

#

there was like one like this but for x64

tawdry mirage
#

not the sysv abi pdf then

#

that only has info on x86_64 specifics for elfs

surreal path
#

yea

#

yea ik

tawdry mirage
surreal path
#

id still rather have the proper spec

#

i found this "spec" but its not rlly a pdf and more an ugly webpage

#

it is the proper spec thjo

#

ima just install dark reader cause this hurts my eyes

#

and read this one

odd summit
surreal path
odd summit
#

Oh good

surreal path
#

IT WAS SHITTY AND LIKE IT had corruption issues or something some keys went to 444????

#

and i cant get any library one working cause like

#

my free takes in size

#

as well

#

and i tried to modify the library but

#

didnt rlly work

odd summit
surreal path
#

how

#

???

#

i need size4\

#

how tf will i know then

#

hmmm?

#

how will i know if i should use my slab allocator or my vmm region allocator

odd summit
tawdry mirage
#

it shouldn't be that difficult to make your code remember the size to pass to free

tawdry mirage
#

considering it's not a stdlib free

cinder plinth
#

wish C++ could somehow make operator delete[] take a size

surreal path
# odd summit metadata

yea i have the slab metadata in the start of the page but idfk if i can trust just checking if theres a reasonable slab metadata entry at the start of the page

cinder plinth
#

I mean

#

turn delete A in operator delete(A, sizeof(A))

tawdry mirage
cinder plinth
#

I think you need to pass the size explicitly

surreal path
#

im just not gonna do a hashmap

#

simple as that

odd summit
#

Though articles on implementing malloc are a dime a dozen

cinder plinth
surreal path
#

i dont want one

tawdry mirage
cinder plinth
#

what is your use

cinder plinth
tawdry mirage
#

in the past you needed -fsized-deallocation for clang

cinder plinth
#

maybe I'm mixing it up with delete[] though?

tawdry mirage
#

but it seems that it's not necessary nowadays (at least on trunk)

surreal path
#

yk

cinder plinth
#

eh you could just use a binary search tree for that

surreal path
#

function name and address of the starting function

odd summit
cinder plinth
#

hashmap would be simpler tho

#

seperate chaining is easy af

tawdry mirage
surreal path
#

im good man

tawdry mirage
#

can sort it when generating instead of at runtime

odd summit
surreal path
cinder plinth
surreal path
#

wanna see my shit impl?

tawdry mirage
cinder plinth
#

that's simple

cinder plinth
#

rbtree

tawdry mirage
#

:^)

cinder plinth
#

no

#

b-tree

#

even better

surreal path
#

my shit hashmap impl

cinder plinth
#

(I have no idea what those are i just know they are complex (and used by xfs))

surreal path
odd summit
cinder plinth
#

might try doing XFS one day

tawdry mirage
#

select name from symbols where starting_address=$0

#

just link sqlite into your kernel for this

#

:^)

surreal path
#

anyways im going back to writing elf structs like a dumb loser

cinder plinth
#

would be doable

#

isnt there a mainstream kernel that does that tho

odd summit
cinder plinth
#

I vaguely remember Windows linking it or something, not sure if it was in the kernel

surreal path
#

oh come on

cinder plinth
#

bro

surreal path
#

WAIT

#

yep

#

im stupid

#

whoops

#

sorry

odd summit
#

What

surreal path
#

dw about it

cinder plinth
surreal path
cinder plinth
#

you should read the tutorials chicken sent honestly

surreal path
#

bro

#

😭

cinder plinth
#

would help

surreal path
#

i dont need no hashmap

#

ill do a binary search or whatever tf

#

there

odd summit
surreal path
#

dies\

#

why

#

cause like my hashmap was shitty

#

anyways its 4am

#

i think i go sleep

odd summit
surreal path
#

oh yeah whoops

#

ok fixed

surreal path
#

🤯

#

even tho

#

like bro

cinder plinth
#

you're not handling collisions first of all

surreal path
#

yea ik

#

whats the second thing

cinder plinth
#

a lot of stuff

#

your remove() does nothing

surreal path
#

i check if something exists tho?

cinder plinth
#

you're just freeing it

#

you need to remove it as well

surreal path
#

oh yeah i need set to null

#

what

#

yea

#

set to null

#

done

cinder plinth
#

and yeah the problem is likely collisions

surreal path
#

yea

#

ok ill redo the hashmap from scratch with the tutorials

#

tmrw

#

NOW WISH ME GOOD NIGHT 😡

#

i go eep

surreal path
cinder plinth
#

what

surreal path
#

say goodnight

#

or have fright

cinder plinth
#

gn

surreal path
#

gn

frigid cliff
#

what happened to rust halfmemeright

silk wind
#

ub

spice yarrow
#

it turns out writing unsafe rust like c is not a very good idea

haughty kite
#
uint64_t hash_to_index(uint64_t hash, uint64_t size) { return (((uint64_t)(uint32_t)hash) * size) >> 32; }
cinder plinth
haughty kite
#

because this is a different algorithm

#

lol

#

it does a slightly different thing

#

it still uniformly distributes the hashes

#

but it saves a division which is good

#

and it lets you use prime sized hash tables

cinder plinth
#

Ok I shall do that too then

haughty kite
#

good

molten grotto
#

is using that with a 64-bit hash worth it tho if you just discard the upper bits?

#

or well ig the hash is still better?

haughty kite
#

first, a 64 bit hash isnt that much more expensive

#

also, you use it to accelerate the equality check

cinder plinth
#

that's just a mixer function btw

#

not a complete hash function

#

you should totally embed xxhash

#

come on bro just one more dependency

haughty kite
haughty kite
#

or siphash

cinder plinth
#

I use murmurhash2a

#
/*
    MurmurHash2a, by Austin Appleby
*/
uint64_t murmur_hash(const void *key, size_t len, uint64_t seed) {
  const uint64_t m = 0xc6a4a7935bd1e995LLU;
  const int r = 47;
  uint64_t h = seed ^ (len * m);
  auto data = (const uint64_t *)key;
  const uint64_t *end = (len >> 3) + data;
  while (data != end) {
    uint64_t k = *data++;
    k *= m;
    k ^= k >> r;
    k *= m;
    h ^= k;
    h *= m;
  }
  auto data2 = (const unsigned char *)data;
  switch (len & 7) {
  case 7:
    h ^= (uint64_t)(data2[6]) << 48;
  case 6:
    h ^= (uint64_t)(data2[5]) << 40;
  case 5:
    h ^= (uint64_t)(data2[4]) << 32;
  case 4:
    h ^= (uint64_t)(data2[3]) << 24;
  case 3:
    h ^= (uint64_t)(data2[2]) << 16;
  case 2:
    h ^= (uint64_t)(data2[1]) << 8;
  case 1:
    h ^= (uint64_t)(data2[0]);
    h *= m;
  default:
    break;
  };
  h ^= h >> r;
  h *= m;
  h ^= h >> r;
  return h;
}
frigid cliff
haughty kite
frigid cliff
#

Lmao

#

If you add another zero it might just be enough for a nodejs hello world

surreal path
#

hey sorry ive been busy all friday

#

parents took me on a trip

#

we went to the cinema

#

!!!

#

well they dropped me off at the cinema

#

and then we had kfc

#

and then we went to the park

#

was fun

#

ill work on nyaux later today!

tender gorge
surreal path
#

I AM SO SORRY GUYS BUT SCHOOL

#

I STUDIED

#

ALL DAY

#

CAUSE I MISSED SO MUCH SCHOOL

#

😭

#

oki i work on hashmap now

surreal path
#

i dont understand the growing part however

#

like do u just add another entry

#

if u have a collission

#

how many buckets should u have?

#

are u able to create MORE buckets?

#

so many questions

cinder plinth
#

a bucket is a key value pair

kind root
surreal path
kind root
#

When too many collisions

surreal path
#

okay

#

i can have a collission counter

#

if it reaches 10

#

ill create a new bucket

#

good design?

kind root
#

U can always adjust the algorithm later

cinder plinth
#

every time

surreal path
#

whats the better algorithm

cinder plinth
#

bro this isnt hard just look at wikipedia

#

do open addressing + seperate chaining

kind root
#

Never look at wikipedia

#

Always spam this server with questions instead

cinder plinth
#

true

surreal path
#

not funny

cinder plinth
#

you can do a fancy tree later

#

might use a rbtree for mine

#

simple bst is fine tho

surreal path
#

seriously

kind root
surreal path
#

and i dont spam

kind root
#

For what purpose

surreal path
#

who said i spammed infy

cinder plinth
kind root
#

No one, I was making a general joke

surreal path
#

i didnt find it funny

kind root
#

Is hard to make a joke everyone would find funny

surreal path
#

fair

kind root
surreal path
kind root
#

Eh sure sorry if that sounded offensive to you

surreal path
#

oki forgiven

kind root
#

Ah, I think you're using the word bucket incorrectly

cinder plinth
#

maybe

kind root
#

Bucket would be one singular tree in this case

#

So efficiently finding the value if there are collisions so a lot of them end up in the same bucket

cinder plinth
#

yeah that

#

idk the terminology

#

i just

#

did it

kind root
#

Makes sense

#

A bucket is just like a data structure to store values that matched a specific hash, a linked list usually for a simple implementation

cinder plinth
#

yeah a linked list is good for most use cases

#

but O(n) worst case

kind root
#

Ye

cinder plinth
#

meanwhile rbtree O(log n) guaranteed

#

😋

kind root
#

All depends on what sort of values and how many of them u want to have

cinder plinth
#

ok avl tree might be better tho

#

for that

kind root
#

Sometimes u literally make a dynamic array + linear search and that ends up being faster

surreal path
#

im just gonna do seperate chaining for now

kind root
#

Basically yeah

surreal path
#

ill keep a variable of how many key value pairs are in the hashmap, if it exceeds a number

kind root
#

Especially for small objects

surreal path
#

ill add another bucket

cinder plinth
#

it's like hashmaps

#

they are O(1) best case but that 1 can be slow

#

so trees might be better in theory

#

but not in practice

kind root
#

Yeah I mean 1 just means its the same amount of time for any N, but the baseline can be very slow

kind root
surreal path
#

yea

#

basically

cinder plinth
#

if size >= capacity { capacity *= 2}

tender gorge
surreal path
#

i tried

#

im not doing a hashmap

#

this is pointless

#

thanks but no

#

:)

thorn bramble
#

what did you even need a hashmap for

surreal path
#

exactly

thorn bramble
#

no i am asking seriously

#

i wanted to know lol

surreal path
#

function name and address pairs

thorn bramble
#

for stack traces?

#

or something?

surreal path
#

yea

thorn bramble
#

you don't need a hashmap for that tbh

surreal path
#

exactly

thorn bramble
#

if you sort them you can just binary search them if you want it to be slightly faster

#

but like no need for a hashmap

surreal path
#

yea

surreal path
#

broski

#

ah yes

#

section header with type 1235125125125

#

elf signature is correct

#

like sir

#

???

#

lol

surreal path
#

okay

#

my suspesion is that

#

the calculation for the seciton in the for loop is wrong

#

which i dont understand

#

???

molten grotto
#

you are doing that

surreal path
#

i CAN SPELL

#

CANT

#

😭

molten grotto
#

wait yeah my bad I were looking at the git code, didn't realize the image had different code nvm, it wasn't even the same line

molten grotto
surreal path
#

oki

#

yea that solved it

#

thanks for spotting that

surreal path
#

lets goo

surreal path
#

i cannot even sort the fucking array

#

weird ah shit going on

#

im losing it

edgy pilot
surreal path
surreal path
#

stack traces done :)

surreal path
#

😎

#

coolness

surreal path
#

@kind root look!!

surreal path
kind root
#

congrats

surreal path
#

then vfs and file systems

#

then userspace

#

yippie!

kind root
worldly condor
thorn bramble
#

damn nyaux being worked on

#

good stuff

#

meanwhile i got a bit sidetracked and i'm building a language with a friend and i'll probably use it to write yet another kernel halfmemeright

haughty kite
thorn bramble
# haughty kite what does the language look like?

the syntax looks kind of like pascal with begin/end for blocks and an interface/implementation thing, though interface is implied and right now we're lacking any sort of class concept/object oriented programing but i think we might just add UFCS and call it a day

#

it's not really well thought out and we are improvising :^)

frigid cliff
edgy pilot
surreal path
#

bubblesort my beloved

spice yarrow
#

Do insertion sort, it's a lot faster and still simple

surreal path
#

nah bubblesort my beloved

#

wait thats selection sort

spice yarrow
#

You can't even recognize what bubblesort looks like

surreal path
#

this is bubblesort

#

😡

#

i understand bubblesort very well

#

because it is easy

#

quicksort is easy too but

#

i made it poop my array

#

and im too lazy to debug that

#

bubblesort is lit 2 for loops

#

lol

#

😭

molten grotto
#

uhda on nyaux when troll

surreal path
#

ill unironically use it if it was ready for use

#

not at this stage tho

molten grotto
surreal path
#

it wont be long now

#

few more weeks

#

timers -> scheduler -> timers -> vfs -> tmpfs -> dev devices -> elf loading -> -> driver loading -> xsave/fpu shi -> syscalls -> mlibc -> bash

#

-> more syscalls -> more and more syscalls -> unix signals? -> uhhhh

#

doom port ig?

#

wait I forgot something

#

yep

frigid cliff
#

Bogo sort

finite summit
surreal path
#

ill play val ig then

#

work on hpet

#

blah blah yk

cinder plinth
#

it will be my sidequest today

#

ok maybe not today

#

one day my OS will play pink floyd tho 😎

molten grotto
#

I mean you can always download + convert it to raw pcm using ffmpeg and then use it as a kernel module + play it inside the kernel KEKW

#

that's basically what I do for testing it

cinder plinth
#

but I cba to port uhda rn

#

I should probs port uacpi first

cinder plinth
#

then cat a file to it

#

and the uhda_kernel_pci_allocate_irq i'm not sure how to do

molten grotto
#

well it's basically just supposed to setup msi/msix/legacy irq for the device and wire it up to some cpu vector (that then calls the provided handler fn with the arg when it occurred)

#

maybe I should document them better

#

also not all of them are really necessary if you don't plan on disconnecting the device like the irq deallocate function

cinder plinth
#

ok so it should be easily portable

#

what about uhda_kernel_pci_enable_irq?

#

is that just a sti

molten grotto
#

it's for the pci device's irq (msi/msix/legacy irq enable bit)

#

its also not really necessary if you enable the irq already in the pci irq allocation function

cinder plinth
#

ah alright

#

has uhda been ported to something yet

molten grotto
#

I have it on astral and managarm locally

#

and my own kernel ofc

cinder plinth
#
uhda = subproject('uhda')

uhda_sources = uhda.get_variable('sources')
my_kernel_sources += uhda_sources

uhda_includes = uhda.get_variable('includes')
my_kernel_includes += uhda_includes
#

btw

#

why didnt you just declare a dependency

molten grotto
#

it could probably be made a dependency too, idk how would that work with the compilation flags tho (and this is also what uacpi does)

cinder plinth
#

should work fine

#
uhda = declare_dependency(sources: blabla, include_directories: blabla)
#

then you can just do something like dependency('uhda')

surreal path
#

nyaux uses makefiles so

#

yea

molten grotto
cinder plinth
#

they are

#

I have my own patch for e.g flanterm

#

that uses declare_dependency

molten grotto
surreal path
#

i have a question

#

for allocating an irq what does that mean?

#

im so confused

#

and uacpi right wants to install an interrupt handler?

#

i have to allocate an irq?

#

but what does that mean

#

and how does that work

#

also unrelated but nyaux device file icon concept

#

idfk

surreal path
desert haven
edgy pilot
surreal path
desert haven
#

Some are available for use, some are in-use by things. So if you need a vector for a device to send you an interrupt, you allocate it. Installing an IRQ handler just means "hey call this function when the interrupt is fired"

surreal path
#

nyaux logo

#

never forget

#

😡

#

anyways im gonna make install interrupt handler and uninstall

#

allocating them

#

and give them to uacpi to use

#

for whatever tf it wants

#

AFTER I SLEEP

#

CAUSE I DIDNT SLEEP

#

YET

#

AND ITS 7AM

#

💀

#

ive been awake all night

#

i was working on the hpet anyway

#

which works btw!!!

#

lapic timer AFTER i get irq allocation shit

#

then scheduler then vfs then tmpfs then device files and yada

desert haven
#

Yeah you should sleep, make sure to look after yourself

surreal path
#

@kind root i have a question, uacpi_interrupt_handler doesnt take stackframe directly so it would not be able to be installed. what do i do nooo

#

also what is ctx

#

??

#

is passed to the provided handler for every invocation???

#

huh

#

i want to impl this

#

and what am i supposed to do with handle a firmware request

molten grotto
surreal path
surreal path
#

im confused

molten grotto
#

for the interrupt, if your interrupt handler functions use a different format

surreal path
#

mhm like taking a stackframe

molten grotto
surreal path
molten grotto
#

?

surreal path
#

can u like step by step explain this

#

cause i didnt understand

#

😭

molten grotto
#

well eg. if your interrupt fn is of the form c bool irq(void* arg, irq_frame* frame); then you have some kind of wrapper eg. ```c
typedef struct {
uacpi_interrupt_handler fn;
uacpi_handle ctx;
} uacpi_irq_wrap_info;

bool uacpi_wrap_irq_fn(void* arg, irq_frame* frame) {
uacpi_irq_info* info = arg;
return info->fn(info->ctx) == UACPI_INTERRUPT_HANDLED;
}

uacpi_status uacpi_kernel_install_interrupt_handler(uacpi_u32 irq, uacpi_interrupt_handler handler, uacpi_handle ctx, uacpi_handle* out_irq_handle) {
uint8_t vec = idt_allocate();
uacpi_irq_wrap_info* info = kmalloc(sizeof(uacpi_irq_wrap_info));
info->fn = handler;
info->ctx = ctx;
*out_irq_handle = (uacpi_handle) info;
register_irq_handler(vec, uacpi_wrap_irq_fn, info);
io_apic_register_isa_irq_or_gsi(irq, vec);
}

surreal path
#

okay

#

also whats with io_apic_register_isa_irq_or_gsi for? why are we doing that

#

and whats with register_irq_handker taking in info?? huh

molten grotto
#

its the void* argument

surreal path
#

ummm

molten grotto
#

you don't have to do it exactly like this, it was just an example

surreal path
#

i have an array of function pointers like this

#

how is that gonna work

#

to put something in void * how will the assembly stub code know

molten grotto
tawdry mirage
surreal path
tawdry mirage
#

then mov isr_ctxt(%rip + %rax * $8), %rsi assuming it's the index is in rax?

surreal path
#

ill have it uacpi_irq_wrap_info *blahblah[256]

surreal path
#

cause it can be a global var

#

so no need

molten grotto
surreal path
molten grotto
#

void*

surreal path
#

okay

molten grotto
#

then the drivers and whatever can put anything they want in there

surreal path
#

kk i see

#

okay this is my function

molten grotto
molten grotto
molten grotto
#

there can be multiple devices sharing the same interrupt pin

surreal path
#

that bad or good?

molten grotto
#

well its bad because then you have to allow installing multiple irq handlers for the same idt entry + then when you actually get that irq you loop through the handlers until you find one that acknowledges the irq (and the handlers have to check if the device/other thing they are for actually generated it or not)

molten grotto
#

its a thing you run into especially with eg. legacy pci interrupts, there are only so many pci interrupt pins

surreal path
#

lol

kind root
#

its just a thing that exists

#

u only have e.g. 220 idt entries per cpu

#

there can be e.g. a thousand devices generating interrupts

surreal path
#

okay then

#

how do i know when i should allocate a cpu idt entry for a handler

#

or

#

use some same idt entry

#

??

kind root
#

well generally never

surreal path
#

what

kind root
#

the way it works in linux for example

#

it has a per-cpu structure of available idt slots

#

when something wants a slot, it loops through cpus, find the one with least slots occupied, and allocates one out of that

surreal path
#

and what if u have thousand of devices

#

generating interrupts

#

and u dont have enough

#

idt entries

kind root
#

if u have thousand of devices

#

u probably have a lot of cpus

#

so u get 220 * num_cpus slots

#

some devices still share the same physical origin, so u have to have multiple listeners on a slot

#

basically u have to think of this as detached things

#

idt entry is not the same as the irq origin

#

as irq can always be redirected anywhere

#

but the same irq can only be redirected to one place

molten grotto
#

nvm that reply lol, it wasn't related to that

kind root
#

so request_irq just fails

#

u can easily reach this limit if u have a lot of virtio devices

#

because it does a per-cpu queue

#

so per-cpu irq

#

so after about 200 virtio devices you're done

surreal path
#

so basically no idt entry can share multiple irqs

#

if u run out of idt entries

kind root
#

not multiple irqs, no

#

but one irq can originate from multiple devices

surreal path
#

yea i get u on that which wont be for me to worry about

#

all i need to do is

#

have a cpu struct of

#

how much entries i have allocated

#

and such

kind root
#

u need to care about this if u want to support legacy pci interrupt routing

#

because that only has 4 irqs for all devices on the system

surreal path
kind root
#

probably not

surreal path
#

okay

kind root
#

i wouldnt bother

#

well if u want to support older hardware

#

without MSI

surreal path
#

no i dont wanna support pci with no msi

#

that comes from

#

late 90s rihgt?

#

right*

#

if so im not doing it

kind root
#

kinda

surreal path
#

yea okay

kind root
#

u can do lspci -vvv on your pc

#

and see what has MSI and what doesnt

#

it would look like:

        Capabilities: [40] MSI-X: Enable+ Count=64 Masked-
                Vector table: BAR=2 offset=00000000
                PBA: BAR=2 offset=00000400
surreal path
#

yea all have msi x

#

well its in wsl

#

so some have null

#

for microsoft pci shit

kind root
#

lmao

#

wsl doesnt count

surreal path
#

which i dont care

molten grotto
surreal path
#

okay what im going to do for now because i dont have smp yet

kind root
#

do the same thing but pretend u only have one cpu

surreal path
#

is just allocate vec if no vec allocate no handler

#

yea

kind root
#

this is the thing i was talking about

surreal path
#

yea i see

#

dw ill figure this out and change this around as i get smp working

#

for now

#

im just gonna

#

get this working

#

oh and do i put anything into out irq handle

kind root
#

well its a thing u use to identify this specific irq if its ever uninstalled, so up to u

surreal path
kind root
#

sure

#

u can ignore it as well

surreal path
#

ill put the vec that was allocated

#

when i uninstall

#

ill allocate a int on heap

#

set it to vec

#

make the ptr in the handle

kind root
#

waiit

#

why not just *out_irq_handle = (uacpi_handle)vec

surreal path
#

oh fair

#

lol

#

what should i do with "irq"

#

ignore?

molten grotto
#

no its the actual io-apic/pic irq you have to configure

surreal path
#

uh huh

kind root
#

lol

surreal path
#

i dont have that yet

#

so im just gonna

#

not do anything

kind root
#

??

surreal path
#

yea i havent written code for the ioapic yet lol

kind root
#

u cant just ignore the irq number lol

surreal path
#

okay

#

um

#

yea no interrupt will fire but

#

:)

molten grotto
#

well you don't need that function at all unless you want events

kind root
#

if u have rebased pic its just 32 + irq

surreal path
#

no i dont have pic

#

im not doing pic

#

ill write ioapic soon

#

for now

#

ima just install the handler

#

whichll do ABSOLUTELY nothing

#

but eh

#

lol

kind root
#

could just do return ok

#

and be done with it

surreal path
#

eh nah

kind root
#

the SCI irq number is basically alyways 9 btw

#

its a universally accepted thing

surreal path
#

oop my nbad

molten grotto
kind root
#

or gnu_printf if clang

surreal path
#

trust

kind root
#

not nah

#

do it

surreal path
#

why i use kprintf to not just print numbers

#

i also print my lovely text

kind root
#

and

surreal path
#

im not making it so im required to give at least 2 parameters

kind root
#

ur not??

#

it just makes it so the format string is verified against the args

surreal path
#

oh

kind root
#

at compile time

surreal path
#

fair

#

whoops

#

gives warning

#

so what tf am i supposed to do

kind root
#

gnu_printf

molten grotto
#

printf works too

kind root
#

not on clang

surreal path
kind root
#

not the definition

surreal path
#

done

molten grotto
kind root
#

idk i remember it not working for some reason, i have these ifdefs everywhere

molten grotto
#

;compile cclang_trunk ```c
attribute((format(printf, 1, 2))) void d(const char* fmt, ...) {}
int main() {
d("%d");
}

viscid pecanBOT
#
Compiler Output
<source>:3:9: warning: more '%' conversions than data arguments [-Wformat-insufficient-args]
    3 |     d("%d");
      |        ~^
1 warning generated.
kind root
#

maybe someone else can enlighten me

kind root
#
    #ifdef __clang__
        #define UACPI_PRINTF_DECL(fmt_idx, args_idx) \
            __attribute__((format(printf, fmt_idx, args_idx)))
    #else
        #define UACPI_PRINTF_DECL(fmt_idx, args_idx) \
            __attribute__((format(gnu_printf, fmt_idx, args_idx)))
    #endif
#

the other way around

surreal path
#

works on gcc

kind root
#

gnu_printf is the gcc way

molten grotto
#

yeah warning: format ‘%d’ expects a matching ‘int’ argument [-Wformat=] on gcc with format(printf

surreal path
#

yea so it works

kind root
#

;compile

__attribute__((format(printf, 1, 2))) void d(const char* fmt, ...) {}
int main() {
    d("%d");
}
viscid pecanBOT
#
Compilation successful

No output.

surreal path
#

nvm

kind root
#

didnt seem to do anything

viscid pecanBOT
#
Compiler Output
<source>: In function 'd':
<source>:1:58: warning: unused parameter 'fmt' [-Wunused-parameter]
    1 | __attribute__((format(printf, 1, 2))) void d(const char* fmt, ...) {}
      |                                              ~~~~~~~~~~~~^~~
<source>: In function 'main':
<source>:3:9: warning: format '%d' expects a matching 'int' argument [-Wformat=]
    3 |     d("%d");
      |        ~^
      |         |
      |         int
surreal path
#

;compile cclang_trunk

__attribute__((format(gnu_printf, 1, 2))) void d(const char* fmt, ...) {}
int main() {
    d("%d");
}
viscid pecanBOT
#
Compiler Output
<source>:1:16: warning: 'format' attribute argument not supported: gnu_printf [-Wignored-attributes]
    1 | __attribute__((format(gnu_printf, 1, 2))) void d(const char* fmt, ...) {}
      |                ^
1 warning generated.
kind root
#

maybe because new gcc

frigid cliff
surreal path
kind root
surreal path
#

105 110 102 121 32 97 110 100 32 111 98 101 114 114 111 119 32 97 114 101 32 109 97 100 101 32 111 102 32 112 105 122 122 97

frigid cliff
#

Cringe decimal ascii

surreal path
#

😡

#

@hexed mango 69 20 6C 6F 76 65 20 69 74 61 6E 69 74 75 6D

#

@frigid cliff zoe i hope u become soggy pizza thats left in the microwave

frigid cliff
#

Ok well it’s in all caps

surreal path
#

wait

#

i forgot

#

to translate

#

it

#

fuck

frigid cliff
#

Wha

#

What the heck

surreal path
#

🍕

kind root
#

sometiems pizza tastes better the next day ngl

frigid cliff
#

Pizza isn’t even that good ngl

kind root
#

L take

surreal path
#

L take

frigid cliff
#

Maybe you need to burn me at the stake but it’s true

surreal path
#

chat, force her to use nyaux as her daily driver

kind root
#

ok what is your fav food

frigid cliff
#

Idk

kind root
frigid cliff
surreal path
kind root
frigid cliff
#

What rank are you even

surreal path
#

sliver 2

#

😭

kind root
#

play cs instead

surreal path
#

😡

kind root
#

its like valorant but without the cringe abilities

molten grotto
#

I like valorant more

surreal path
#

skill issue

frigid cliff
#

Cs ranking sucks tho

kind root
#

u have faceit

surreal path
kind root
#

which is also kernel level anti cheat

surreal path
#

with using ablities