#Hornet(rewrite, do you remember?)

1 messages · Page 1 of 1 (latest)

tardy mist
#

Hey im here on my main acc

hollow leaf
#

for what purpose do you have 166 bit gdt segments?

tight summit
#

166 bit?

tardy mist
#

oops wront reply

hollow leaf
#

16bit************

#

stupid keyboard repeat

tardy mist
#

what? thee is no 16 bit segment

hollow leaf
tardy mist
#

long mode bit is set

#

so its 64 bit

#

wait

#

I forgot

#

Rewrite branch

tardy mist
#

rewrite branch is the new

hollow leaf
#

ah

tardy mist
#

here is how it looks

hollow leaf
#

it looks nice ngl

#

do you have a memory allocator?

tardy mist
#

I have a PFA, but it aint working

hollow leaf
#

eh the only hard part of it is the bitmap functions

tardy mist
#

maybe theese bitmap funcs are bad?

hollow leaf
#

I'd use a simpler aproach on set function

tardy mist
#

it works now

#

it was one bitshift lol

#

fuck

#

I pasted the wrong thing

#

so, now it works

proven horizon
tardy mist
proven horizon
#

Wait what exactly are you doing with the bitmap_set function

#

Are you saving the bitmap[bit] except the bit you want to set into temp, and then ORing with the bit?

tardy mist
hardy merlin
#

Also the get function is just horribly broken

#

1>>bitIndex ??

#

Also clearing a bit is convoluted in your set function

#

a & ~b clears all the bits in b from a

tardy mist
#

I added PCI device exploration, now it has most of the old kernel's features

barren sundial
#

Why are your commas like that

tardy mist
#

update: I got the IDT to work

#

It still crashes

#

but now not so quietly

proven horizon
#

so now it crashes loudly?

tardy mist
#

no

#

but its now visible

tardy mist
#

I added keyboard input but it does not really work?

hardy merlin
tardy mist
#

whats the problem with that?

#

is page falut that much better?

#

I can read ur mind lmao

proven horizon
#

paging falutultrameme

hardy goblet
#

falut

tardy mist
#

umm, how do I make a stacktrace?

#

for the err screen?

proven horizon
#

walk the stack until you encounter 0, and print the rip values along the way

#

(if you use limine, rbp is always 0 when calling the kernel entry point, hence rbp value of 0 can be considered the "end")

tardy mist
#

Hello, this is an OSDEV studying day for me, so can you please link resources related to ACPI and VMM?

hardy merlin
#

VMM is not that complicated either

ebon fable
#

wdym either

barren sundial
#

for a vmm, I can recommend taking a look at the sunOS and vms vmms. There's plenty of write ups and papers online about them.

#

for acpi it depends what you want to do. The tables give you some config details about the current machine, depends what you want to know. For anything beyond you're going into the deep end and will probably want something like lai/acpica. The acpi specs are freely available online, the tables are documented under the software interface iirc.

hardy merlin
#

sorry

hardy merlin
#

how it does that is up to the implementation

ebon fable
#

also you can make your VMM arbitrarily sophisticated

hardy merlin
#

that's the gist of it

#

CoW, demand paging, swapping and compression are features implemented on top of your vmm

ebon fable
#

but at least a substantial part of their implementation is part of a VMM

worthy cradle
#

that is what a vmm is

#

the "vmm = page table data structure implementation" thing is a big misnomer in hobby osdev

#

it's such a tiny and trivial part of it that there are many kernels where it's not even a separate discrete component of any kind because all you're doing is setting pointers a few levels deep which you can easily do inline with the logic of the actual vmm

hardy merlin
#

or those are parts of the VMM

worthy cradle
#

those are commonly implemented features of vmms

hardy merlin
#

fair

#

but the minimal VMM with no feature is page table management

#

is it not?

worthy cradle
#

yea sure

#

actually even that was more sophisticated since it still had swapping just of entire processes at a time

proven horizon
hardy merlin
#

what do you think is the minimal VMM?

#

like a vmm with no features of any kind to optimize memory usage for instance

worthy cradle
#

the only feature it then has is address space isolation

#

and sparse allocation

hardy merlin
#

ah

tardy mist
#

I added a reg dump to the panic screen

proven horizon
#

the regs clobbed together without a space after the comma makes it hard to read

dawn spruce
#

FUCKING HALT!

tardy mist
dawn spruce
#

yo chat is this rizz tho?

tardy mist
tardy mist
#

do I need working ACPI for multiprocessing?

barren sundial
#

You'll need the lapic ids of the other cores to start them, which means parsing the madt. So yes, you'll need the tables, but not the other cruft.

#

Not sure if you use limine, but the protocol can also start the APs for you.

tardy mist
#

I do use limine cuz its easy

proven horizon
barren sundial
#

Limine tells you their ids in the feature response

barren sundial
#

But yes, you need them to talk to the lapics

proven horizon
#

ohh limine has everything i see

tardy mist
#

btw

#

wtf is lapic

#

local apic?

hardy merlin
tardy mist
#

oh cool

#

also I added a PIT driver

hardy merlin
#

There's also the I/O APIC (IOAPIC) which allows you to communicate with legacy devices such as the keyboard and PIT

hardy merlin
# tardy mist also I added a PIT driver

Please use the LAPIC timer for accuracy. If you can't use a different timer to calibrate it (such as HPET) or otherwise determine its frequency (as Linux does), you can fall back on the PIT to calibrate it in polled mode.

#

the ioapic is only for legacy external hardware interrupts

tardy mist
#

ok, where can I read about it?

hardy merlin
#

the wiki?

#

the SDM?

#

whatever google tells you

tardy mist
hardy merlin
#

what?

tardy mist
#

im tired of ppl saying "just google" or smth like that

hardy merlin
#

If you don't want to be constantly told to "just google" something, just ask Google what you need before asking the questions in the first place

#

Will save a couple of headaches

#

The "where can I read about it?" question is what google is designed to answer - linking you to webpages with the information

tardy mist
#

ty

tardy mist
hardy merlin
tardy mist
#

or just about the lapic in general

proven horizon
#

you write to the 11th bit of the IA32_APIC_BASE_MSR

tardy mist
#

new day, new things

#

is setting the pic remap offset to 0 a bad thing?

proven horizon
#

i don't know what exactly happens when you set the offset at 0, but it could clash with exceptions

tardy mist
#

Im refactoring cuz the code quality is awful

#

also, Im trying to make myself pay attention to warnings

#

there was countless times I made stupid mistakes, that could have been easily combated by paying attention to the warnings

#

they are warnings afterall

proven horizon
#

that way even if you don't see any error during compilation, GCC will just error out

tardy mist
#

is Weror needed?

#

I would think its kinda annoying

#

Ill give it a try anyways

#

I keep accidentally closing vscode wtf?

tight summit
#

i would suggest keeping -Werror out in any circumstance but development

#

it's bad practice to leave it in the default CFLAGS

#

because compilers may add warnings in the future and your stuff will stop building

tardy mist
#

Im adding serial support

#

for real HW debugging

#

should I remove the port E9 trick?

proven horizon
tardy mist
#

I fully integrated serial to the kernel

#

now the debug log uses it

#

I made a simple init system

#

here is the game plan:

#

the kernel will read /boot/kernel.cfg

#

the init system will be baked into the kernel

#

after the init system is done, it will start the login prompt

#

of course the login prompt will be able to be replaced by any program

#

then, the init system will initialize the enviroent, now logged in as a user

#

so it will be fully customizable

#

is this a good game plan?

#

(for a general purpuse kernel)

tardy mist
#

anyway this is just the future

#

rn, I dont have anything like that

tardy mist
#

how to write scheduler?

hardy merlin
tardy mist
#

wut?

proven horizon
# tardy mist wut?

Round-robin (RR) is one of the algorithms employed by process and network schedulers in computing.
As the term is generally used, time slices (also known as time quanta) are assigned to each process in equal portions and in circular order, handling all processes without priority (also known as cyclic executive). Round-robin scheduling is simple,...

tardy mist
#

oh

#

cool

proven horizon
#

It’s pretty easy to implement, there are some other articles you can find that will help with that

tardy mist
#

ty

hardy merlin
#

Actually task priority is usually implemented by having several queues, as is done in Windows NT

#

So you only need a couple of round robin queues for your task's priority

hardy merlin
#

no I said that it has several queues, not that it uses round robin

#

it might, but I can't say for sure yet

#

as many queues as there are priority levels

hardy merlin
#

From top to bottom

#

the highest priority tasks always go first

#

if you make a CPU intensive process a "realtime" process, that core is nuked

tardy mist
#

Im doing the scheduler

#

but first, I need a periodic interrupt

#

Im thinking of leaving the APIC alone and using the Realtime Clock instead

#

cuz acpi is hard

tardy mist
#

hmm, why isnt the XSTD there?

proven horizon
tardy mist
#

oh

#

ty

proven horizon
#

wait no

#

just checked and qemu does have xsdt

tardy mist
#

umm, then what the fuck?

proven horizon
#

how do you check for an XSDT?

tardy mist
#

RSDP revision is 0

#

I check the revision

proven horizon
#

like this?

if (rsdp->revision == 0) {
    _xsdt_is_available = false;
    rsdt_init();
} else if (rsdp->revision >= 2) {
    _xsdt_is_available = true;
    rsdt_init();
}
tardy mist
#

no, I dont have the else if

#

I have just else

#

it says it found the RSDP on OVMF

#

cuz I have a UEFI testenv too

#

that uses OVMF

#

nope, Im blind

#

it crashes on the checksum test

#

[INFO=]PCI Devices: 
[INFO=]VendorID: 0x8086 ,DeviceID: 0x1237
[INFO=]VendorID: 0x8086 ,DeviceID: 0x7000
[INFO=]VendorID: 0x8086 ,DeviceID: 0x7010
[INFO=]VendorID: 0x8086 ,DeviceID: 0x7113
[INFO=]VendorID: 0x1234 ,DeviceID: 0x1111
[INFO=]VendorID: 0x8086 ,DeviceID: 0x100e
[INFO=]RSDP found
[FATAL]Paging fault
[INFO=]RIP=0xffffffff800036dd ,RSP=0xffff80000e417fc0 ,CS =0x0000000000000008 ,SS =0x0000000000000010
[INFO=]RAX=0x000000000fb7d0e8 ,RBX=0x00000000000000f4 ,RCX=0x0000000000000100 ,RDX=0x00000000000003f8
[INFO=]RSI=0x000000000000000a ,RDI=0xffff80000fb7e014 ,RBP=0x0000000000000060 ,R9 =0x00000000ffffffff
[INFO=]R10=0x00000000ffffffff ,R11=0x00000000ffffffff ,R12=0x0000000000000057 ,R13=0x0000000000000000
[INFO=]R14=0x0000000000000000 ,R15=0x0000000000000000 ,ERROR_CODE=0x0000000000000000```
proven horizon
#

lolwut

#

what could have you done wrong there?

tardy mist
#
    unsigned char sum = 0;

    for (uint32_t i = 0; i < table->h.Length; i++) {
        sum += ((char *)table)[i];
    }
 
    return sum == 0;
}```
#

this is the checksum

#

the page table is the stock limine one

#

oh, I see you typing out exactly the right answer, in a complicated manner

proven horizon
#

sum += ((char *)table)[i];
converting the table to a char array and adding that might cause the issue maybe?

proven horizon
tardy mist
#

thats why I use a hide typing plugin

#

lol

proven horizon
#

you might want to retype it to uint8_t (sum is uint8_t as well)

proven horizon
#

sum += ((uint8_t *)rsdp_request.response->address)[i];

proven horizon
tardy mist
#

lol

#

still bad 😦

#

SCREW ACPI

#

Im just gonna use the Realtime Clock as a periodic interrupt

#

but what is the frequency of it?

proven horizon
#
uint8_t xsdp_checksum = 0;
uint8_t *xsdp_ptr = (uint8_t *)rsdp_request.response->address;

for (uintptr_t i = 0; i < sizeof(xsdp_t); i++) {
    xsdp_checksum += xsdp_ptr[i];
}

assert((xsdp_checksum & 0xFF) == 0);

taken from luxe

tardy mist
#

so like this:

#
    uint8_t xsdp_checksum = 0;
    uint8_t *xsdp_ptr = (uint8_t *)table;

    for (uintptr_t i = 0; i < sizeof(struct XSDT); i++) {
        xsdp_checksum += xsdp_ptr[i];
    }

    return (xsdp_checksum & 0xFF) == 0;
}```
#

right?

#

cant belive, it works...

#

like this

#

but it still crashes on OVMF???????????

#

what the hell?

proven horizon
#

wait I just noticed that

#

you're computing the XSDT checksum

#

However the checksum is written for XSDP

tardy mist
#

what is the difference?

proven horizon
#

XSDP is a Pointer, while XSDT is the Table to say it simply

tardy mist
#

the pointer points to the table?

proven horizon
#

R/XSDP contains the address to the R/XSDT table

tardy mist
#

ohh

#

this good?

#
    if(rsdp->Revision != 0){
        xsdt = (struct XSDT *)PHYS_TO_VIRT(rsdp->XSDTAddress);
        if(do_checksum(xsdt)){
            log_info("XSDT found");
            xsdt_entries = (xsdt->h.Length - sizeof(xsdt)) / 8;
            use_xsdt = true;
        }else{
            log_error("XSDT corrupted ,falling back to RSDT");
        }
    }else{
        xsdt = (struct XSDT *)PHYS_TO_VIRT(rsdp->RSDTAddress);
        if(do_checksum(xsdt)){
            log_info("RSDT found");
            xsdt_entries = (xsdt->h.Length - sizeof(xsdt)) / 4;
            use_xsdt = false;
        }else{
            log_CRITICAL(NULL,HN_ERR_ACPI_FAULT,"RSDT corrupted, can not fall back to anything");
        }
    }```
tardy mist
#

this name sounds a bit Hungarian to me

proven horizon
#

because it is

tardy mist
#

ok

proven horizon
tardy mist
proven horizon
#

do you map the virtual memory before doing that?

tardy mist
#

nope

#

I cant

#

I mtoo stupid for that

proven horizon
#

why did you then converted the addresses to virtual ones

tardy mist
#

gtg eat lunch

proven horizon
#
xsdt = (struct XSDT *)PHYS_TO_VIRT(rsdp->RSDTAddress);

should then be

xsdt = (struct XSDT *)rsdp->RSDTAddress;
hardy merlin
#

the HHDM maps all of physical memory

tardy mist
#

btw, why did you take down the luxe gh repo?

proven horizon
proven horizon
tardy mist
#

why do it manually, If I have GDB?

tardy mist
#

fuck ACPI

#

Im using the PIT instead

tardy mist
#

intresting

#

the serial driver is getting fucked by the isr0 handler?

tardy mist
#

lessgoo

#

the stack is now not fucking up

#

got the periodic interrupt

#

anyways

#

part 1

#

of scheduler done

#

part 2: write a queue

#

how the fuck do I do that?

#

@proven horizon how do I write queue for a schedualer?

#

screw it

#

ill try

proven horizon
#

once the scheduler reaches the bottom of the array (the last task present) it goes back and executes the first task in the array (kind of "execution in a circle" - hence the name "round robin")

tardy mist
#

the queue is done

#

lets test it!

#

but how?

#

I guess I cant test it

#

I will just wing it

#

and hope its not the queue

#

also, I didnt expect to make it this far into the project

#

I thot I would be hell burned out after a week

#

but no

proven horizon
#

and pass the function pointer as an entry point for the scheduler

tardy mist
#

nah, I have godbolt

#

*Compiler Explorer

proven horizon
#

what

steady merlin
#

you are in games with gabe server too right

tardy mist
#

I used to watch him

steady merlin
#

used to

#

sad that he is not currently uploading

tardy mist
#

buth his newest project is boring as fuck

steady merlin
#

The animation editor?

tardy mist
tardy mist
tardy mist
#

I remember, you dnt?

steady merlin
#

ohhhh

#

your server

#

I joined to check what it was gdtdoesntwork

tardy mist
#

lol

#

anyways

tardy mist
tardy mist
#

jeff? what kind of name is that?

steady merlin
#

I really dont know

#

just decided on it for some reason

tardy mist
#

and how is it?

steady merlin
#

I also cant answer that

steady merlin
#

I want to see

tardy mist
#

it just a kernel

#

no GUI stuff

#

just under thre hood stuff

steady merlin
#

Your readme says you have audio support but no gdt lmao

tardy mist
#

holy shit

#

fuck capslock

steady merlin
#

wait did you resend the message

#

lmao you sent "that is old, see rewrite branch", deleted it and sent "REWRITE BRANCH"

tardy mist
#

oh, you have msg logger

steady merlin
#

No, I literally remember you sending a message

tardy mist
#

oh

#

is this OK or should I do it another way?

    Registers status;
    //TODO:add more stuff
} process_t;


static bool is_active;

queue(uint64_t,process_queue);
vector_static(process_t,processes);

void sched_enable()
{
    is_active = true;
    queue_init(process_queue,uint64_t,500);
    vector_init(&processes);
}

void kill_process(uint64_t ID)
{
    processes.data[ID].status.rip = 0;
}

uint64_t create_process(void (*process_main)())
{
    Registers newregs;
    newregs.rip = (uint64_t)process_main;
    vector_push_back(&processes,{newregs});
    queue_add(process_queue,processes.len);
}```
steady merlin
#

.... just remove from queue

tardy mist
#

I cen only remove it if its at the front

#

so Ill do the removing in the schedule function, that Im just about to write

tardy mist
# steady merlin .... just remove from queue

this should work right?```void schedule(Registers *regs){
if(!is_active)
return;
memcpy(&processes.data[current_process].status,regs,sizeof(Registers));

while(true){
    if(process_queue.fullness == 0){
        log_CRITICAL(NULL,HN_ERR_UNIMPLEMENTED,"No more processes to execute, ideally, we should shut down");
    }
    uint64_t next;
    queue_remove(process_queue,next);
    process_t nextproc = vector_at(&processes,next);
    if(nextproc.status.rip != 0){
        memcpy(regs,&nextproc.status,sizeof(Registers));
        current_process = next;
        queue_add(process_queue,next);
        break;
    }
}

}```

#

ok. wtf?

proven horizon
#

what do you mean by escaping the scheduler?

tardy mist
#

nothing

#

It was just me being stupid

#

but...

#

WHAT THE HELL IS THE THING THAT I GAVE YOU????

#

god damn

#

oh, my logic is bad

tardy mist
#

HOLY SHIT IT FUCKING WORKS

#

LESSGOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

#

lets see how it does with multiple processes

#

what

#

wft?

#

the PIT stops sending the periodic interrupt wtf

#

after we enter the first process

proven horizon
tardy mist
proven horizon
#

There is an interrupt enable bit there, if it is not set interrupts are blocked

#

I made that mistake when writing my scheduler

tardy mist
#

oh

#

well

#

I dont initialize rflags for the initial process state

#

so thats the problem

proven horizon
#

Should usually be set up to 0x202 to set IF and the reserved (must be on) bit

proven horizon
# tardy mist I dont initialize rflags for the initial process state

The FLAGS register is the status register that contains the current state of an x86 CPU. The size and meanings of the flag bits are architecture dependent. It usually reflects the result of arithmetic operations as well as information about restrictions placed on the CPU operation at the current time. Some of those restrictions may include preve...

tardy mist
#

ye now it worsk

hardy merlin
tardy mist
#

it was rflags

hardy merlin
#

oh ok

tardy mist
#

tysm

#

imma list the still uninitialized varibles so you can make me aware if it can cause problems

#

lol, there are none

#

the rflags was the only one

proven horizon
tardy mist
#

I think this is the point where h0r.net isnt a toy kernel anymore

#

cuz now it doesnt just initialize hardware, but it actiually uses it

#

so yeah

proven horizon
#

Are you going to do a unix-like design or something else?

tardy mist
#

something else

proven horizon
tardy mist
#

custom

proven horizon
#

Oh ok. how do you plan on porting software?

tardy mist
#

Frankenstein design

proven horizon
#

Interesting

tardy mist
proven horizon
#

Do you have a ramdisk or other filesystem?

tardy mist
#

nope

#

I dont yet

proven horizon
#

I would recommend doing that next, ramdisk is really easy, especially tar format. You can start to actually parse ELF files

tardy mist
#

tar?

#

isnt that juat an archive format?

proven horizon
#

Tape Archive Format, yes. Most people think it's for compression but that's really just an extension

#

In reality it's a way of lumping files together into one file (or tape) which is super easy to parse.

tardy mist
#

oh cool

#

I will implemant tar first, but will customize later

proven horizon
#

You can implement it in an hour, max. Depending on if you can already load modules using your bootloader.

tardy mist
#

I use limine so I can load modules

proven horizon
#

Yeah, once you can do that tar is super easy

tardy mist
#

(main branch is old )

#

Im updating the TODO

#

what is MSI?

proven horizon
#

It's something to do with PCI I guess

tardy mist
#

ohh

tardy mist
#

nice

#

got modules loading

#

well, mint is right, limine is really easy

steady merlin
#

I just copied the gdt from lyre because I thought it was a one time thing that I dont need to waste time on

#

Rip and rsp I understand

#

Do ip and ss also have to be set or can I just set rip and rsp?

proven horizon
proven horizon
tardy mist
#

im adding hornet.conf

#

so it can be configured

#

but first, Im making a library

#

basically just kernel utils

#

so its easy to make kernels if ur new

#

also for me in the future

#

is there anything I missed?

proven horizon
#

im not sure if that's included in stdtypes or not though

tardy mist
#

lessgoo

#

the lib is ready

#

Imma make a new post about it

#

okay, made new post

#

tar

#

first, I need an initramfs to load

tardy mist
#

@proven horizon how can I make a tar file with the simple tar not USTAR?

proven horizon
#

man tar

tardy mist
#

oh

#

ok

#

actually tar --help did the job

tardy mist
#

hmm

#

so if there is only one file

#

it crashes at the end

#

cuz there is no more at the end

#

HOW THE FUCK AM I SOPPOSED TO KNOW THAT IT ENDS

#

oh

#

file size

#

right

#

lessgooo

#

it works

#

@proven horizon Im done with tar

#

it works

#

now I have to figure out wtf happened to my pid 1

#

it now spams fsr

#

hmm, but the only thing I did is I removed 2 create process calls

#

hmm

#

WTF?

#

ooh

#

fixed

proven horizon
#

You're making good progress

#

Are you going to do userland stuff next or something else?

tardy mist
#

Im thinking of yaml and NBT parsers

#

but yaml looks hard

#

and I never looked at the NBT spec

proven horizon
tardy mist
#

yaml for config , NBT for registery hives

proven horizon
tardy mist
#

maybe Ill try json

proven horizon
#

I would say for configs for a kernel, INI is probably better but JSON also works

tardy mist
#

screw it, Ill do INI intead

tardy mist
#

ini parser almost done 😉

tardy mist
#

ini parser is done

#

but I have to go

steady merlin
#

Also add these configs to kernel args in limine

#

And allow the kernel args to override the config files

#

So when I forget a password or something I can just change the kernel to some password change mode in kernel args in limine and change the password

#

It's just an example

#

You can do other things

tardy mist
#

ok ok

tardy mist
#

the ini parser does not work

proven horizon
tardy mist
#

so vfs

#

how the HELL do I do that?

proven horizon
tardy mist
#

actually, Imma just upgrade the tty, cuz its really not usable

#

(Imagine mint jumping in and saying "Just use flanterm")

tight summit
#

Just use flanterm

tardy mist
proven horizon
tardy mist
#

oh

proven horizon
#

I would recommend it

tardy mist
#

just that the owner loves to self advertize

#

that was the meme

proven horizon
#

This server does advertise Limine a lot I guess

tardy mist
#

like Im afraid Im gonna catch it by putting flanterm into h0r.net

#

screw it, flanterm time

proven horizon
#

The main benefit of SSFN is it supports unicode so foreign languages display correctly

proven horizon
tardy mist
#

wtf is a framebuffer's pitch?

#

how do I do this?

#

wait, I can just copy from halihacker

#

he uses this same config

tight summit
#

that sounds terrible

tight summit
tardy mist
#

is there a way to clear the sreen?

#

is this how flanterm sopposed to look?

#

just asking

tight summit
#

yes

tardy mist
#

cuz it looks great actually

tight summit
#

you can change the font if you want, or colour palette, etc

tardy mist
#

does it scroll?

tight summit
#

yeah of course

#

hell, it runs like

#

80% of what the average Linux terminal emulator runs

#

including nano, vim, nyancat, etc

#

and it is quite performant

#

without weird hacks

tardy mist
#

unicode?

tight summit
#

it supports a subset of unicode

#

it understands unicode but most characters will result in tofu if they are not part of codepage 437

tardy mist
#

oh hell no

#

I hate projects that dont have the proper gitignore

tight summit
#

hm?

#

flanterm does not have a gitignore because it doesn't have a build system

#

limine-barebones has proper gitignores

tardy mist
#

oh ok

tight summit
#

if you dropped the flanterm C files in a repo with proper gitignores and build systems, it won't be an issue

#

well i assume your editor shows it that way because you cloned the flanterm repo into your repo

tardy mist
#

I submoduled it

tight summit
#

alright, same thing

#

though git adding in your base repo shouldn't affect the flanterm directory

#

even if it shows like that in your editor

#

one way to fix this is by doing out of tree builds

#

but that is beyond the scope of limine-barebones

proven horizon
tight summit
#

which issues?

proven horizon
#

after the screen fills up, you could literally see each line getting pushed upwards which slowed down the entire thing

#

but it does work just fine on real hardware so I just disabled flanterm when running in QEMU

tight summit
#

so i am not sure what's going on there

#

if you want to double check, go get the lai test image and see if it's slow there as well

tardy mist
#

my keyboard driver seems to be bad

#

cuz, I press a on my custom prompt and nothing happens, digging deeperthis is how a keypress looks like(the right number is the output of KEY_IS_PRESS)

#

lol

#

I forgot about this custom banner

#

I think its just KEY_IS_PRESS

#

really?

#

the relase KEYBOARD_RELASE value was wrong

#

now I need a sleep func to make typing not be impossible

#

I have the PIT sleep func now

#

@tight summit how do I do backspace with flanterm?

tight summit
#

\b

tardy mist
#

oh

#

theres a char

tight summit
#

if you want to clear as well, then \b \b

#

that's the standard way to do that

tardy mist
#

so 2 backspaces in a row clears screen?

tight summit
#

space in the middle, and no

#

i mean to clear a character

#

like pressing backspace in a terminal

#

if you want to clear the screen there is another escape sequence for that

tardy mist
#

oh

tight summit
#

\e[2J\e[H

tardy mist
#

what the FUCK?

tight summit
#

hm?

hardy merlin
tardy mist
#

yes

hardy merlin
#

tbh I had fun implementing them in my terminal emulator

tardy mist
#

I got a little experimental kernel shell running

#

here are all features

#

this interactive env will help me make the VFS

hardy merlin
# tardy mist

I'd load an executable from a module first and then use that

tardy mist
#

and I alredy hade the code for it

#

anyways

#

lets actually make a proper VFS

tardy mist
#

shis should be good right?

#

thats it for now

#

Imma call it a day

tardy mist
#

I have been developing for 2 weeks straight

#

also fuck paging

#

Imma just act like its 2001

hardy merlin
tight summit
#

we had paging in 2001

#

btw

tardy mist
tight summit
#

like

#

the 70s or so?

#

ask will he'll give you a 5000 word essay about it

ebon fable
#

But basically every 32-bit PC ever made has it.

ebon fable
# tardy mist Imma just act like its 2001

By 2001, I'm pretty sure 99.9% of people moved on from 8088 and 286 PCs.
The 386, the first x86 processor to support paging, was released in 1985, and was first used in commercially available PCs in 1987.
In the early 90s, 8088s and 286s became increasingly rare.
Windows dropped support for 8088 with the release of Windows 3.1 in 1992, and Windows NT always required at least a 386.
Windows for Workgroups 3.11, introduced in 1993, and every subsequent PC version of Windows required a 386 or higher and made heavy use of paging.

#

Anyways

#

Paging makes a lot of things easier, not harder.

tardy mist
#

maybe I should het off the Poncho drugs and read something actually useful

tardy mist
hardy merlin
#

the page tables simply map each page of the virtual address space to physical pages... or don't (if the present bit isn't set)

#

but instead of pml4, pdpt, pd and pt (names used by the SDM) you can use pml4, pml3, pml2 and pml1 so it is a little less mind numbing

proven horizon
#

@tardy mist what the fuck is this log

tardy mist
#

"testicles" starts with test yk

proven horizon
#

🤣🤣🤣🤣🤣

tardy mist
#

I implemented a get_file func

proven horizon
#

by the way how fast you implement stuff I'm starting to get worried about the code quality tbh

tardy mist
#

its on the github

proven horizon
#

it's... inconsistent

#

i hope that's the right word

tardy mist
#

wdym?

proven horizon
#

as in: some functions named in snake_case, some combine capital letters (snake_CASE), and then some functions are PascalCase

#

also the coding style varies from file to file:
one has

if(cond){
  expr
}

another one

if (cond) {
  expr
}

and

if (cond)
{
  expr
}
tardy mist
#

wtf?

#

that is just nit picking

proven horizon
#

well it still is something that might raise questions (especially if the code really is yours, and not just a frankenstein of different projects)

tardy mist
#

what is wrong with being inconcistant?

proven horizon
#

nothing in terms of functioning - it all gets compiled to the same instructions regardless

#

the thing is code readability: it's a lot easier to maintain a large repository with a clean, set coding style

#

and don't take this the wrong way, it's going to help you (and others interested in contributing, like me) get oriented in the code easily

tardy mist
#

but how does the if case one help?

#

that one specifically

#

is stupid

proven horizon
#

I mean code style is very subjective (as to where do you like to place braces etc.), in the if() case I meant mostly consistency

tardy mist
proven horizon
#

idk, never got to vfs stuff in the first place and i haven't studied your impl enough

#

but I'd say that tar_get_file_header should actually read the file, and get the file's header (and not the metadata)

tardy mist
#

the

#

VFS

#

is

#

complete

#

Im not gonna hook it up yet

#

ill do it tomorroe

#

its enugh work alredy

#

so

proven horizon
#

becauseeee I want to

tardy mist
#

I got a simple VFS working, but Im still debugging

tardy mist
#

anyways I committed the changes

#

I hate debugging

#

does anyone know some background noise or music that makes me not want k*ll myself while debugging?

tardy mist
proven horizon
#

like "if this string is the same as the other string, do this"?

tardy mist
#

yes

proven horizon
#

that would need to be if (!strcmp(...)) then

tardy mist
#

why?

proven horizon
#

wait no, you're using your own implementation

tardy mist
#

yeah

proven horizon
#

a really weird implementation tbh but yeah

#

what are you debugging? i've got some time so i could also take a look at it

tardy mist
#

Im noöt adebugging anything rn but the tar parser cuz it stops at the bin folder fsr

#

its inb vendor/libkrnl-essentials/parsing/tar.c

#

(the lib is made by me)

tardy mist
proven horizon
#

i didn't really find anything wrong

tardy mist
#

oh ok

proven horizon
#

just curious, is this supposed to align the size to 512 bytes?

if (size % 512)
            _header += 512;
#

(it's in the parse_tar function)

tardy mist
#

yes

hardy merlin
#

(_header + 511) % 512

proven horizon
#

that would not align it properly however

#

if you had a size of, say 513, adding 512 would result in 1025, which again isn't aligned

hollow leaf
#

if you want to align to next 512

tardy mist
#

ty

#

the problem is that the parser only sees the first header

proven horizon
#
if (!((struct ext_dir*)folder_contents->ext)->files[i].flags)
{
  break;
}

this is failing

#

soo there's something wrong with setting the flags for files when they are detected

#

also the cd command is broken

tardy mist
#

ye, ik, but idk what

#

um wtf?

tardy mist
#

in the pic?

proven horizon
tardy mist
#

oh ok

tardy mist
#

hmmmmm

#

I added event system

#

its not very important rn

#

but I want my kernel to be event based

#

event BASED lol

fallow pilot
#

Subscribers? Isn't that like, YouTube???

hardy merlin
#

which is an event

#

so... I guess yeah?!

fallow pilot
#

Yeah I know lol

dawn spruce
# fallow pilot Yeah I know lol

don't forget to subscribe, hit the bell and smash that like button, it helps the channel a lot, thank you and let's continue with the video

fallow pilot
dawn spruce
#

forgot to put the "gone wrong" after that

fallow pilot
#

yes

tardy mist
fallow pilot
#

Oh alright

uneven fox
#

forgot to put the OMG COPS CALLED flobsh

old sapphire
#

and if it was 2017, also a clickbait thumbnail and a title with the "so i did (something not even related to the video)..." (the three dots at the end are important)

#

but in 2023 it's just some words are written with caps, also if you can put an arrow and a question mark, then do it

dawn spruce
tardy mist
#

I hate debugging

#

that stupid tar parser isnt working right fsr

#

why???

#

why????????????????????????????????????????????????????????

#

what the hell??

#

it was the pointer arith

#

me = stupid

#

very stupid

hollow leaf
#

gdb

tardy mist
# hollow leaf gdb

Does the visual studio code plugin native debugger cout as gdb? if yes, then Im alredy using it

hollow leaf
#

good job

#

follow the spec to the word

#

and it should work properly

fallow pilot
#

at least it didnt take you 3 weeks to debug 😢

#

oh you didnt fix it yet

#

alright

tardy mist
#

I fixed it

fallow pilot
#

oh nice

tardy mist
#

but there is another bug

#

*2 more bugs

#

first

#

why is this true when path is bin/cum and filename is bin/?

#

strncmp(path, (char*)hdr->filename, strlen(path)) && !strcmp(path,(char*)hdr->filename

hollow leaf
#

check for strncmp to be 0

tardy mist
#

my impl doesnt follow the spec

#

it just returns true if they match and false if they dont

hollow leaf
#

if it is then it's a full match

proven horizon
hollow leaf
#

I thought the tar isn't to spec

#

mb

fallow pilot
#

😅

#

that might be it

hollow leaf
#

probably :)

#

it looks nice everywhere else

fallow pilot
#

yeah

tardy mist
#

that is the error yeah

#

2nd new bug: mistery kernel panic

proven horizon
#

@tardy mist do you support APIC yet?

tardy mist
#

I am clueless

tardy mist
hollow leaf
#

and use addr2line

#

on the offending address

proven horizon
tardy mist
proven horizon
#

oh wait right I forgotnooo

tardy mist
#

or is there a PIO method too?

fallow pilot
#

The stupid ioapic, I am implementing it right now and it SUCKS

proven horizon
#

parsing the MADT isn't hard though, shouldn't take you more than 1-2 hours to read the spec and implement it

proven horizon
#

MADT is just some simple structs and minimal parsing work

#

The spec is your best friend here even if it seems intimidating at first

tardy mist
hardy merlin
#

Actually the local APIC is accessible via an MSR

#

or you are talking about the IOAPIC?

#

but that just involves going through the ACPI headers.. which is NOT complicated

#

it's just a struct

proven horizon
hardy merlin
#

running AML is complicated (for whatever reason)

proven horizon
hardy merlin
#

boom

proven horizon
#

literally the MADT parsing is just a switch-case inside of a for loop

tardy mist
proven horizon
#

You can’t access a random pointer you get from an ACPI table without ensuring it is mapped

tardy mist
#

does limine not map the tables for you?

#

rsdp is mapped if you request it

#

but IG nothing else is

proven horizon
tardy mist
#

this:

    /* We wanna be placed in the topmost 2GiB of the address space, for optimisations */
    /* and because that is what the Limine spec mandates. */
    /* Any address in this region will do, but often 0xffffffff80000000 is chosen as */
    /* that is the beginning of the region. */
    . = 0xffffffff80000000;
proven horizon
tardy mist
tardy mist
#

wierd, it still loops

#

it loops until it runs out of stack

#

it works now

#

listing directory contents is still wierd tho

#

it does not like empty folders fsr

#

I need to add cat...

#

why does it think everything is a directory?

proven horizon
#

probably wrong flags set?

tardy mist
proven horizon
#

aaand does cat check for the flag correctly?

tardy mist
#

yes it does

#
{
    struct node* fileinq = get_file(path); 
    if (fileinq == NULL) return false;
    return (fileinq->flags & FLAGS_ISDIR) >> 1;
}```
fallow pilot
#

Any updates?

proven horizon
proven horizon
proven horizon
proven horizon
#

readmes tend to be outdated

#

uhoj

#

uhok*

hardy merlin
#

Will it beat linux though?

proven horizon
#

hornet isnt complete >:D

proven horizon
#

but you can come close to (or even beat) Linux in terms of security, functionality and speed

proven horizon
#

what do you mean by that exactly?

tardy mist
#

I want it all

proven horizon
#

well that is definitely doable

#

(doable does not mean easy though)

tardy mist
#

Imma focus on functionality first cuz that sounds the easiest

proven horizon
#

and the most important imho

tardy mist
#

why is there no XSDT?

fallow pilot
#

Qemu?

tardy mist
#

its seabios

#

it does exist on TianoCore

fallow pilot
#

Idk then

tardy mist
#

lessgo, I just had to replaxe the checksum with a signature chack and now it works

#

nooooooooooo

#

trying to access one of the tables page faluts

#

@tight summit does limine not (page) map the ACPI tables for you?

#

IK it does RSDP and RSDT/XSDT

#

but what about the other ones?

tight summit
#

it doesn't say anything about the ACPI tables, but it always maps the first 4GiB where usually most tables are, and it also maps all other memory map entries, which usually also includes ACPI entries

tight summit
#

if the address is <4GiB and you get a page fault, it isn't Limine's fault, assuming you're using Limine's page tables

tardy mist
tight summit
#

i mean physically

tardy mist
#

hmm. faluting address(cr2) is 16????

#

is this address good?

tight summit
#

that looks non canonical

tardy mist
#

wdym?

tight summit
#

it's an invalid address

tardy mist
#

oooh

proven horizon
#

Lyre

#

it's my number one choice when I don't understand something

tight summit
#

just you wait for the rewrite :p

proven horizon
#

i have fucking fat fingers

#

fixed it lol

tardy mist
#

I have moved development of the VFS into a test enviroment(standard userspace ""application"") for convenience

#

almost works..

hardy merlin
#

that, or Valgrind

tardy mist
hardy merlin
#

basically ensures you don't have any memory bugs

tardy mist
#

nice

tardy mist
#

I got mounting ro work

tardy mist
#

finally

#

the VFS works

steady merlin
#

hello

tardy mist
#

hellohacker

proven horizon
#

With a VFS working you might also want to implement a real FS on top of it

#

so you can test your OS (including FS stuff/file loading later on) on real hardware

proven horizon
#

@tardy mist Are you still looking to implement ACPI one day?

#

I might write something and send you a PR if you want

tardy mist
#

jusm make sure to add a lot of comments, so I can learn from it

proven horizon
#

So with this you should easily be able to write code for HPET, MADT and friends

tardy mist
#

finally got the VFS to work in the kernel

#

it still uses the test drive

#

but Ill write a tar driver soon

#

maybe even mount some ACPI info to /sys/acpi

tardy mist
#

turns out, I just forgot to initialize my bitmap font renderer 🤦🏼‍♂️

proven horizon
tardy mist
#

I just learned how to use unions in C for type specific stuff

#

how did my head not explode trying to debug my VFS without this?

tardy mist
#

finally got cat to work

#

this thing shows all current shell features

#

(note: this is the kernel test shell)

tardy mist
#

bruh, tar vfs driver going well...

tardy mist
#

ok, now its only **semi-**broken

proven horizon
#

i like how everything you name refers to dicks, balls and cum

tardy mist
#

Sex humor

#

Im in that age group

proven horizon
#

12-13?

tardy mist
#

13-16

#

maybe thats not it

proven horizon
#

seems legit

#

it's kinda cool to see such young people make an OS tbh

tardy mist
#

am I just stupid or do you really need a fully developed frontal cortex for wrapping your head around the MMU?

#

because there is always smth I cant explain

#

maybe its Limine, and If I was to make my own mappings it would be better

#

but Im too lazy to do that

proven horizon
#

well it's just a translation unit

#

(along other things of course)

#

so you have the kernel loaded in memory at address, say, 0x123456, but it makes it seem like the kernel is actually loaded at 0xfffff8000 something

#

also it ensures that other processes cannot see the memory of other processes

tardy mist
#

fucking

#

finally

#

it works

#

LESSGOO

#

969th message

#

now

#

I have to fix up the VMM

steady merlin
tardy mist
#

I have a barebones scheduler

steady merlin
#

than do it after everything on top of it is complete

#

then you would have to change a lot

steady merlin
#

like rescheduling if sleep?

#

and adding to sleeping list and that?

tardy mist
#

for multiple thereads, its a bit moer komplikated

#

but I know how

#

cuz my sleep is just a spinlock with a milisecond counter

proven horizon
#

why the spinlock?

tardy mist
proven horizon
#

oh you have a global counter?

hardy goblet
steady merlin
#

Wait why are u the op, isnt lolguy making this os

hardy goblet
#

well you are using a spinlock and millisecond counter, whatever

steady merlin
#

Hotnet os conspiracy

dawn spruce
#

isn't irq 1 keyboard tho

#

until you're talking about IRQ 0 (PIT)

proven horizon
#

but why the lock?

proven horizon
#

i was hoping for a more... descriptive answer

steady merlin
tardy mist
#

I know its horrible and wastes cycles, but it works

proven horizon
#

but i'm not seeing the spinlock either

tardy mist
#

the while loop

#

isnt it technically a spinlock

#

__asm__ volatile("movq %0, %%cr3\r\n" : "=r"(nextproc.pml4) :);

#

is this good?

#

why does it not work

#

is the asm the issue?

#

oops wrong channel lmao

proven horizon
#

so no

tardy mist
#

I didnt work on hornet today

#

Because I went to an open day, and won a high end USB pendrive on an IT knowlage contest

#

and what I did with it?

#

well, I noticed that it is much faster than my HDD

#

so I made it my boot drive

#

Im still using the HDD, but soon, the portable GeekUSB™ will be done!

tardy mist
#

This is how the system looks

#

its all on a USB drive

tardy mist
#

I redone the error screen again, now its using flanterm

#

so I got rid of that 2nd font renderer

proven horizon
#

looks good👍

proven horizon
#

any updates?

tardy mist
proven horizon
#

it was delicious

#

wait what

proven horizon
#

isn't that my vmm code?

tardy mist
hardy merlin
tardy mist
#

okay

tardy mist
proven horizon
tardy mist
#

yep

#

wait

#

nvm

#

im just stupid

#

Im not doing anyting rn

tardy mist
#

Sorry for the ded-looking project

#

I just run out of motivation quick

#

I wil get back to it later

#

I promise

tardy mist
#

this is a normal non- ‫ message ‫

tardy mist
#

Im diving head-first into ELF parsing!!

#

rn, the hornet test playground is just inspecting itself

tardy mist
#

some progress:

hardy merlin