IRC channel logs

2022-10-28.log

back to list of logs

***ChanServ sets mode: +o rekado
<stikonas>oriansj: any preference on how we select linux vs UEFI in M2-Planet?
<stikonas>define that we need to pass via command line?
<stikonas>actually not in M2-Planet but we'll need to do it in M2-Mesoplanet
<stikonas>hmm, maybe that question can wait then
<oriansj>stikonas: how does --host posix vs --host UEFI vs --host bare-metal sound?
<oriansj>or maybe --operating-system posix vs --operating-system UEFI vs --operating-system none
<oriansj>possibly --operating-system linux so that we have different folders for the *BSDs and the rest
<stikonas>and defaults to --host posix?
<stikonas>or --operating-system posix
<stikonas>hmm, maybe should actually be linux
<stikonas>since those includes are linux specific
<stikonas>or do other posixes follow linux syscall numbers
<oriansj>no, they do not (even have radicially different calling conventions)
<stikonas>ok, so maybe --operating-system linux
<stikonas>which can be default
<stikonas>or --operating-system UEFI
<oriansj>possibly default to the host?
<stikonas>hmm, good question, maybe
<muurkha>stikonas: a lot of other OSes support running Linux binaries now, for which purpose they support the Linux syscall numbers and calling conventions
<oriansj>as we can set that with -D when we build M2-Mesoplanet
<stikonas>I think M2-mesoplanet does default to host arch already
<oriansj>so that would match
<stikonas>anyway, that is still some time away
<stikonas>I've barely started looking and porting M2libc
<oriansj>but it is something to think carefully about as changing it in the future might be more complex
<stikonas>hmm, why do we have mknod so early, just because it was easy to add?
<oriansj>yep
<stikonas>I guess that's return -1 in UEFI...
<oriansj>and for setting up /dev/null if I remember correctly
<oriansj>and we can sort it out later if we choose to build anything more advanced than M2-Mesoplanet on UEFI
<stikonas>oriansj: hmm, what do you think I should do with void* malloc(unsigned size) function
<stikonas>right now it is in top level stdlib.c
<stikonas>but I need a different implementation that does not use brk
<stikonas>so I guess I should move it to linux dir...
<stikonas>oh, maybe I can just use defines in the file
<oriansj>or just make the brk function in UEFI
<oriansj>and just return 4MB pages
<stikonas>hmm... might need to rething how I allocate memory
<stikonas>I though of using 4 MB pages
<stikonas>but one page might be disconnected from the other
<oriansj>hmmm
<stikonas>well, maybe I can hide it somehow in brk implementation
<stikonas>add some layer that maps address
<oriansj>we could do a slab allocator
<stikonas>maybe, that would still work in linux...
<stikonas>so maybe we just improve that malloc in top-level stdlib.c
<oriansj>well it definitely would work on linux and enable us to have proper free() as well
<oriansj>it just involves us adding a bit of complexity but nothing too serious
<oriansj>assuming we allocate 4MB blocks
<oriansj>the first block would be enough to track 4GB of RAM
<stikonas>I'll have to read up a bit more on slab allocators...
<stikonas>so 1st block will store some kind of map?
<stikonas>where the memory is located
<oriansj>basically we can only cut a block in half 4MB, 2MB, 1MB, 512KB, 256KB, 128KB, 64KB, 32KB, 16KB, 8KB, 4KB, 2KB, 1024, 512, 256, 128, 64, 32, 16, 8, 4bytes
<oriansj>and we allocate the first block that is big enough
<stikonas>ok, makes sense
<oriansj>although that might make a problem if we need to allocate more than a single block for a single object
<stikonas[m]>So more than 4MiB?
<stikonas[m]>Yeah, we can't guarantee that blocks are next to each other...
<oriansj>but I guess we could add logic for merging of blocks but then we would need more tracking logic
<stikonas[m]>But I guess we rarely have allocations if more than 4MiB in calloc
<stikonas[m]>Or just use bigger than 4Mib blocks...
<oriansj>say use an integer to store the 2^n size
<oriansj>then we have a pointer to the base address
<stikonas[m]>But calloc expects continuous memory, doesn't it?
<oriansj>so the first block is just an array of structs {int size; void* base;};
<stikonas[m]>On uefi we can't guarantee that blocks are next to each other....
<stikonas[m]>Though we can request bigger block...
<stikonas[m]>If we get huge calloc request
<stikonas[m]>And where do we store which segments are used?
<stikonas[m]>OK, found some docs https://www.kernel.org/doc/gorman/html/understand/understand011.html