***dongcarl3 is now known as dongcarl
<oriansj>BSDs and OSX pass arguments to the kernel on the stack; pushed right-to-left (first argument is the last one pushed and the last argument is the first pushed onto the stack), syscall number in the eax register and call by interrupt 0x80 <oriansj>So the only things one would need to change to port is the syscalls and nothing else as that is the only part that is Operating system specific <oriansj>it might be easiest if we did the port for M2libc first so that you have a good reference point for the system syscalls needed <oriansj>oh and that above is only for 32bit OSX, they do something completely different for 64bit OSX <oriansj>arguments are passed on the registers rdi, rsi, rdx, r10, r8 and r9 and the syscall number in the rax register with the call is done via the syscall instruction and appears to follow: http://x86-64.org/documentation/abi.pdf but seems to add 0x20000000 to the syscall number for some odd reason <oriansj>oh and for extra fun: Apple is also known to break the syscall ABI between MacOS versions <stikonas_>I guess that's what you get with closed platforms... ***stikonas_ is now known as stikonas
<stikonas>they can get away with it since they also update libc at the same time <unable_to_execut>if i wanted to change the syscalls for the elf / a.out file "tape02" output executable. should i be looking to edit "VM" "M0" the stage1 assemblers , all of the above , or something different entirely ? <unable_to_execut>figured i would just ask before going an installing something like "linuxulator" <unable_to_execut>last time i was here skitonas said it would be fairly easy if i learned a bit of assembly <unable_to_execut>thanks again for help last time btw i was able to get the vm going by adding more mem <unable_to_execut>i grabbed these , im willing to change the syscalls but any help would be really great <unable_to_execut>i really wouldn't know what im doing im not an asm programmer but i really want this to work on Mac <unable_to_execut>ok i guess i will look at this , but ofc i have no experience or clue what im doing i will start with m2 maybe? even tho i haven't been able to compile m2 without cc_x86 i can cheat or w/e... anyways thanks i guess ill just hang out or check by later to see if you have any more info <unable_to_execut>im gonna go look at this stuff i may be a while but will def check in later thanks alot oriansj stikonas[m] (y) <stikonas>unable_to_execut: syscalls are directly called in all programs written in hex or assembly programs, so hex0, hex1, hex2, M0 and cc_x86. Then for C programs they are hidden inside C library (M2libc), so you would have to port it once and all C programs would work <stikonas>but syscalls are only important for stage0-posix, not baremetal stuff from stage0 <stikonas>as you can see function open on x86 on Linux has sycall number 5 which is hardcoded in hex0 <stikonas>that 5 might be different on different OSes <stikonas>or even different instruction sets (e.g. arm) on Linux, but different CPU arches of course require significant porting, where as same arch but different OS is easier, just need to adjust a few constants <unmatched-paren>I don't really see the point of porting bootstrap to mac, but if you think you'll enjoy and learn from it, then okay <checkup>so if i wanted to use vm's how do i execute cc_x86 ? / cc_knight? <checkup>heres what i have been doing , i rather use the vms <unmatched-paren>I suppose Darwin could benefit from it. I wonder if anyone is actually using Darwin standalone though. <checkup>would be nice once i figure out how this works, yea i rather use vm's tapes, but i dont know what to do with the output from the cc_x86 tape? how does it execute with vM theres no instructions past that in "bootstrapping_steps.org" <stikonas>yeah, personally I wouldn't port bootstrap to mac, but I wouldn't oppose it. One can then start on Mac and e.g. bootstrap linux from just source <checkup>Our C compiler will read any code in tape_01 and output the compiled output to tape_02. <checkup>The compiled output is macro assembly (allowing for easy inspection) which then must go through the appropriate macro assembler and hex2 steps to become a working binary. <checkup>Should you wish to port the C compiler to a different target, one need only update the strings and a few minor places in the code; looking at M2-Planet's multi-arch support will cover all of those questions quickly. <checkup>im basically stuck right here , with the "VM" <checkup>1b44b454b8e7beab41ecc4fb81220ef0a396bfeb954a3589861b6807dea0c313 <checkup> i have this hash but dont know how to use it <checkup>theres no instructions for how to run compile or hash check anything from the bootstrapsteps c compiler <checkup>its actually really dissapointing and frustrating cuz the instructions were so clear up till then... <checkup>i tried just running m2 thru it maybe i need 2 do something with the M2 tape just keep pushing past <checkup>yea no im not married to mac, i rather have this work on w/e machine <checkup>i thought thats what the promise of the vm was <stikonas>checkup: so have you tried increasing vm ram? <stikonas>I haven't worked much with stage0 stuff but I think you input C source (if you have a few files you need to first combined them into one file in the right order) in tape_01 <checkup>ill check back later im probably just confused about the jump from cc_x86 to m2 cuz the gap / lack of instructions on bootstrapping steps <stikonas>and M0 assembly will be spit out in tape_02 <stikonas>then assembler spits out unliked binary code <stikonas>take a look at some stage0-posix steps, it might become clearer <checkup>i cant run posix on mac and like using the vm but i can do that for sure <stikonas>unmatched-paren: yes, but posix in stage0-posix right now is linux <checkup>the vm has an assembler i dont want to use nasm its bloated <stikonas>checkup: so as you can see to go from C to binary you need a few steps <stikonas>1) cat C files into single file (or tape in stage0) <checkup>yea i will check it out i appreciate your help <checkup>hold on i will show u exactly wut i do <stikonas>then 3) cat M0 definitions, C entry point and tape from step2 into one M0 file <checkup>how does m0 run on the vm , do. u have much experience with the vm? <checkup>also i really would love 2 run that vm on fpga <stikonas>then next step where ELF header is attached is not relevant to stage0 and so 5) run everything through hex2 <stikonas>well, that VM is just a small emulator for knight architecture <stikonas>and we compiled M0 program for that architecture in the previous step <stikonas>checkup: some old CPU arch from seventies <checkup>Knights Hill (KNH) was a planned successor to Knights Landing, a 10 nm many-core microarchitecture designed by intel for high performance computin <stikonas>but right now consider it an arch that only has emulators and no real hardware <checkup>i want to beable 2 bootstrap the same compiler on both my computers <stikonas>the good thing about knight is that it only has 2 tapes, 1 in and 1 out. You don't need to worry about e.g. disk, how to deal with drivers, etc <checkup>im def gonna look thru this chat and try to get this goin on the vm <stikonas>checkup: and once you get everything working, it would be nice if you could update documentation <stikonas>cause stage0 is less used and hence more poorly documented <checkup>yea bootstrapping.steps.org is what i have been using <checkup>and it pretty much drops off after cc_x86 <checkup>insetad of going into m2 so if i figure it out and get it able to peirce thru 2 mes tcc <stikonas>oh also when building m2-planet you need to use cc-mini.c instead of cc.c <checkup>and get my high level compilers going i wiill definately be more confident about telling anyone else how to do it <stikonas>well, when you combine m2-planet source into a single file <checkup>i have like all the different versions from savana etc <checkup>so im just grapping peices and using w/e works <stikonas>yes, but it's like 10 versions behind :) <checkup>i did a cat but didnt' have much more luck with that <stikonas>M2-Planet in git repo is way more capable now, it has some support for preprocessor, etc <checkup>like i definately try everything in the docs its whats not in the docs thats getting me messed up <stikonas>oh, but keep in mind that M2-Planet_x86.c would be x86 version <stikonas>so maybe if you want to run it on Knight, you'll have to grab files from M2-Planet.git repo <checkup>lfs.master@lfsmasters-MacBook-Pro CC_KNIGHT]DEV]M2]ON]0002 % ./bin]vm/vm --rom cc_x86/cc_x86 --tape_01 M2-Planet_x86.c --tape_02 tape02]OUTS/M2planet --memory 2500K <checkup>After Executing 16966733 instructions <checkup>lfs.master@lfsmasters-MacBook-Pro CC_KNIGHT]DEV]M2]ON]0002 % cat defs tape02]OUTS/M2planet > temp <checkup>lfs.master@lfsmasters-MacBook-Pro CC_KNIGHT]DEV]M2]ON]0002 % ./bin]vm/vm --rom M0/M0 --tape_01 temp --tape_02 temp2 --memory 1500000k <checkup>After Executing 112690395 instructions <checkup>lfs.master@lfsmasters-MacBook-Pro CC_KNIGHT]DEV]M2]ON]0002 % ./bin]vm/vm --rom stage1_assembler-2/stage1_assembler-2 --tape_01 temp2 --tape_02 tape02]OUTS/cc_Out]M2planet --memory 50000K <checkup>After Executing 16359742 instructions <checkup>lfs.master@lfsmasters-MacBook-Pro CC_KNIGHT]DEV]M2]ON]0002 % <checkup>so i have this "cc_Out]M2planet" files <checkup>]0002 % file tape02\]OUTS/cc_Out\]M2planet <checkup>≠ÌÆÍ:fiˇÏ͛ӥ≠ÓÎÎŒÏ≠ÌÆÌÍ˸˛ÕÍfi⁄Ó°Ífi⁄Ó§≠Ô˛Œ≠fiÎJfiÓ∫fiˇÏ͛ӻ≠ÌÆÌ≠Ô˛Œ≠fiÎ≠ÓÎ≠Ô˛Œ≠fiÏäfiÓ fiˇÏ͛ӑ≠ÓÌ≠ÌÆÍXÍ≠ÌÆÍû™€Æ≠fiÍäfiÓ™fi⁄Ó†Î≠fi晀Ó∞PÓÎÓÓ˛ <stikonas>oriansj: is M0 from knight architecture compatible with x86 one? <checkup>i imagine some part of stage0 is equipped to read it or vm? <stikonas>checkup: no, I think that is x86 machine code <checkup>i think knight and x86 give same result. <checkup>oh ok i can use the cc_knight compiler and try again <stikonas>checkup: ok, M0(x86) and M0(knight version) might be giving the same result <stikonas>well, cc_knight might be more interesting for you <checkup>and thats past bootstrapping.steps.org <checkup>thats just me doing stuff on my own trying 2 work thru <checkup>- M2-Planet (v1) compiles blood-elf (v1) <checkup>- M2-Planet (v1) compiles hex2 (final) <checkup>- M2-Planet (v1) compiles blood-elf (final) <checkup>- M2-Planet (v1) compiles get_machine <checkup>- M2-Planet (v1) compiles M2-Planet (final) <checkup>- M2-Planet (final) compiles mescc-tools-extra (see next step) <stikonas>yes, that's a summary for steps, but on knight architecture you won't be able to go beyond M2-Planet <checkup>so i guess i should forget about knight if im trying to do mes. <stikonas>mes itself maybe not so hard, but mescc would be hard <stikonas>checkup: bootstrap till gnu would be a very hard project <stikonas>with lots of different people working on different parts we only got x86 on Linux <checkup>oh i was under the impression you got tcc / gcc <stikonas>arm and risc stop at either stage0-posix or mes <stikonas>there is somebody porting mes/mescc to riscv64 <stikonas>well, mes is a few hours of work but mescc is tricier <stikonas>we have to go through lots of old software <stikonas>that was not written with portability to other arches in mind <checkup>i dont mind python but compilers needing that is weird <stikonas>though we are going to add python to live-bootstrap <stikonas>checkup: but gcc needs Perl for its build system <checkup>if im being stubborn, i guess my best bet would be to try to install "LTP" linuxulator on my bsd, and bootstrap posix to gcc and see where that gets me? thats what i was planning on doing today <checkup>i dont really know what else to do if vm isn't gonna perform fully <checkup>i haven't really mastered porability of qemu and bridged networking etc <checkup>im really trying to go for a portable bootstrapper <checkup>yea i haven't really mastered that but that sounds like solid advice <stikonas>checkup: as for knight, keep in mind that baremetal stuff can only get you so far... You are basically limitted to one input file and one output. Forget about shells, etc, no bash, so no autotools, etc... <checkup>sorry i got disconnected.. yea i just been really bummed about building software only to have the underlying compiler change etc. especially on mac/ios was hoping i could get a stable enviornment <checkup>mandatory macos updates and what not <stikonas>I just said: "checkup: as for knight, keep in mind that baremetal stuff can only get you so far... You are basically limitted to one input file and one output. Forget about shells, etc, no bash, so no autotools, etc..." <checkup>ive seen a forth c compiler for "2klinux" <stikonas>you can do some easy steps without OS, but at some point you need OS for bootstrapping and knight VM wouldn't be good for that <stikonas>yeah, NieDzejkob is occasionally on this channel <checkup>yea i looked at that first, dont really know what to make of it <stikonas>this is a x86 kernel that can run all steps in stage0-posix <checkup>im really trying to push towards a portable uefi boot kernel with a portable compiler <stikonas>one could right something similar for UEFI I guess <checkup>was really hoping vm would see thru 2 that but i guess it was a pipe dream <stikonas>anyway, bootstrapping is probably harder than what you thought :) <stikonas>we want to write some kernel in M2-Planet dialect <stikonas>and if there will be, initially it will be x86 only <stikonas>though I guess one could build M2-Planet for knight in thatvm <checkup>would have been really cool even if u had a knight fpga <checkup>that way u could be on x86 or fpga or emulate either or <stikonas>yeah, that might be cool project but we don't have anybody working on that <checkup>not really a whole lot of other players in the game it seems u guys are the only ones who really care about bootstrapping trusted compiler <checkup>yea i would like to take a pi shaped fpga and put it in a "kano" pi laptop and call it a day <checkup>get a x86 emulator and uefi going on it and just have self bootstrapping laptop <checkup>i just prefer doing work on laptop is the problem <stikonas>for bootstrapping it is more important to have an implementation <stikonas>not necesserily standard compatible implementation <checkup>all new laptops use uefi. they dont even allow mbr. it seems at least the ones i have. so i kinda wanted my machines 2 work , be mine <stikonas>everywhere I saw you could switch on legacy mode <checkup>seems that now they dont even let u use uefi (msft) <checkup>they want a vm on the machien so u have no bootccontrol <stikonas>but e.g. in live-bootstrap the shell scripts are bash specific, they are not POSIX compatible scripts <stikonas>which I guess is why they don't enable legacy mode <checkup>i guess im a hacker or something lol <stikonas>personally I wouldn't buy microsoft stuff... <checkup>the way i want. w/e i dont wanna complain <checkup>yea i only would really trust fpga nowadays i dont wanna champion different vendors and then be let down later on down the road <checkup>thats basically how i feel about mac <stikonas>they might also have some secure boot stuff on those things <stikonas>so you can't even boot your stuff, nevermind about bootstrapping compiler <checkup>well thats easy 2 shutoff or bypass with a hash <checkup>like u can literally get a secure hash for your stuff its pretty ez <checkup>if u have a kernel u want 2 secure boot, u maybe a vendor or something , but yea i think thats goin away with msft going 2wards these vm only boots <checkup>it just boots right into a vm no uefi no mbr nothing <checkup>im sure this is basically what apple is using <checkup>inside something like this. maybe 100 bucks to make shipping for 3k + <checkup>so yea. knight vm full thru 2 clang/gcc2 uefi would be really nice <checkup>but maybe overly ambitious giving the current state of stuff. but yea. if ur gonna keep deving definately keep that in mind pls !thanks for your time i will mess around with some of this stuff and see if i can get anything going