#Nullium

1 messages Ā· Page 2 of 1

wild glen
#

or not idk

#

move multiboot2 entry to userland trl

wild glen
#

im done with the powerpc bullshit ima go back to actually writing code

hushed briar
#

Fire

wild glen
#

all hail somewhat working linux

#

(it breaks sometimes)

wild glen
#

ok so i moved grub to userspace for efficiency and speed

the gdt is now on a separate computer and has to be loaded through a network protocol at 1 byte per hour

#

if an error occurs a robot spawns in and lights your house on fire and shoots you in the head afterwards

#

also trying to add paging now

wild glen
#

be me
do thing correctly
triple fault

wild glen
#

ridiculously small font

fluid moon
#

A

gloomy musk
#

very smol font lol

wild glen
#

you'd see the whole universe on a single screen

#

C

#

should i make it larger though

gloomy musk
#

it is a bit too tiny ye šŸ˜…

wild glen
#

im gonna use the default system font for the terminal actually

#

its just big enough to be good

#

probably

wild glen
wild glen
#

boot options, probably (system extensions are gonna be drivers, idea stolen from mac os obviously)

#

ok anyways time to actually make something

wild glen
#

also progress will slow down

#

sadly

wild glen
#

nvm menu gone trl

#

instead

#

like apple

#

"HOLD [insert key] DURING BOOT HOPE IT DOES SOMETHING trl"

#

also theres visual output if your goofy keypress worked

#

i didnt steal anything i swear on my mom trust me

#

ok anyways im gonna sleep actual progress tomorrow hopefully

lean relic
#

poor mom

fluid moon
wild glen
wild glen
#

im gonna consider stealing less from apple

#

before they shoot me to death with their big epic patents

wild glen
# wild glen

my best idea is to remove the text because its said that extensions are off way before this

#

garphibc desgn

wild glen
#

im gonna remove some of the mac os ideas

#

its not really gonna feel like mac os but might be similar to use

wild glen
wild glen
#

my brain works periodically

#

by that i mean it doesnt

#

im stupid

wild glen
#

ok im back to doing things except progress is actually gonna be slow trl

#

almost done with paging

wild glen
#

i fucked up paging

#

truly skill issue

#

multiboot2 so functional amirite

wild glen
#

ok so apparently i am not making a unix im probably making a mac os and dos hybrid in some form

#

because no posix compliance

#

i mean i want to put bash on it eventually as an app

#

and also a terminal text mode for nerds and shit

#

maybe thats the unix part

#

but idk

#

classic mac os and unix is literally a/ux so its still a/ux like

#

probably

gloomy musk
#

I mean... you could probably force bash to work on a non-UNIX system with enough effort... probably..... okay maybe not......... okay yeah this sounds sillier the more I think about it

#

(was classic macOS not a unix-based system?)

wild glen
gloomy musk
#

ahhh, I see

lethal summit
wild glen
#

partially firmware

lethal summit
#

Paging is easy to mess up but paging is pretty simple

wild glen
wild glen
lethal summit
wild glen
#

loading in my os afterwards was the problem

gloomy musk
lethal summit
#

ok šŸ‘

wild glen
#

found this on wiki

#

for bash

lethal summit
#

i would not trust it

#

no joke check the reboot page

wild glen
lethal summit
#

šŸ’„

wild glen
#

idk why the fuck would you triple fault to reboot

lethal summit
#

lazy people

wild glen
#

i mean its easy but like quadruple stupid

#

the only thing i use that for is some forms of debugging by "HMMM THIS DOESNT WORK MAYBE IF IT GETS TRIGGERED I SHIT COMPUTER"

gloomy musk
#

that's certainly one of the more egregious things the wiki has said XD

wild glen
#

that you need like 3000 years of experience

#

(i only programmed for directx 9 and a ti84+ ce calculator before osdev)

#

smells like total bullshit

gloomy musk
#

I mean, you certainly need to be comfortable with a lang like C, but asking for 12+ years of experience is a bit much lol

wild glen
#

true

#

i know enough c to understand everything well enough

#

12 years is insane

#

i feel like people gatekeep a lot to look smart

#

"you can only program if you know 3000 types of math and have 30 phd's"

gloomy musk
#

I mean, personally I don't think that was the intention of the paragraph, I think it was just worded a little poorly

wild glen
#

true i guess

#

it probably intents to warn dumbasses that "you cant make an os without knowing shit in a low level language" (RIS trl)

#

except ris

#

it should be worshipped trl

fluid moon
wild glen
#

you can just make your processor lose its shit

wild glen
#

making a physical memory allocator

paging later trl

#

(i know its fucking required or yall are gonna kill me)

gloomy musk
#

I mean.... you don't have to do paging if you don't want to

wild glen
#

ironically classic mac os allowed itself to be overwriten

gloomy musk
#

Segmentation trl

wild glen
#

there were no defenses

#

like actually 😭

gloomy musk
wild glen
#

BeOS started like this

#

it literally overwrote mac os

gloomy musk
#

that's funny XD

wild glen
#

apple only unfucked it when mac os 10 came out

#

it was a unix now

wild glen
#

i spent like 400 years figuring out how to deal with the kernel in the memory alloc thing

i figured it out just allocate pages for the kernel (damn im stupid)

#

divide end addr of kernel by page size and then take that many pages

#

not actual paging its currently just physical memory allocation

#

not a lot of images because no visual changes

wild glen
#

did someone say something

#

i got pinged

fluid moon
fluid moon
wild glen
#

i has have int to ascii (binary???) converter

#

how do i do a regdump though

#

nevermind i doubt i need a register dump

#

i still have an itoa

wild glen
#

guys everyone who wants to actually read the github code i am sorry for my war crimes

#

jk i got the best code ever trl

#

i worked at blizzard for 90 years trl

fluid moon
wild glen
fluid moon
wild glen
#

mk

wild glen
#

FUCK

hushed briar
wild glen
#

FUCK

wild glen
#

itoa works now

#

why does it end at 0x0

#

wtf is my linker on

#

crash screen

unlike the regular one (this one has to be toggled on by user) it has more info

#

grammatical error is intentional i think

#

anyways time to do the funny memory alloc

#

i needed to know at what addr the kernel ends

#

made an itoa and this crash screen

#

time to stop using that fucking crash screen for tests

#

thought this is like ultrabullshit for a moment

#

apparently its not

#

convert this to decimal then to megabytes

#

terminal on the left to prove that its 2 gigs

#

what if i give it 4

#

new number

#

damn

#

LETS GOOOOOOOOOOOO

wild glen
#

i forgot i have base10

#

anyways if anyone wants to know what the numbers mean look to the code screenshot

#

shit the numbers are cut off

#

now not

#

the left numbers are in kilobytes

#

the right ones are in bytes

#

top is total amount of ram (no shit)

fluid moon
#

so skibidi

wild glen
#

memory management isnt as painful when you know what in the fuck you are working with

fluid moon
#

do you output to COM1 or is the UI your only way to show text?

fluid moon
wild glen
#

idk how to output to com1

fluid moon
# wild glen idk how to output to com1

it’s just I/O, you outb an initialization sequence that sets the frequency to COM1 and then you’ll be able to use the port as a bidirectional text buffer

wild glen
#

fair

#

can it be used for like communication between multiple pc's

fluid moon
fluid moon
wild glen
#

idk

wild glen
#

ok for actual communication id probably just add ethernet drivers later

#

fair enough

fluid moon
#

my logging functions print both on the ā€œUI terminalā€ and on serial

wild glen
#

im gonna make an os log program later

#

because theres no terminal text mode

fluid moon
fluid moon
#

it can save you a lot of debugging time

wild glen
fluid moon
fluid moon
#

I’m not a networking expert

#

but

wild glen
#

me neither

#

i really just want to send bytes between computers

#

(a protocolā„¢ :0)

fluid moon
# fluid moon but

you should be able to send data to a beacon (likely your router) or another another device if you’re using a bus topology

fluid moon
fluid moon
fluid moon
fluid moon
#

at the end you’ll end up with a cascade structure that becomes more abstract layer by layer:

LAN transmissions (a lot of theory, lots of hardware stuff)
Addressing (theory and implementation)
Transport (mainly algorithms implementation and some security related development)
Applications (relatively the easiest part, you just follow protocol specifications and implement them)

wild glen
#

getting stuff is just that but in reverse

fluid moon
wild glen
#

damn

fluid moon
fluid moon
#

I’m still learning as I write an ethernet driver

wild glen
#

idk it sounds understandable in theory

fluid moon
wild glen
#

more memory management:

top number is pages required for kernel
bottom number is how much memory the kernel uses

#

is it me or is that a shit ton

#

4kb pages btw

#

c does floor divisions i might have to round it up later

#

that is um

#

mildly different

#

jesus christ 😭

#

that is even more of a shit ton

#

wait i divided it by a regular 1000

#

not the hex 1000

#

me dum dum

wild glen
#

ok its 1066 instead of 1065

#

yay

#

i need 1066 pages (damn)

#

is that a lot or did i do everything right

#

it includes like literally everything

#

like the stack and all that

fluid moon
wild glen
#

its rounded up now

fluid moon
wild glen
#

real

wild glen
#

more memory progress tmrw

#

you people are smart and know your shit but like i have a bitmap of 4 kb pages and like it can allocate groups of these pages and they haved to be freed otherwise memory leak

#

(i like talking im sorry)

#

i want a separate bitmap that instead tells which task took which pages

#

also its physical memory only currently

#

virtual memory is later

wild glen
#

hopefully

#

if something takes too much memory my only suggestion is to kernel panic the system

#

or just say "you took too much memory go end your apps or some shit"

#

windows does that

#

i think

#

triple fault it trl

wild glen
#

then why

lethal summit
wild glen
lethal summit
lethal summit
#

no joke it can take multiple seconds to scan through an 8gb address space

#

they also dont provide any alignment guarantees

#

buddy allocators by default align to the size specified

wild glen
#

fair

#

how does it work

lethal summit
# wild glen how does it work

u should read the dedicated articles and implementations of it since those provide much more concise and thought out info whereas me yapping would sound like an unhelpful yapfest lol

wild glen
#

fair

#

is it multiple bitmaps layered on each other

lethal summit
#

but the idea is you have blocks that you allocate from of different sizes and when two adjacent same size blocks become free you merge them together into a larger block

#

reduces fragmentation

lethal summit
#

basically yea

wild glen
#

im gonna try making that in a simpler programming language first

#

because im stupid

lethal summit
#

faster + alignment guarantees + reduced fragmentation + all the cool kids use it

#

it's a win win

wild glen
#

wait im allocating pages though

#

ima still use it idk

#

oh

#

WAIT HOLY SHIT

#

i wanted to make that at 3 am

#

or something

#

idk its partitions

lethal summit
#

šŸ’„

rocky elbow
#

@wild glen checkout my gui

lethal summit
#

kernel window manager

wild glen
#

the color palette is a bit goofy but its cool

wild glen
#

guys rip the 4 kb of ram that is never going to be used in the os

#

and the first two megabytes of ram as well

#

hlep i need this number divided

#

what can it be divided by

#

actually fuck it more than 4 kb is lost

#

at least 8 trl

wild glen
# wild glen

idc about anything until this number is divided

#

or not all memory would able to be used :(

#

fuck it im fine with losing 8 kb

#

its not that much

#

instead of 1047920 pages it now can scan 261980 instead (buddy allocator, i think, it's like a directory tree)

#

do i need to reduce that number more

lean relic
wild glen
lean relic
#

523961

wild glen
#

yes shit

wild glen
#

he smort

#

math

#

anyways

#

im doing more directories trl

#

directoriesā„¢

#

the buddy allocation of all time

#

(i know this is 4 gb in pages, some of them are going to be blocked out depending on how much memory is in your pc)

#

(this should work fine for 32 bit)

#

( i think idk you people reading this know way more than i do )

wild glen
#

i suck at thinking so i just booted up the fucking scratch editor

idk is this how buddy allocators work im braindead

#

shouldve used a spreadsheet editor actually

#

i might be making something else

#

whatever im just gonna write a fucking memory allocator on scratch first

#

then port it

#

im geniunely too stupid to write it in c from the start

viral leaf
#

Just write in pseudo language

wild glen
lean relic
#

if i cant get figure something out i write it in psuedocode, sometimes port parts of it to a scripting language

#

like python

fluid moon
wild glen
#

currently a pmm

#

i wasnt at home for like the last 2 hours

wild glen
#

oh wait im making something else

#

yeah im reconsidering life choices šŸ”„

#

buddy allocator time

lethal summit
#

goated

wild glen
#

i made a buddy allocator on scratch trl

#

context: lol no

#

ima post the project file once im done with this fuckass

#

its gonna be ported into my os

#

there's no structs in scratch i cant make an array of structs tho

#

its gonna have structs in c dont shoot me to death

#

to have it make more sense i have to use a sorting algorithm

#

wait i found a bug

#

j

wild glen
#

i have to do a sorting algorithm

F

#

its for easier merging of free memory blocks

#

oh wait

#

ok its not a traditional sorting algorithm

#

its a filter

#

it finds free blocks in the list

#

puts them on a list and then merges the ones close by

lethal summit
#

let's say

allocate 1 page, call this LEFT

allocate 1 page, call this RIGHT

free LEFT, check if we can merge -> we can't merge

then

free RIGHT, check if we can merge -> we can -> merge it with LEFT

wild glen
#

what if free segments are fragmented tho

#

how the hell are you going to fix something like this

#

(scratch because im still not done with the testing shit)

lethal summit
#

that's the caveat of this all

lethal summit
wild glen
#

ok i think i figured out how to do that

#

thats what i was going to do either way but i think i figured out how to program that

lethal summit
#

have a blast 😃

wild glen
#

aight

fluid moon
#

it's very unlikely that you'll need a buddy allocator for pmm

wild glen
#

he said the reason why afterwards

fluid moon
#

having a buddy allocator as PMM it's a nice flex but also a pain inthe ass to write

wild glen
#

maybe

#

idk

fluid moon
lethal summit
wild glen
#

memory allocation wars

lethal summit
#

it took like 50 minutes to write gng

#

ts not hard

fluid moon
#

overkill

lethal summit
#

now my buddy allocator is not good and it has a Big Function Lock, I'm planning on parallelizing it soon

wild glen
lethal summit
#

but it is a buddy allocator

lethal summit
fluid moon
#

I like segmentation when allocating heap instead

lethal summit
#

it genuinely isn't bad

#

"Having performant code... overkil...."

#

šŸ’”

fluid moon
#

okay it's better, I'm lazy

wild glen
#

booting from rom

lethal summit
#

there we go

#

yep buddy allocators are Very Fun

#

have a blast pal

wild glen
#

propaganda solved šŸ‘

fluid moon
#

Booting from ROM...

#

why isn't kernel.c booting

#

plus who tf writes "file.C" (with capital C)

wild glen
lethal summit
#

michael soft

wild glen
#

theyre braindead anyways

lethal summit
#

i said michael soft not microsoft

#

microsoft doesnt code like that

#

michael soft might

fluid moon
lethal summit
#

facts

wild glen
#

john michael is the leader of the board of directors at michael soft

#

and/or the ceo

fluid moon
#

binbows

fluid moon
#

IT IS better than bitmap

sour pollen
#

even then, a simple freelist allocator is much easier to get right than a bitmap allocator anyway

gloomy musk
#

Freelist my beloved ā¤ļø

wild glen
#

memory allocation wars

sour pollen
#

busting the bitmap propaganda

wild glen
#

protesting against the bitmap kingdom

#

absolute revolution

#

world war 3

fluid moon
#

what complexity do freelist and buddy allocator have per allocation?

wild glen
wild glen
#

merging two free entries is a pain in the ass though if you dont know how to do it

hushed briar
#

Free list is just… a free list

fluid moon
hushed briar
#

I have an impl

#

If you’re interested

fluid moon
wild glen
#

i also do except its on fucking scratch

#

(its gonna get ported i have no other option)

hushed briar
sour pollen
wild glen
#

this is the most stupid code ever

anyways my buddy allocator works i can port it now šŸ’„

#

(i should port my os to scratch trl)

#

this is the scratch project file for the buddy allocator test thing

yall can do whatever you want with this (its a theoretical simulation of memory)

wild glen
#

im not sure if this is public shaming or is this the most random shit ever

wild glen
wild glen
wild glen
wild glen
#

even though this was already discussed

#

its still insane

fluid moon
#

going through a rewrite might be the best thing I've ever done

wild glen
fluid moon
wild glen
#

oh

fluid moon
#

I've dumped the old one

#

the codebase became spaghetti code

wild glen
#

the best thing i did is to scrap my shitty vga text mode os because half the code was stolen

#

this one is my actual try

fluid moon
wild glen
#

i was also following the shittiest tutorial on earth

fluid moon
#

your progress report thread became misc0

wild glen
#

this went from buddy memory allocation to kernel rewrites

#

if you want we can go to misc 0 idk

fluid moon
#

I think I'll go to sleep, keep reporting progress and I'll keep posting in the thread :)

wild glen
#

aight

#

gn

#

do i still do buddy allocation with pages

#

fuck it ima do it with pages

#

ok anyways

wild glen
#

ported struct

#

I LOVE THE ITOA FUNCTION AISKJDHAFHQUJKRHQWUJQWMNDHGIJSEKFQWIL>WQKHJDQWHJKD

anyways i can add malloc now

#

i made it horizontal

#

i want to print all the values in the list thing out

#

debugging šŸ‘

#

it allocated yay

#

function for it

#

it shouldnt return 0 but whatever

#

lemme make it not return 0

#

this is page allocation (palloc), malloc will return the actual memory address

#

idk if its called palloc usually

#

i just named it palloc because page allocation

lethal summit
#

windows nt function call style

wild glen
#

it isnt intentional

#

how does winnt code even look like

wild glen
#

i am now michael soft

lethal summit
#

true

wild glen
#

idk i remember seeing directx instructions like that

#

with these function calls

#

i think microsoft made them

#

these functions were long as actual fuck

#

idk i just code functions with a lot of parameters like that now

viral leaf
#

No nt style would be

NT_RESERVE_PAGE_ALLOCATOR_HELPER_FUNCTION(...)

lean relic
#

NT_RESERVE_PAGE_ALLOCATOR_HELPER_FUNCTION(
a,
b,
c,
d,
e,
f
)

wild glen
#

yo guys so like heres my plan (in order)

  • memory management
  • more memory stuff (paging)
  • scheduler
  • hard disk access
  • window management
  • file systems
  • programs
#

maybe swap fs and window management

lethal summit
wild glen
lethal summit
#

do you want multitasking in this project

wild glen
lethal summit
#

and you'll also want a side dish of synchronization primitives to go along with it

#

condvars, mutexes, semaphores, blah blah blah

wild glen
#

mk

#

oh

#

the concept is simple

lethal summit
# wild glen mk

also you didn't seem to know what a spinlock was before this, I suggest you definitely look into multithreading and write multithreaded userspace programs with pthreads in C

wild glen
#

i use interrupts for the mouse pointer already

lethal summit
#

like with mutexes

wild glen
#

fair

lethal summit
#

a simple mutex is, well, simple

but if you have thread prioirities, then you might introduce priority inheritance, and then if you want pointer sized locks, you need per-thread turnstiles and a global turnstile hash table

wild glen
#

fair

fluid moon
lethal summit
#

wdym

fluid moon
lethal summit
#

how is your os functional

fluid moon
#

I lock the spinlock in critical functions like allocators

#

the scheduler notices and doesn't switch task

lethal summit
#

what do you mean "The Spinlock" is this a BKL type thing

lethal summit
#

crazy

fluid moon
#

I'm not even planning on adding SMP

lethal summit
#

your loss

fluid moon
#

I will fall for SMP propaganda someday

#

but not today

wild glen
#

what in the fuck happened

#

also

i am tragically informing you all

#

about the lack of the cd-rom, the box, the manual, and swiss cheese in the nullium cd set

#

no warranty included either

#

in the digital edition swiss cheese has to be removed as well

#

i couldnt afford the free version of chatgpt so i have to inform you people about this tragic loss not with an essay

#

but instead 8 discord messages

#

to protest this crime cheese react the thread

#

or something

wild glen
#

i wanted to add tetris except the company making it will not like it

#

at some point

#

in the os bundle

#

which is a major ass disappointment

hushed briar
hushed briar
#

Like

#

Just create a kernel

#

And a userspace

#

Then just make your own Tetris game in c in userspace

#

Running Tetris in the kernel is

#

Bound to cause maybe a few issues trl

wild glen
#

i know

#

thats what i wanted to do

#

the company will still not like it

#

the tetris company

#

i have to license it for all my money

#

times 5403002

#

idk i dont want to run tetris in the kernel no matter how goofy asf that would be

wild glen
#

i remember a guy writing a tetris os

#

there was a youtube video or smth

hushed briar
#

there is thois popular programming youtuber who did it

wild glen
#

fair

hushed briar
#

although

#

its dogshit

#

like

#

its a cool concept but

#

the code is shit

wild glen
#

youtubers suck at programming always trl

#

except terry davis (brainfart)

#

he was a streamer though

hushed briar
#

terry davis wasnt bad

#

shit fart

wild glen
#

fart shit

#

idk youtubers absolutely suck ass at coding

#

idk how

#

idk why

hushed briar
#

you should help me with the ui of my os

#

at some point

#

when i reach userspace again

wild glen
#

why me lmao

hushed briar
#

because your shit looks great

wild glen
#

thank

#

lemme finish my homework rq i can actually finish my crappy mem allocator (PALLOC MAUAHAHAHAHAHAHAHAHAHAH how did people live with 6 letter labels)

hushed briar
#

no youre good, just at some point id be interested in that

#

if you need help with your allocator let me know

#

i have the buddy system implemented and i know a decent bit about it

wild glen
#

fair

#

i have a scratch project for it for some ungodly reason

#

you can scroll up and find it

hushed briar
#

yeah i saw

#

sometimes we need visual representations for some concepts

#

i used scratch to help me implement virtual memory

#

no shame

wild glen
#

easy to understand lego programming language that doesnt need to compile

#

shit has more debugging tools than visual studio

hushed briar
#

yeah its elite

wild glen
#

fr

hushed briar
#

i designed my clone pagemap

#

in that

#

because

#

it was fucking weird

wild glen
#

damn

hushed briar
#
int clone_pagemap(uintptr_t src_base, uintptr_t dst_base, size_t size) {
    size_t pages = _align_up(size) / PAGE_SIZE;

    for (size_t i = 0; i < pages; i++) {
        uintptr_t src_vaddr = src_base + i * PAGE_SIZE;
        uintptr_t dst_vaddr = dst_base + i * PAGE_SIZE;

        uint32_t src_pd_idx = _pd_index(src_vaddr);
        uint32_t src_pt_idx = _pt_index(src_vaddr);

        if (!RESOLVE_RECURSIVE_PD[src_pd_idx].present) continue;

        pte_t* src_pt = RESOLVE_RECURSIVE_PT(src_pd_idx);
        if (!src_pt[src_pt_idx].present) continue;

        uintptr_t src_paddr = src_pt[src_pt_idx].frame_addr << PAGE_SIZE_SHIFT;

        page_attrs_t attrs = {
            .present = src_pt[src_pt_idx].present,
            .rw      = src_pt[src_pt_idx].rw,
            .user    = src_pt[src_pt_idx].user
        };

        void* dst_frame = pmm_alloc_page();
        if (!dst_frame) return -1;

        flop_memcpy(dst_frame, (void*)src_paddr, PAGE_SIZE);
        attrs.frame_addr = ((uintptr_t)dst_frame) >> PAGE_SIZE_SHIFT;

        if (map_page(dst_vaddr, (uintptr_t)dst_frame, attrs) < 0) {
            // Rollback previous mappings
            for (size_t j = 0; j < i; j++) {
                uintptr_t undo_vaddr = dst_base + j * PAGE_SIZE;
                unmap_page(undo_vaddr);
            }
            pmm_free_page(dst_frame);
            return -1;
        }
    }

    return 0;
}
#

cancer fr

wild glen
#

ok im done with the homewo- WHAT THE FUCK

#

cancer indeed

hushed briar
#

just look at any vmm.c in any os

#

its just fucked

#

i added a bunch of protections features too

#

my shit is 1k lines of code for no reason

wild glen
#

ok now im scared of adding vmm

hushed briar
#

nah

#

you only need 2 functions

wild glen
#

oh ok

hushed briar
#

for a "vmm"

wild glen
#

also what do i do with the pmm once i have virtual memory

#

it shouldnt just vaporize

hushed briar
#

wdym

#

no

#

the vmm is just an abstraction of physical memory

wild glen
#

true

hushed briar
#

so you need a pmm

wild glen
#

i still allocate physical memory

hushed briar
#

to give you pages

#

yes

wild glen
#

then make it pretty to make it virtual

hushed briar
#

i guess you can say it like that yes

wild glen
#

idk

hushed briar
#

you just need to be able to map pages to a virtual address

#

which isnt crazy

wild glen
#

not sure but iirc paging or whatever allows to like block off access to the kernel in user space

wild glen
#

from yesterday i have this absolute fart

hushed briar
#

beatiful

wild glen
#

doesnt map actual memory addresses actually

hushed briar
#

valid? free? šŸ—£ļø

wild glen
#

im gonna add a parameter in the struct for that

wild glen
#

mem location

first is base16 second is base10

#

too much effort for a debug table that will get sent to the shadow realm shortly after using it

#

i need to write a spreadsheet editor for nullium after i get to userspace and shit

#

size is in pages btw

hushed briar
#

Wanna look at my impl

wild glen
#

i mean sure ig

#

the table is helpful though

#

its all debugging and stuff

hushed briar
#

No this is good

#

This file is a banger

wild glen
#

truly

#

i made an allocator that cuts exactly how much you ask instead of just the middle

hushed briar
#

Oh

#

I see

#

That isn’t a buddy then tho

wild glen
#

:0

hushed briar
#

Because buddy blocks are supposed to be powers of 2

#

But

#

It’s fine lol

#

No one cares

fluid moon
wild glen
#

then what did i make lmao

hushed briar
#

A memory allocator

#

Which works

wild glen
#

i made my own algorithm i should trademark it

hushed briar
#

So who cares

#

Idk exactly what that would be called

#

Someone with more knowledge than me could probably tell you

fluid moon
wild glen
#

i mean its like hard disk partitions

hushed briar
fluid moon
hushed briar
wild glen
hushed briar
#

Which is cool

wild glen
#

not damnit

hushed briar
#

Nothing wrong with those

#

Shit, Linux used one for years

wild glen
#

tried to write a buddy allocator but i got a freelist ;-;

#

im this bad at understanding things

fluid moon
hushed briar
wild glen
#

lmfao

#

anyways

hushed briar
#

Meaning that it presents memory to applications and the kernel in a way to where each process has its own ā€œaddress spaceā€

fluid moon
hushed briar
#

Dividing what

wild glen
#

(#osdev-misc-2?) /j

fluid moon
hushed briar
#

Well then sure

hushed briar
wild glen
#

nah its fine

#

yall can talk

hushed briar
#

My thread has a lot of that happening sometimes

wild glen
#

fair

hushed briar
#

It’s mainly just me being schizophrenic tho

wild glen
#

shit happens 😭

fluid moon
#

terry

wild glen
#

elephant simulator

wild glen
#

it grows from the top

hushed briar
wild glen
#

indeed?

hushed briar
#

Well

#

Now the big question

#

Does it work?

wild glen
#

uh

#

i think

#

lemme check

#

if i can alloc then i can go make a free-er

hushed briar
wild glen
#

The

#

id say it works

#

would these interfere though

#

actually nah ion think they would

#

tell people "size means end address"

wild glen
#

FREE

#

FREE MEMORY FOR FREE

#

time to merge it

hushed briar
wild glen
#

ibm ultrabay specifications when

wild glen
#

it can merge now

before:

#

after:

#

time to test it

#

add a few memory segments then do stuff to them

#

so the merger works fine

#

except it doesnt merge all the free segments

#

ж

hushed briar
wild glen
#

look closer

#

im done with page allocation

#

yay

#

do i do paging next or do i add a malloc()

hushed briar
hushed briar
#

You need that anyway to make a proper malloc()

wild glen
#

oh

#

fair

#

lemme just do page allocation for kernel space

hushed briar
#

Yeah that’s fine

#

Although

#

A good kernel heap allocator is really nice

#

Because imagine you need a 30 byte allocation

#

You would do a page alloc

#

And waste

#

4066 bytes

#

With only 3 being used

#

Internal fragmentation

wild glen
#

mk

#

not sure if i add one but thanks for the info

hushed briar
#

Well

#

If you wanna waste all your memory sure

#

No actual sane kernel does that tho

wild glen
#

rip

wild glen
#

not do the heap allocator or do it

hushed briar
#

Not do it

wild glen
#

i think i can do a heap actually

#

theres a point in it

#

other than you telling that all the cool people are using it

#

github push

added physical memory allocator

hushed briar
#

Like

#

Imagine how many small allocations there is for thread structs

#

Imagine each of them taking a whole ass page

wild glen
#

im gonna make system processes use cooperative multitasking

this only includes the file explorer (im gonna call it the browser for shits and giggles) and system menu and error messages really

#

nothing else

wild glen
lethal summit
#

huh

wild glen
#

absolutely everything except the fucking file explorer is gonna be preemtive

vocal root
#

did classic macOS/aux even use pre-emptive multitasking

gloomy musk
wild glen
lethal summit
#

nope

vocal root
#

so if this is a/ux style co-operative multitasking is fine 😭

wild glen
#

a/ux was a unix though

lethal summit
#

oh right I forgot about that part of the project

#

ok then lgtm Have Fun

wild glen
#

i just realized this shit will not be a unix 😭

#

maybe i should just make it a classic mac os-like os

im just gonna keep the classic mac os part of it

#

theres still gonna be a text ode

#

mode

#

and bash

#

and shit

gloomy musk
#

UNIX is overrated trl

wild glen
#

indeed

#

Nullium - a classic Mac OS like OS (some unix elements present)

#

more accurate

#

its gonna have preemptive multitasking

#

but the file explorer is just built different

wild glen
#

how do you load paging

or like a page directory

#

how do you even use this shit afterwards

#

im confused

#

the article on the wiki (osdev.org) uses gas while i use nasm

lethal summit
#

just convert the syntax

wild glen
#

i can understand everything else

lethal summit
wild glen
#

oh

#

gnu is evil

#

full stop

#

thx a lot

#

it triple faults

gloomy musk
wild glen
#

tmrw im gonna fix my shitty paging

#

apple's liquid glass looks like total farts imo so im gonna make a cooler one trl

#

like excuse me what the fuck are these icons

wild glen
#

should the menu panel be at the top of the screen

#

note that even if it was at the bottom it functions nothing like the windows one

#

fuck it im moving it up to the top

wild glen
#

paging shits itself

#

as usual

#

i hate it

#

i hate it and i need it

gloomy musk
#

😭

wild glen
#

i dont want my fucking kernel to be rewritten by a program that wont be exactly cash money

#

i really just want this specifically

#

i dont care for anything else i want isolation from the kernel

gloomy musk
#

Segmentation trl

hushed briar
#

Stop right there

#

šŸ’€

gloomy musk
#

🤣

#

ye I'm obviously joking, pls don't use segmentation

wild glen
#

i forgot what that

gloomy musk
#

good, keep it that way meme

hushed briar
#

Even tho paging existed for 30 years before intel started supporting it

hushed briar
#

We took a big ass step backwards

wild glen
#

intel chose to be smartasses?

#

ok yeah that

hushed briar
#

Yeah

#

We had paging computers in the 60’s

#

And Intel didn’t support it until the late 80’s

wild glen
#

hardware or software

hushed briar
#

Uh

hushed briar
#

That’s what I’m targeting

#

Although paging was still optional

#

You could still do segmentation

#

For example Microsoft DOS used segmentation

wild glen
#

dos is like the first x86 operating system it just uses whatever came out first

#

fair

hushed briar
hushed briar
# wild glen wdym

I mean I guess it’s an os but it’s pretty useless compared to most operating systems

wild glen
#

its still an os

#

operating systems are bloated to hell these days

#

even linux

hushed briar
#

There’s no multitasking, no memory protection of any kind, only ring 0, lack of hardware abstraction

hushed briar
wild glen
#

ok true lmao

hushed briar
#

I main the core kernel code is good for sure

#

But drivers/

#

Is just fucked

#

Also just the naming on the drivers too

wild glen
#

that folder is ultimate abomination of intel, nvidia, ati, and 5000 shitty programmers

hushed briar
#

Wtf is half of this shit

wild glen
#

this is like reading chinese

gloomy musk
wild glen
#

nullium goal 2: dont make the driver folder look like the one in linux

hushed briar
#

Mine is somewhat sane

wild glen
wild glen
gloomy musk
hushed briar
#

I feel like these folder names should be EASYto understand

wild glen
#

mine looks like this

hushed briar
#

Yeah that looks fine

#

I prefer folders for drivers

wild glen
#

some drivers are in the arch folder

#

these are somewhat universal

#

as in they work both for x86_64 and i386

hushed briar
#

Mmmm

wild glen
#

allegedly

#

(outb always existed)

hushed briar
#

You drivers shouldn’t be arch specific period

gloomy musk
#

I have yet to get to the point of having any drivers lol

wild glen
#

its really just boot init stuff

hushed briar
wild glen
#

congratulations

#

i did everything right

#

in the arch folder is just paging (ptsd), gdt, idt, system entrance etc

hushed briar
#

That’s what should be there yeah

#

Drivers aren’t arch specific

wild glen
#

i guess

#

idk if theres an outb instruction in like powerpc

hushed briar
#

There’s an equivalent

#

Write a byte to a port

#

That is universally available

wild glen
#

thats what outb is

#

so the evil ps2-x86 will work on literally anything if outb gets ported to [insert whatever]?

#

awesome

hushed briar
#

Something like that

#

Yes

wild glen
#

cool

#

making an x86 thing currently though

#

the most no shit thing i said

hushed briar
#

X86 is definitely a mess tho

#

I feel like any big hardware/software will be messy

#

Like the Intel SDM is extremely cumbersome

#

To read

#

And a lot of the mnemonics don’t even make sense

lethal summit
#

ARM has no in/outb

#

the IRQ abstraction here is also x86 specific

hushed briar
#

Not an exact equivalent

#

But you need some way to write to data ports lmao

lethal summit
#

which means it wont work at all

#

those ports are MMIO on arm

hushed briar
#

Oh yeah mmio I forgot arm does that

lethal summit
#

you'd want ps2_read/write functions that compile to in/out on x86 and whatever else on ARM

#

so this code is correct for being PS2-x86.c

hushed briar
#

Yeah true but it wouldn’t work for arm

lethal summit
#

you wouldnt entirely rewrite it for Arm, you would just introduce arch-agnostic abstractions like a ps2_read/write

hushed briar
#

So it would be a mmio write and read rather than outb and stuff

#

Makes sense

wild glen
#

IT TRIPLE FAULTS AGAIN

#

IM GONNA FUCKING KILL SOMOENE

#

is there any fucking sensible instruction on paging anywhere on the fucking internet

hushed briar
#

Show me your code

#

Maybe I can help trl

#

Nah but fr I can try to help

wild glen
#

a sec

#


unsigned long *page_directory = (unsigned long*) 0x9C000;
unsigned long *page_table = (unsigned long*) 0x9D000; 

extern unsigned long read_cr0();
extern unsigned long read_cr3();

extern void write_cr0(unsigned long);
extern void write_cr3(unsigned long);

void init_Paging(){
    unsigned long address=0;
    unsigned int i;

    // only first 4mb of memory
    for(i=0; i<1024; i++)
    {
    page_table[i] = address | 3;
    address = address + 4096;
    };

    page_directory[0] = (unsigned long)page_table; 
    page_directory[0] = page_directory[0] | 3;

    for(i=1; i<1024; i++)
    {
    page_directory[i] = 0 | 2; // attribute set to: supervisor level, read/write, not present(010 in binary)
    };

    write_cr3((unsigned long)page_directory); 
    write_cr0(read_cr0() | 0x80000000); 
}

followed the thing on the bona fide osdev site

#

this is total farts

#

global read_cr0
read_cr0:
    mov eax, cr0
    retn

global write_cr0
write_cr0:
    push ebp
    mov ebp, esp
    mov eax, [ebp+8]
    mov cr0,  eax
    pop ebp
    retn

global read_cr3
read_cr3:
    mov eax, cr3
    retn

global write_cr3
write_cr3:
    push ebp
    mov ebp, esp
    mov eax, [ebp+8]
    mov cr3, eax
    pop ebp
    retn

assembly

#

your implementation is somehow way simpler than whatever the fuck everyone else is doing

#

@hushed briar