#Zinnia

1 messages ยท Page 27 of 1

near tartan
#

because just casting a slice from user memory is a bad idea obviously

brisk totem
#

if you agree that you didnt hear it from me i do know how to make a DST with whatever pair pointer-sized pair of numbers you want stored in a reference to it

near tartan
#

nah i think then it's just easier to write functions in IovecIterator

brisk totem
#

yeah

#

i think linux calls this an iov_iter

near tartan
#

it's very practical because you don't need to care about whether or not a buffer is in userspace or not

brisk totem
#

just make it so that the buffer is always in userspace /hj

storm bobcat
#

That's just operator overloading isn't it

brisk totem
#

no

#

you can overload all the operators to make it kinda work

marble salmon
#

what's even the issue

brisk totem
#

although i think until we get place projections it cant quite work properly

near tartan
marsh holly
marble salmon
near tartan
#

hm?

brisk totem
#

sometimes you want to read from files in kernelmode

#

i mean i wouldnt but i can see why some people would think this is a good idea

#

its probably handy for like sockets or something?

marble salmon
#

then just read into the page cache

brisk totem
#

except there you could just make a kernel api...

brisk totem
marble salmon
#

pointers to userspace also need to remain in the same address space

#

there are just too many differences

#

you can't take the physical address of them

#

without locking memory

#

in particular, differences that imply that you need to handle them differently

#

at the site where they are used

near tartan
#

are you saying i should have different APIs for kernel vs user accesses in e.g. the VFS code?

marble salmon
#

yes

brisk totem
#

i would just not have kernel accesses

near tartan
#

i think i use it to bootstrap

#

i.e. File::read and ::mmap for init

brisk totem
#

to bootstrap what?

somber solar
#

init

near tartan
#

ok so wait

brisk totem
#

btw

#

you know that rust has a never type right

near tartan
#

yeah

brisk totem
#

you dont have to use unreachable!()

near tartan
#

where

brisk totem
#

kerne/src/syscall/process.rs

somber solar
brisk totem
#

no

#

its a bottom type

#

you can have it in a union

#

and then that case of the union is unconstructible

#

and you can match on it to construct whatever value you want

somber solar
#

monostate but better?

brisk totem
#

monostate but it behaves properly in every case ๐Ÿ™ƒ

#

wait no its not monostate

#

its an unconstructible type

#

you cannot make a value of type !

near tartan
#

-> Result<!, Errno>

#

?

brisk totem
near tartan
#

๐Ÿ‘

#

btw thanks for the reviews KEKW

#

i could use all of them

#

even if they're nitpicks

somber solar
#

pitust could you take a look at my shitty vmm when I finish it?
you seem to know stuff about it

near tartan
#

i would like to get interrupts working but idfk what I'm doing

#

especially msis with nvme

marble salmon
#

i.e., in arbitrary places instead of just function returns

brisk totem
#

yeah but nightly is better anyway

near tartan
#

i have to use nightly regardless

marble salmon
#

you don't have to use nightly

near tartan
#

you do

#

if you want to write a kernel

marble salmon
#

why?

brisk totem
#

you need a custom target spec

near tartan
#

and build-std is unstable

brisk totem
#

yeah

marble salmon
#

just patch rustc meme

brisk totem
near tartan
marble salmon
#

amazing meme

#

why can't you just use no_std?

#

and a freestanding target?

#

surely there must be a way to do bare metal apps on stable?

near tartan
brisk totem
#

and abi

#

and no prebuilt binaries

near tartan
#

and in my case i also have dynamic linking enabled

marble salmon
#

i know ppl who work with rust on bare metal in regulated industries and i'm 90% sure that they cannot use nightly

near tartan
#

maybe

#

ask them

marble salmon
#

even we use stable only at work

#

(but we don't do bare metal rust)

near tartan
#

yeah that makes sense

#

maybe they use nightly cargo and stable rust meme

#

afaik build-std is done on the cargo level

brisk totem
#

thats TOTALLY different right

brisk totem
marble salmon
#

well the difference is that the stable compiler is actually, you know, stable

brisk totem
#

not with RUSTC_BOOTSTRAP=1 it isnt

marble salmon
#

well, it's built from a stable branch etc

#

it may have nightly features enabled during bootstrap but the point is that it went through way more QA than a random nightly build

#

with random nightly features enabled

magic charm
#

i increasingly feel freebsd is doing the right thing

#

by autogenerating the de/marshalling code from SAL annotations

hybrid island
#

Now you can't forget to enforce certain preconditions, especially if you have a type system that can more rigidly enforce it like C++ and Rust

near tartan
#

@brisk totem i added smap

#

everything still works so far

brisk totem
#

nice!

near tartan
#

meme i cherry picked stuff over from the socket branch

grave peak
#

damn vgpu

near tartan
#

yeah

#

it works

#

with drm

grave peak
#

even 3d?

near tartan
#

lol no

#

dumb buffers

grave peak
#

ah

near tartan
#

you forget that i'm not goated

grave peak
#

tfym

#

3d soon

near tartan
#

UserSlice

grave peak
#

u can always verify user crap later

near tartan
#

i really want to get sockets working with a cool rust abstraction

grave peak
#

3d is where its at

near tartan
#

but i can't think of anything

#

i have this shit rn

#

console=/dev/fbcon seems to work

grave peak
#

is this a bash port or just fastfetch

near tartan
#

just fastfetch

#

bash works but there's no input yet

grave peak
#

ah

near tartan
#

i totally forgot zinnia has a working nvme driver

#

i did console=/dev/nvme0n1

grave peak
#

what does console= do?

near tartan
#

opens a file for stdin/out/err for init

grave peak
#

oh

brisk totem
near tartan
#

currently the only "safe" way of accessing user memory is through UserPtr

#

which handles SMAP and page faults

brisk totem
#

yeah good

near tartan
#

are there any important cases where having the same API for kernel and user memory is useful? (cc @marsh holly since you have code for iovec_iterator_t in the VFS)

storm bobcat
#

what is iovec

near tartan
#

#include <sys/uio.h>

hoary cave
#

scatter gather

brisk totem
#

like in socket code MAYBE

#

and in elf loading code

near tartan
#

yeah currently i only have it in elf loading code really

storm bobcat
#

just realized

#

there are a bunch of names here that start with Z

#

nvm no there arent

#

we're the only two

near tartan
brisk totem
#

but for the elf code you can just load a flat binary

#

and then have it be the real elf loader

#

aka the vdso loader route

storm bobcat
#

do your elf loading in userspace

#

like a man

near tartan
#

no

#

i am a pussy

hoary cave
#

kityt

near tartan
hoary cave
brisk totem
#

get some help then

near tartan
#

i have rebased most of the patches from the socket branch onto main

#

(minus the big vfs changes)

#

this afternoon i want to actually get some shit done

#

let's see...

#
  • switch to iovecs
#
  • rebase the vfs changes
#
  • port rust std
#

std will be the most annoying part i think

storm bobcat
#

now that you switched back to rust I dont fw this project anymore

#

๐Ÿ˜ข

near tartan
#

it's over

lofty copper
near tartan
lofty copper
#

Or like it's annoying, but not too difficult

near tartan
#

sure

#

i need to do the mlibc definitions too

#

sadly I can't use a generator so ig i do it by hand

#

i could make an abi checker maybe

lofty copper
#

Managarm is mainline

#

Just steal from there trl

near tartan
#

but not mlibc

#

managarm isn't unix

#

managarm is linux_like

lofty copper
#

Huh

near tartan
#

yeah

lofty copper
#

Then idk

#

There's a bunch of other unix-like operating systems

near tartan
#

maybe haiku

lofty copper
#

Also, most of it is abstracted away anyway?

lofty copper
#

Redox

near tartan
#

the problem for me is libc

#

i have the base std done

#

i just need libc

#

but all structs and functions in there are random

somber solar
#

it can either hold kernel or user pointer

#

I use it for my vfs methods

#

of course every read and write is checked

near tartan
#

i wonder if it's enough to make the iovec iterator thingy in a way that can't be Copy, Clone, Sync, Send

#

that would mean the only way that struct can be safely constructed is if it's pointing to an address in the active address space

hoary cave
#

Alright

near tartan
#

because you can't send it to another thread, everything stays contained

#

ofc you can construct raw iovecs from thin air at all times

#

they just don't carry any meaning since you can't do I/O with them safely

hoary cave
#

so what is the use for an iovec if you can't do io on it

#

that's the only use for it

near tartan
#

you use it with the iovec iterator

#

you pass a list of iovecs to this iterator struct, which allows you to do reads and writes

#

the raw iovec is meant as something like an FFI

#

and the iterator is a safe wrapper around it

hoary cave
#

okay

near tartan
#

@hoary cave i got further with iovec

#

read and write now uses it

late bramble
#

Womenix

near tartan
near tartan
#

i should figure out serial interrupts

#

this is like the most basic ass form of input

#

i need to see if the coreutils do their shit right

somber solar
#

Womenix

neon flicker
#

Womenix

near tartan
modern hamlet
#

meaning you need to setup IOAPIC and stuff

#

unless you have a PCI serial device

near tartan
#

do i need to parse acpi tables for ioapic configuration

modern hamlet
#

yes im pretty sure you do

#

luckily you dont need to know how to do aml

near tartan
#

do i need to configure the pin polarities?

modern hamlet
#

4 different types of headers

near tartan
#

wut

somber solar
#

it's not that hard

modern hamlet
near tartan
modern hamlet
#

i believe it was astral but not sure

near tartan
#

i have discovered the ioapic and i have code to configure it

#

ig im just missing the setup

somber solar
near tartan
#

I've got an idea

#

I'm going to make Zinnia BSD-like

#

it already has a BSD license and some BSD ioctls

#

most of the work will be getting BSD functions into mlibc

marsh holly
near tartan
#

nah

#

i could, but i explicitly want to help with mlibc

#

because i believe it's a project that benefits way more people than a shitty hobby kernel

median forge
near tartan
near tartan
#

@somber solar

#

what is this

somber solar
#

where

#

oh

#

pic thingy

#

that connects the two pics

#

I don't remember the name

near tartan
#

ohhhh

#

yea i masked the pic completely

#

is that bad?

somber solar
#

nope

#

you should do that if you use ioapic

near tartan
#

k

grave peak
#

linux only unconditionally masks if doing x2apic + iommu

near tartan
#

wait so

grave peak
#

otherwise it masks per pin

#

when enabling a specific ioapic interrupt

near tartan
#

what am i even supposed to do here

#

your code reads like there are no GSI overrides if PIC is disabled

somber solar
#

I think you need to unmask irq 2 in pic even with ioapic

grave peak
#

if u want to be able to use pic as a fallback

near tartan
#

i dont

somber solar
near tartan
#

oh

#

hm

#

well like i said i just want to get com1 interrupts

#

idfk how

somber solar
#

I have code for that too

#

wait a sec

spark surge
near tartan
#

why

#

3

spark surge
#

because on base revision 5+ Limine will mask the ExtINT LVT in the local APIC(s) which means that masked or not masked, you're not gonna get PIC interrupts

#

in any case it's fully masked, in any base revision

spark surge
#

masking ExtINT is the "proper" way to disable the PIC

#

per se

grave peak
#

๐Ÿ˜ญ

somber solar
#

:P

#

how do I do that?

spark surge
#

imagine not assuming that ISA peripherals just exist

near tartan
#

i need to write a uacpi driver wrapper

#

i dont like the way uacpi does discovery

#

but that's bound to C ig

#

@somber solar irq_swtich

spark surge
somber solar
spark surge
#

you should do both anyways

near tartan
somber solar
#

indeed

near tartan
#

@grave peak have you considered removing anon structs and unions from uacpi headers

#

:3

grave peak
#

Which

spark surge
#

this

near tartan
#

it's not an issue at all but it makes codegen a bit ugly on langs that don't have it

spark surge
#

using enums in C is stupid

near tartan
#

example

spark surge
#

even more so on public interfaces

grave peak
spark surge
#

oh fuck

#

i hallucinated, sorry

#

still, it applies i think :p

near tartan
spark surge
#

real

grave peak
#

Nah enums aren't going away

spark surge
#

:(

grave peak
#

For anon structs ill think about it

near tartan
#

i'm only talking about anonymous types

spark surge
#

why do you like enums

#

in C

#

real q

near tartan
#

what's the problem with enums?

grave peak
#

Just a clearer intent when reading code, instead of int thing

near tartan
#

especially in c23 they're good

grave peak
#

Yep

spark surge
#

yeah in C23

#

but like

near tartan
#

nobody here isn't using that

spark surge
#

what person making libraries is targeting C23

#

especially source libraries

near tartan
#

i've never had issues with enums?

somber solar
near tartan
#

even before c23

grave peak
# near tartan example

Cant you like make a custom helper or just tell zig the struct contains one item that you want instead of using raw bindings?

spark surge
#

you can use enums, just not in public interfaces, that's my take, but whatever, irrelevant here

grave peak
#

Why not?

spark surge
#

wait, zig?

near tartan
#

rust

#

nobody writing c89

grave peak
#

Oh thats rust, even worse

spark surge
#

not C89 but usually something like C99 or C11

near tartan
#

both have enums?

#

what's the problem with it lol

grave peak
#

@near tartan I could add like a no_anon_struct define, would that help?

near tartan
#

how would that look

grave peak
#

Ifdef no_anon_struct { field } else union { field1, field2, field3 }

#

Something like that

spark surge
near tartan
#

that would cover all cases

spark surge
#

you can give types to defines but not to enums

#

enums are always int

grave peak
spark surge
#

(not in C23 but whatever)

grave peak
#

Does it not?

near tartan
grave peak
#

Cuz then u have to have a name for the member, which means u have to add a tbl.thing.ptr

near tartan
#

wut

#

no?

spark surge
#

i think infy is right

grave peak
#

Yep

#

Adding a name means u can no longer access members directly in C

spark surge
#

yeah

grave peak
#

Which makes all C code as ugly as your rust code

spark surge
#

yeah, i'd be against making unions/structs named

grave peak
#

Barring that, it just breaks literally all users

#

So that's a bit too much

near tartan
#

oh

#

god fucking damn it

#

i hate C

spark surge
#

removing enums won't :p

grave peak
#

But putting that behind an ifdef is fine perhaps

spark surge
#

i hate C too <3

near tartan
grave peak
#

Why lol, u can just pass it to rust

#

And you will have no ugly names

near tartan
#

no?

grave peak
#

No what

near tartan
#

you have the same issue then lol

grave peak
#

?

spark surge
#

@grave peak don't tell me there isn't some instance where you wish you could have typed enum members

somber solar
#

sleep marvin

grave peak
#

You will have tbl.ptr

#

In rust

spark surge
#

barring C23 of course

grave peak
#

It supports openshitcom etc

somber solar
#

lol

spark surge
#

tf

#

oh

#

watcom

near tartan
#

oh wait lol

grave peak
#

marving trolling today

near tartan
#

im mad okay

spark surge
near tartan
#

i'm pissed off that i can't figure out how to properly setup the ioapic

spark surge
#

not to mention that having functions take enum parameters or return enums is kind of a meme in C as well

spark surge
#

if you need them to be typed

grave peak
#

or u could just do enum : type meme

spark surge
#

that is C23 only

#

or C++

#

so that's a no-go

#

if you care about compat

near tartan
#

i should make myself a uacpi wrapper

storm bobcat
#

write your own aml interpreter

somber solar
#

uacpi C++ modules support when

grave peak
# somber solar <@353593948523986945> I couldn't find any info about it iirc
Device (UAR1)
{
    Name (_HID, EisaId ("PNP0500") /* Standard PC COM Serial Port */)  // _HID: Hardware ID
    Name (_UID, One)  // _UID: Unique ID
    Name (_DDN, "COM1")
    Method (_STA, 0, NotSerialized)  // _STA: Status
    {
        If ((FUIO (Zero) != 0x0F))
        {
            Return (0x0F)
        }

        Return (Zero)
    }

    Method (_CRS, 0, Serialized)  // _CRS: Current Resource Settings
    {
        Name (BUF0, ResourceTemplate ()
        {
            IO (Decode16,
                0x02E8, 
                0x02E8,
                0x01,
                0x08,
                _Y2C)
            IRQNoFlags (_Y2D)
                {3}
        })
        CreateByteField (BUF0, \_SB.PCI0.UAR1._CRS._Y2C._MIN, IOLO)  
        CreateByteField (BUF0, 0x03, IOHI)
        CreateByteField (BUF0, \_SB.PCI0.UAR1._CRS._Y2C._MAX, IORL) 
        CreateByteField (BUF0, 0x05, IORH)
        CreateWordField (BUF0, \_SB.PCI0.UAR1._CRS._Y2D._INT, IRQL)
        Local0 = FUIO (Zero)
        Switch (ToInteger (Local0))
        {
            Case (Zero)
            {
                IOLO = 0xE8
                IOHI = 0x02
                IORL = 0xE8
                IORH = 0x02
            }
            Case (One)
            {
                IOLO = 0xF8
                IOHI = 0x02
                        IORL = 0xF8
                        IORH = 0x02
                    }
                    Case (0x02)
                    {
                        IOLO = 0xE8
                        IOHI = 0x03
                        IORL = 0xE8
                        IORH = 0x03
                    }
                    Case (0x03)
                    {
                        IOLO = 0xF8
                        IOHI = 0x03
                        IORL = 0xF8
                        IORH = 0x03
                    }

                }

                IRQL = (One << (FRUI (Zero) & 0x0F))
                Return (BUF0)
            }
        }

Some examples from real hw

somber solar
#

I don't speak aml lol

#

PNP0500

grave peak
#

PNP0500 + uacpi_get_current_resources

storm bobcat
#

huh kinda funny they have an IRQL field

grave peak
near tartan
#

yeah

#

oh wait

#

no

storm bobcat
#

what does the switch case do? is FUIO the thing you pass in to find a port

#

i mean

#

is Zero the first parameter or something

grave peak
#

it is yes

#
Method (FUIO, 1, Serialized)
{
    If ((IER0 == One))
    {
        If ((WUR0 == Arg0))
        {
            Return (Zero)
        }
    }

    If ((IER1 == One))
    {
        If ((WUR1 == Arg0))
        {
            Return (One)
        }
    }

    If ((IER2 == One))
    {
        If ((WUR2 == Arg0))
        {
            Return (0x02)
        }
    }

    If ((IER3 == One))
    {
        If ((WUR3 == Arg0))
        {
            Return (0x03)
        }
    }

    Return (0x0F)
}
#

its some internal firmware code

#

who knows

storm bobcat
#

ah ok so you call that function to get the port

grave peak
#

only stuff prefixed with _ is public API

storm bobcat
#

bruh

near tartan
#

duh

somber solar
grave peak
#

@somber solar serial devices in aml also often times have possible_resources() and set_resources() so u can choose any IRQ u want and any IO port you want

#

out of the supported values

somber solar
#

nice

#

well I know what I'm doing next

grave peak
#

not all hw has it but yeah

somber solar
#

tlb shootdown can wait

storm bobcat
#

so what device can you actually assume is present for early logging lol

somber solar
storm bobcat
#

I chose serial because at least on real hardware it might actually exist vs debugcon

grave peak
#

in hypervisors u can test for 0xE9

somber solar
#

can you just write to com1 and hope it exists?

grave peak
#

u can try that

storm bobcat
#

implement a log buffer

#

and log when u find a port

grave peak
#

^

storm bobcat
#

in fact infy is implementing uLog as we speak

somber solar
#

hmmm

somber solar
#

really?

grave peak
#

straight up lies

storm bobcat
somber solar
#

lol

spark surge
#

well, sort of, rather, you can check if it exists

grave peak
#

if anything he should make one instead

spark surge
#

without AML

storm bobcat
#

who, me?

grave peak
#

ofc

storm bobcat
#

just convert my zig back to C++

grave peak
#

your ring supports 32 bit

storm bobcat
somber solar
#

okie

#

gonna get inspired

storm bobcat
grave peak
#

zig to C bindings

spark surge
#

ring?

storm bobcat
#

since I can do u<arbitrary> so I do u<usize bits - 2>

somber solar
#

even more pnps PNP0500 PNP0501 PNP0510 PNP0511

grave peak
#

yeah theres a few

somber solar
#

if only you could have that many ways of detecting pit

spark surge
#

here's the thing: for ISA devices you can assume that they are either where you'd expect them to be, or they are not, but there's not going to be something else in their place

#

that's just not a thing that happens

storm bobcat
#

yeah thats why I opted for com over debugcon

spark surge
#

so you can test if they are there with readbacks/init and whatnot

grave peak
#

yeah they're scared af to break nt boot

somber solar
storm bobcat
#

well I suppose I could setup detection

#

afaik e9 is easy to do

somber solar
#

you just read from it

storm bobcat
#

yea

grave peak
#

e9 detection is in(e9) == e9 lol

storm bobcat
#

well

#

in_hypervisor && in(e9) == e9

grave peak
#

ye

spark surge
#

tbf i don't think there is much of an advantage to using e9 once you have com anyways

somber solar
grave peak
spark surge
#

yeah

#

just checking the e9 readback is enough

#

imo

somber solar
spark surge
#

never

grave peak
#

this is for detection

spark surge
#

on real hw (and probably emulators/qemu)

grave peak
#

yeah but if there's something else at that port you may cause side effects

spark surge
#

unlikely

grave peak
#

still possible

#

but yes

#

its not like a standard isa port or anything

spark surge
#

that's why you don't use e9 if you have com :p

somber solar
#

can one detect absence of pit?

grave peak
#

no

#

well only by probing it

spark surge
#

yeah by probing, but like

#

that's not enough

#

for example ARL has a PIT but it's clock gated by default

#

most probing mechanisms would tell you there is a PIT there

grave peak
spark surge
#

but if you wait for it to tick, it never will

#

because it's clock gated

near tartan
grave peak
#

i mean who needs it for anything other than calibration

spark surge
#

so yeah, no, heuristics are a better approach

grave peak
#

so would ifdef help you then?

spark surge
#

e.g. you can assume there is a PIT if a machine is old enough to not have e.g. invariant TSC

somber solar
#

I should mask pit if something else is used

modern hamlet
spark surge
#

like the IRQ? yes. ideally you should have all IRQs/GSIs masked unless you need them lol

grave peak
somber solar
#

lol

near tartan
#

just ignore it

grave peak
#

bruh

#

cant u pass c flags from rust?

#

also theres proper bindings being worked on anyway so

spark surge
near tartan
spark surge
#

the only thing that is not masked as per spec are MSIs which are left as firmware set them up, but that is usually all masked as well

grave peak
#

how lol

near tartan
#

i still have to type the whole path

#

it's not like C where it skips anon structs

#

or not

grave peak
#

not if i get rid of the union entirely

#

if that define is passed

somber solar
near tartan
#

but i want the union?

#

i dont get it

grave peak
#

oh ok if u want it then yes

spark surge
#

it would waste memory

#

but it would work

grave peak
#

i was thiking u have to cast it from rust anyway

#

could just be a void pointer

near tartan
#

not talking about the cast

#

the field name

grave peak
#

if u have to do the cast anyway u can just have one single field and no need for a union

#

the entire idea of a union is to minimize the number of casts required

near tartan
#

it's not so deep

grave peak
#

๐Ÿ˜ญ

spark surge
#

ah i thought you wanted to just not use a union if you passed that define

somber solar
#

okay so I think I'll:

  1. dump everything to com1 until table access
  2. check for spcr/dbg2 when tables are available
  3. evaluate pnps once acpi is initalised
spark surge
#

like, and have multiple fields instead

near tartan
#

LIMINE_PTR(x) meme

grave peak
#

it can have multiple fields if marvin really wanted to

near tartan
#

i dont care anymore :3

spark surge
#

like as i said, it's a bit more wasteful, but it would also be similar enoughโ„ข

#

but a void ptr or something would also work ig

grave peak
#

marvin probably regrets bringing it up KEKW

near tartan
#

yeah

somber solar
#

lol

near tartan
#

this isn't useful

grave peak
#

at least with that option u can have a readable prefix

#

in your builder thing i mean

#

rust doesnt have anon unions at all right

somber solar
#

c just can't stop winning trl

near tartan
grave peak
#

why is it useful to know what system you're running on?

near tartan
storm bobcat
#

why does it matter what the bios vendor is

storm bobcat
#

like just have a log buffer

grave peak
storm bobcat
#

do you find it via uefi

#

is that code upstream

grave peak
#

Same as rsdp

grave peak
storm bobcat
#

your smbios code

grave peak
#

In the pr that's open

storm bobcat
#

why do you do prs

#

on your own

grave peak
#

CI

#

Limine has a way to request smbios tables I think

storm bobcat
#

do you do it with hyper?

grave peak
#

Yes

storm bobcat
#

im trying to depend as less as possible on the bootloader but that kinda stuff is optional anyway so I think I will depend on it for that

near tartan
#

for what?

grave peak
#

Well in bios mode u can find smbios yourself

near tartan
#

smbios?

grave peak
#

In UEFI mode its in the configuration table same as rsdp

#

So it requires boot services

storm bobcat
#

yea

storm bobcat
#

what is smbios useful for though

#

what kinda stuff can I do

grave peak
#

this is the main use case

near tartan
#

it can tell you about the chassis type, installed memory modules

#

stuff like that

grave peak
#

just run sudo dmidecode to get an idea

near tartan
#

it can tell you stuff about a specific dimm

storm bobcat
#

i will crash if the manufacturer is not crucial

somber solar
near tartan
#

should the kernel have a generic way of allocating msis?

#

considering drivers using msis are also generic

near tartan
#

But not for platform IRQs right?

#

or that too

modern hamlet
#

On x86_64 I think you have all the flexibility you can get

#

You can even remap legacy IRQs onto any vector

#

So IRQ 0 you could map to vector 0xAF or whatever for example

near tartan
#

and then what

modern hamlet
#

?

near tartan
#

what's the difference to other archs

modern hamlet
#

other archs might not have nearly as much flexibility

#

e.g. x86 without apic has fixed legacy IRQ numbers which you cant change

near tartan
#

makes sense

near tartan
#

it's no

#

right?

modern hamlet
#

so i guess generic to drivers? yes

#

generic to platforms? not really

modern hamlet
near tartan
#

idk im stupid

#

irqs that aren't msis

modern hamlet
#

well yeah

#

also you'll want such a feature if you implement irq priority levels using the TPR/cr8

fiery marlin
#

are you only planning to support x86?

modern hamlet
#

since those block interrupts depending on the interrupt vector number

near tartan
#

no

modern hamlet
#

e.g. a TPR of 0x8 blocks interrupts with numbers 0x00-0x8F

fiery marlin
# near tartan no

ok, so far what I'm thinking is that a generic api for allocating interrupt lines (of any kind, msi or something else) is useful for drivers, but the implementation really depends on the platform and interrupt controller configuration.

near tartan
#

yeah figured that much

fiery marlin
#

there's a paper that fadanoid(?) linked recently that I thought was really interesting for this, I dont know if you read it

near tartan
#

should be doable

#

i can make allocating int lines a archdep

marble salmon
#

I think anybody who wants to design a proper IRQ abstraction needs to look at multiple architectures and IRQ controllers since they are all different

#

You cannot look at x86 and extrapolate from there

fiery marlin
#

yeah

marble salmon
fiery marlin
#

I have made that mistake in the past

fiery marlin
marble salmon
#

All of these assumptions are wrong:

  • IRQ routing is fixed / constrained and not fully dynamic
  • IRQ routing is fully dynamic
  • The CPU has a concept of an IRQ vector number
  • The device has a concept of an IRQ number
  • The interrupt number that the device uses matches the one on the CPU side
  • There is only one IRQ controller between the device and the CPU
  • MSIs are sent directly to the CPU
  • You need to send EOI before handling the IRQ
  • You need to send EOI after handling the IRQ
  • IRQs are either edge or level
  • The kernel knows if IRQs are edge or level
  • All IRQs have the same priority
somber solar
storm bobcat
#

In zig they're useful because you don't have to use masks

#

But Linux does

near tartan
#

finally have working serial with interrupts

#

somehow this broke lol

#

yay

near tartan
#

i'm rewriting zinnia in C++ and i'm doing linux abi compat

somber solar
storm bobcat
#

Ah fuck April fools

near tartan
#

:)

storm bobcat
#

Unironically do that tho

near tartan
#

in another life

#

that's just fishix tbh

grave peak
#

that would be the good choice tbh

grave peak
#

fishix is a speedrun

somber solar
#

ilobilix :P

near tartan
#

see i want to do bsd source compat

grave peak
#

its not focused on quality etc

near tartan
#

i think it's cool

#

now that i can actually interact with my kernel i think i can test it much better

#

i need to add tty discipline

storm bobcat
near tartan
#

a bit of everything

#

maybe netbsd

storm bobcat
#

why

#

do freebsd

grave peak
#

yeah out of all bsds

near tartan
#

what's the diff

grave peak
#

at least pick the popular one

storm bobcat
#

as much as I love netbsd

#

just do freebsd

near tartan
#

ok

storm bobcat
#

well nvmm is saner tho

#

So I'd do freebsd + nvmm

near tartan
#

yeah

somber solar
grave peak
#

what is nvmm

near tartan
#

kvm but good

grave peak
#

abi means u can cp native programs

storm bobcat
somber solar
storm bobcat
near tartan
#

i want to do bsd + mlibc

storm bobcat
#

It's really nice and simple

#

And qemu supports it

grave peak
storm bobcat
#

unlike freebsd jails

storm bobcat
near tartan
#

the thing is, because i'm not claiming to be literal freebsd, i can do whatever i want and pick my favorite APIs from everywhere

storm bobcat
#

I'm not cloning anything in particular

grave peak
near tartan
#

nah

#

im gonna remake that gif with linux abi compat

grave peak
#

lol

storm bobcat
#

freebsd has Linux Abi compat

#

Buzz Lightyear meme

near tartan
#

lol

grave peak
#

linux abi compat used to be a novel concept

somber solar
grave peak
#

but everyone stole it from me

somber solar
#

who else does it?

grave peak
#

๐Ÿ˜ญ

storm bobcat
#

!

#

Like two years ago

grave peak
#

damn

somber solar
grave peak
#

probably because it didnt exist

somber solar
#

this rewrite is a bit more than a year old

grave peak
#

has it always been linux compat?

somber solar
#

yes

#

but this is the only "successful" one

grave peak
#

ah ok

somber solar
#

I was using mlibc before this rewrite

near tartan
#

i'm doing a mix of everything
drm + evdev + nvmm + posix_devctl + epoll + bsd style device management

somber solar
#

and pe instead of elf

grave peak
#

is nvmm better than kvm?

#

also is that different from bhyve

near tartan
storm bobcat
near tartan
#

streaks implemented it in ironclad and says it's also better

#

or mint idr

storm bobcat
storm bobcat
grave peak
#

is bhyve like part of that or

storm bobcat
#

No bhyve is freebsd's own thing

#

arguably they should've just adopted nvmm

grave peak
#

ohh nvmm is netbsd

near tartan
#

yea

grave peak
#

and bhyve is freebsd i guess

storm bobcat
grave peak
somber solar
#

average open source project trl

grave peak
#

sure its simpler but its not something ud want for production

near tartan
#

another funny thing about being a bsd is devd with a non aids API

#

(netlink)

storm bobcat
#

But like it is pretty good from what I've heard

grave peak
#

is it supported by qemu also?

grave peak
near tartan
#

mitosis

somber solar
#

lol

near tartan
#

opened a pr to mlibc to drop menix

#

(and rename to zinnia)

grave peak
storm bobcat
storm bobcat
hoary cave
#

im cooked

storm bobcat
#

diddybsdm

drowsy tendon
#

diddybdsm troll

near tartan
#

@marble salmon btw the solution was to turn on interrupts in syscalls meme

#

it's the reason the serial interrupt didn't arrive in the kernel

#

because it did fire in qemu

#

my ioapic code was mostly fine already nooo

somber solar
near tartan
#

yes

#

i have an IrqLock

#

but it assumes that a level of 0 == interrupts are enabled

somber solar
#

mine is also broken. it assumes that the last thing unlocked was the first locked

#

gotta fix that

near tartan
#

lol

#

well in my case the mask for syscall doesn't have 0x200

#

so i have to manually enable interrupts in the handler

somber solar
#

idr

near tartan
#

SFMASK

near tartan
#

anyways, now that i can get interrupts routed and send input to user programs it's time to tackle ttys and ptys

near tartan
#

finally fixed mounting

#

i still need to do the tty shit

#

i want to fix some things that i had stubbed out for way too long

#
  • Signals
  • Process groups
  • devctl instead of ioctl
  • ext2
  • fix mount and chroot
#

speaking of, how does one go from initramfs to rootfs? i know linux has pivot_root, but how is this usually implemented?

#

my idea would've been to just mount the rootfs and chroot into it from init

#

but idk if dinit can cope with that

#

maybe I'll just switch back to openrc

median forge
near tartan
#

oh true

marble salmon
#

chroot is fine for this use case in general

#

pivot_root is a hack IMO

near tartan
#

yeah it feels like it is

marble salmon
#

it predates bind mounts which can solve this more cleanly

near tartan
#

so i guess my initramfs "init" is just a simple mount + chroot + execve

marble salmon
near tartan
#

HOLY SHITTTTT

near tartan
#

bro ๐Ÿ˜ญ

somber solar
near tartan
#

i hate my life

#

i forgot to swap out the raw CStrs in execve

#

that's why its dying

#

i think

near tartan
#

yeah that's it

#

great

near tartan
#

i'm now loading modules from userspace

near tartan
near tartan
#

you can now mount partitions by their partuuid

somber solar
near tartan
#

it is

#

just points to the partition device

somber solar
#

why not use /dev/disk/by-partuuid :P

near tartan
#

i dont like subdirs

#

i also have /dev/drmcard0

grave peak
brisk totem
#

my favorite

near tartan
brisk totem
# near tartan idk how else to do it <:meme:1386427600980934706>
u8 source[] = {0x53, 0x2c, ..., 0xed};
struct zn_mount_op mount_op = {
  .fstype = ZN_FS_EXT4,
  .target = "/tmp", .target_len = 4,
  .source_type = ZN_MOUNT_BY_PARTUUID, .source = source, .source_len = sizeof(source)
};
if (zn_mount(&mount_op) != 0) { perror("zn_mount"); return 1; }

ur welcome

near tartan
#

that's not very ergonomic

#

what if you don't want to mount anything

#

you just want to open the device

brisk totem
near tartan
#

io?

brisk totem
#

yeah i mean like what io

#

creating and managing partitions?

#

you can do that with a kernel api ๐Ÿ™ƒ

near tartan
#

๐Ÿ’€

#

that's dumb

brisk totem
#

you need to sync against the kernel

near tartan
#

not really

#

in what case

brisk totem
#

well i guess you dont need a lot of sync

#

you could just tell the kernel to rescan partitions or smth

near tartan
#

for a bit i'll stop working on this to focus on doing mlibc work

nocturne rampart
near tartan
nocturne rampart
#

/dev/pts/67

#

I don't like it either

near tartan
#

fixed the ext2 memes

somber solar
near tartan
#

lol

somber solar
#

fix yo getdents

near tartan
#

yeah

#

that's tmpfs ๐Ÿ˜ข

#

yay

near tartan
#

unfortunate

#

even more unfortunate

#

i really want sockets

near tartan
somber solar
near tartan
#

yeah i renamed it to fbcon

#

the tty1 was a test

somber solar
#

console is still linked to it :P

near tartan
#

oops

somber solar
#

you probably still want /dev/tty

near tartan
#

yea ofc

#

but it's fake rn

hybrid island
#

how is the marv

#

is the zinnia working?

near tartan
#

i'm doing ttys right now

hybrid island
#

cool

near tartan
#

it's kind of working

#

i have ext2 now

#

and signals

hybrid island
#

I'm doing UVM-style VMM for BadgerOS ATM

near tartan
#

nice

hybrid island
#

Still some bugs to iron out

near tartan
#

i can start gcc now :3

hybrid island
#

After that I'm going to do IoKit-like device rewrite

near tartan
hybrid island
#

lmao

#

that's not arch meme

hollow hedge
hybrid island
near tartan
#

very productive day today ๐Ÿ˜ƒ

#

i can even start openrc now

#

somewhat

#

once i figure out unix sockets we can do xorg

#

@magic charm iirc you did something with keyronex udp sockets and xorg

near tartan
#

todo for today

  • check ppoll impl for bash input
  • implement get/setresid, deprecate the individual setid syscalls
  • finish ttys
  • unix sockets
magic charm
near tartan
#

how was that set up? running the server on linux?

magic charm
#

Xorg on keyronex and apps on Linux

near tartan
#

ah

#

that's cool

#

i have no idea how to even start with sockets tbh

#

i have no resources

brisk totem
#

how is it that literally everyone is doing advanced shit

#

and im still failing at baby allocator implementation

near tartan
#

bro have you seen ANY of my impls

#

it's the most cursed dogshit ever

brisk totem
#

yes but you have userspace

near tartan
#

ok and

brisk totem
#

and i have a hello world tier kernel without an allocator

#

is the solution to just not do good impls then

bc if so then thats lame

near tartan
#

korona said something about that as well

#

"make it exist first, then make it good"

#

and i mean my impls aren't the worst

#

they're above average i guess

past leaf
#

and im stuck in a loop trying to do a page cache before i refactor the kernel ๐Ÿ˜ญ

brisk totem
#

right now i didnt even get to a page cache

past leaf
#

it's literally a year that i say i have to do it

brisk totem
#

im refactoring my allocator rn

past leaf
#

and i never get to do it

brisk totem
#

but my old allocator was garbage

past leaf
#

turns out a 4kloc syscalls.c file is not the best design ever

near tartan
#

my vmem allocator for userspace is a bump allocator KEKW

past leaf
#

that's a good idea tho

#

for 64bit

brisk totem
#

i mean true

near tartan
#

yeah i have enough virtual space so shrug

brisk totem
#

personally id just have libc choose the address

past leaf
#

like, even if you allocate 1GB/s

brisk totem
#

and then only do MAP_FIXED in kernel mode

past leaf
#

it's literally 2 days of uptime

near tartan
magic charm
brisk totem
# brisk totem and then only do MAP_FIXED in kernel mode

thats what im gonna do for my kernel bc easier (well im doing MAP_FIXED_NOREPLACE because posix sucks, i want to do strict accounting, making an allocator that refuses to take memory back is fucking insane, and while you can make failure-free munmap/mprotect work its really fucking annoying)

past leaf
#

yes

magic charm
#

Either vol 2 or vol 3 even specifically has a section on unix domain sockets

brisk totem
#

a unix domain socket is just a duplex pipe + duplex fd passing, right? (with some extra headers to make the two line up right)

#

so if you dont care about quality of impl, you can just make a pipe of messages where each message owns the data inside

magic charm
brisk totem
#

and to optimize this you can store a range over a data ring instead of a separate alloc

near tartan
#

damn

#

maybe i CAN implement sockets this week

brisk totem
#

hmm. i wanted to make a bitmap for tracking which objects within my slab allocator are in use, but it kinda sucks to reserve 512 bytes from each zone for a bitmap, when almost all objects in practice are big enough that you wont use all of it

magic charm
#

Xorg certainly doesnt demand much and can live without cmsg support and the like

brisk totem
#

i guess its still less than 1% overhead

past leaf
#

i think i got this from keyronex

brisk totem
past leaf
#

mitshm-using applications dont really write much data to the socket

#

xterm is an absolute hog tho

brisk totem
#

xterm is cringe anyway so it doesnt matter

#

me when unicode

storm bobcat
#

rn I have a classic slab thing but I wanna improve it

#

One thing I can immediately think of is having alloc and free magazines

brisk totem
#

slab with magazines basically

#

lol

storm bobcat
#

yeah I already do that

brisk totem
#

and i dont have anything ๐Ÿ™ƒ

storm bobcat
#

What's a bit annoying is the hashmap

brisk totem
#

why do you need a hashmap?

storm bobcat
#

For large slabs you need one to convert an object pointer to its bufctl

brisk totem
#

or you can just not have large slabs ๐Ÿ™ƒ

storm bobcat
#

they're useful but not that common

brisk totem
#

idk are they useful

storm bobcat
#

in vmem I was able to replace the hashmap with a rbtree tho

brisk totem
#

im trying to avoid having a hashmap

#

by making consumers keep track of the alloc state structures

storm bobcat
#

It's probably not that big of a problem since large slabs aren't that common, but I still need to have some kind of mechanism to resize it

brisk totem
#

just preallocate it

storm bobcat
#

Which would be done in a thread or something

brisk totem
#

a large slab is how big?

brisk totem