Move to new build system.

This commit is contained in:
TomAwezome 2021-10-31 20:04:05 -04:00
parent 7b3a983443
commit 8306996ff4
16 changed files with 191 additions and 104 deletions

3
.gitignore vendored
View file

@ -1,3 +1,6 @@
*.BIN* *.BIN*
*.MAP *.MAP
Boot/ Boot/
ZealOS-*.iso
sync_repo.sh
sync_vm.sh

View file

@ -32,15 +32,15 @@ Features in development include:
- For running in a VM: Intel VT-x/AMD-V acceleration enabled in your BIOS settings. (Required to virtualize any 64-bit operating system properly.) - For running in a VM: Intel VT-x/AMD-V acceleration enabled in your BIOS settings. (Required to virtualize any 64-bit operating system properly.)
- Working knowledge of the C programming language. - Working knowledge of the C programming language.
Every commit contains a "ZealOS-YYYY-MM-DD-HH_MM_SS.iso" in the root of master, which is a timestamped ISO build of that commit. Use this ISO for installation: see the Wiki for guides on installing in [VirtualBox](https://github.com/Zeal-Operating-System/ZealOS/wiki/Installing-(Virtualbox)), [VMWare](https://github.com/Zeal-Operating-System/ZealOS/wiki/Installing-(VMWare)), and [bare-metal](https://github.com/Zeal-Operating-System/ZealOS/wiki/Installing-(Bare%E2%80%90metal)). To create a Distro ISO, run `build_iso.sh` in the `build/` directory. After creating an ISO, see the Wiki for guides on installing in [VirtualBox](https://github.com/Zeal-Operating-System/ZealOS/wiki/Installing-(Virtualbox)), [VMWare](https://github.com/Zeal-Operating-System/ZealOS/wiki/Installing-(VMWare)), and [bare-metal](https://github.com/Zeal-Operating-System/ZealOS/wiki/Installing-(Bare%E2%80%90metal)).
### Contributing ### Contributing
This is basically a read-only repository. Everything happens inside the OS, as intended by Terry. After you've installed the latest release in a VM and made your changes, you can run the `K.CC` file in the Home/ directory to build a Distro ISO. Then, use either the `mnt.sh` or `export.ps1` script to merge your changes & Distro ISO to the repo. There are two ways to contribute. The first way involves everything happening inside the OS, as intended by Terry. After you've built the latest ISO, installed to a VM, made your changes, and powered off the VM, you can run the `sync_repo.sh` script to merge your changes to the repo.
Alternatively, you can put individual files into a folder, and run `RedSeaISO("MyChanges.ISO", "/Home/Folder");` to package them into an ISO, then use the mount scripts to export the ISO. Alternatively, you can edit repo files using an external editor, outside of the OS.
Afterwards, you can make a pull request on the `master` branch. (Make sure to include either the new Distro ISO or package ISO in the pull request, since all other files on the repo are read-only and overwritten each commit: all merges are done manually.) Afterwards, you can make a pull request on the `master` branch.
## Background ## Background

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,7 +1,11 @@
#!/bin/bash #!/bin/bash
# Build Distro ISO using AUTO.ISO minimal auto-install as bootstrap to merge codebase, recompile system, and export ISO
# Run this script inside build/ directory # Run this script inside build/ directory
echo "Making temp HDD, running auto-install" echo "Making temp HDD, running auto-install"
qemu-img create -f raw ZealOS.raw 256M qemu-img create -f raw ZealOS.raw 192M
qemu-system-x86_64 -machine q35,kernel_irqchip=off,accel=kvm -drive format=raw,file=ZealOS.raw -m 2G -smp $(nproc) -rtc base=localtime -cdrom AUTO.ISO -device isa-debug-exit qemu-system-x86_64 -machine q35,kernel_irqchip=off,accel=kvm -drive format=raw,file=ZealOS.raw -m 2G -smp $(nproc) -rtc base=localtime -cdrom AUTO.ISO -device isa-debug-exit
echo "Mounting" echo "Mounting"
sudo rm /mnt/* -r sudo rm /mnt/* -r
@ -11,6 +15,8 @@ sudo qemu-nbd -c dev/nbd0 -f raw ./ZealOS.raw
sudo partprobe /dev/nbd0 sudo partprobe /dev/nbd0
echo "Merging with src/" echo "Merging with src/"
sudo mount /dev/nbd0p1 /mnt sudo mount /dev/nbd0p1 /mnt
rm ../src/Home/Registry.CC # we use Registry for auto-iso process, don't want to overwrite
rm ../src/Home/MakeHome.CC # unneeded file
sudo cp -r ../src/* /mnt/ sudo cp -r ../src/* /mnt/
sudo sync sudo sync
echo "Files copied, unmounting" echo "Files copied, unmounting"
@ -27,6 +33,7 @@ sudo qemu-nbd -c dev/nbd0 -f raw ./ZealOS.raw
sudo partprobe /dev/nbd0 sudo partprobe /dev/nbd0
sudo mount /dev/nbd0p1 /mnt sudo mount /dev/nbd0p1 /mnt
echo "Extracting Distro ISO" echo "Extracting Distro ISO"
sudo rm ./ZealOS-*.iso # comment this line if you want lingering old ISOs
sudo cp /mnt/Tmp/MyDistro.ISO.C ./ZealOS-$(date +%Y-%m-%d-%H_%M_%S).iso sudo cp /mnt/Tmp/MyDistro.ISO.C ./ZealOS-$(date +%Y-%m-%d-%H_%M_%S).iso
sudo chown -R $USER:$USER ./ZealOS-*.iso sudo chown -R $USER:$USER ./ZealOS-*.iso
echo "Files copied, unmounting" echo "Files copied, unmounting"
@ -36,4 +43,5 @@ sudo rm /mnt/* -r
sudo sync sudo sync
echo "Deleting temp HDD" echo "Deleting temp HDD"
rm ./ZealOS.raw rm ./ZealOS.raw
echo "Done" echo "Done, build/ contents:"
ls

View file

@ -1,35 +0,0 @@
Auto-ISO Host QEMU Build Distro ISO for VM Install:
Process:
- make new HDD for a quick install
- boot AUTO.ISO with hdd
- do mini-install and then reboot w/ mount hdd then copy src/-->hdd
- reboot, recompile kernel, reboot, run K.CC with DoDistro
(- copy hdd-->src maybe? not "needed" to just make the Distro ISO)
- export Distro.ISO to Host
- delete temp HDD, finish
Auto-ISO:
Required Stages/Steps:
- automatically installs to first identified hard disk.
- this could maybe just mimic how current VM install works,
just don't bother asking any questions for user input.
- copy src over hdd
- reboot (TO HDD), recompile Kernel, reboot, run K.CC-->DoDistro
- export Distro.ISO to src/
- poweroff, done.
Thoughts:
- implement a "GOOD" file somewhere that is made at the end,
check for this after running the auto ISO and bail if not found?
Notes:
- the Auto HDD bootloader will need to change.
it has to auto-boot into the C Drive to do this process...
so removing&skipping the prompt will be required

View file

@ -1,12 +1,15 @@
#!/bin/bash #!/bin/bash
# Sync VM --> repo # Sync VM --> repo
# (wipe src/, copy VM to src/. To copy over src/ in-place, comment out the `rm -rf ../src/*` line.)
sudo modprobe nbd sudo modprobe nbd
echo "Edit this script first to pick your VM path & file!" echo "Edit this script first to pick your VM path & file!"
exit # Comment this line out exit # Comment this line out
# Uncomment ONE of the next lines and edit it to point to your VM HDD # Uncomment ONE of the next lines and edit it to point to your VM HDD
sudo qemu-nbd -c dev/nbd0 ~/VirtualBox\ VMs/ZealOS/ZealOS.vdi # sudo qemu-nbd -c dev/nbd0 ~/VirtualBox\ VMs/ZealOS/ZealOS.vdi
# sudo qemu-nbd -c dev/nbd0 ~/vmware/ZealOS/ZealOS.vmdk # sudo qemu-nbd -c dev/nbd0 ~/vmware/ZealOS/ZealOS.vmdk
# sudo qemu-nbd -c dev/nbd0 ZealOS.qcow2 # sudo qemu-nbd -c dev/nbd0 ZealOS.qcow2
@ -16,6 +19,7 @@ echo "removing src/ files"
rm -rf ../src/* rm -rf ../src/*
echo "copying src/ files from root of mounted hdd" echo "copying src/ files from root of mounted hdd"
sudo cp -r /mnt/* ../src/ sudo cp -r /mnt/* ../src/
sudo rm ../src/Boot/BootMHD2.BIN.C
echo "src/ files copied" echo "src/ files copied"
echo "unmounting..." echo "unmounting..."
sudo umount /mnt sudo umount /mnt
@ -23,5 +27,6 @@ sudo qemu-nbd -d /dev/nbd0
echo "unmounted hdd" echo "unmounted hdd"
echo "set perms" echo "set perms"
sudo chown -R $USER:$USER ../src/* sudo chown -R $USER:$USER ../src/*
mv ../src/Tmp/AUTO.ISO.C ./AUTO.ISO
echo "finished." echo "finished."
git status git status

View file

@ -1,12 +1,17 @@
#!/bin/bash #!/bin/bash
# Sync repo --> VM # Sync repo --> VM
# (copy src/ to VM. Kernel code changes won't be reflected in VM until running BootHDIns; to recompile kernel.)
# Run this script inside build/ directory
sudo modprobe nbd sudo modprobe nbd
echo "Edit this script first to pick your VM path & file!" echo "Edit this script first to pick your VM path & file!"
exit # Comment this line out exit # Comment this line out
# Uncomment ONE of the next lines and edit it to point to your VM HDD # Uncomment ONE of the next lines and edit it to point to your VM HDD
sudo qemu-nbd -c dev/nbd0 ~/VirtualBox\ VMs/ZealOS/ZealOS.vdi # sudo qemu-nbd -c dev/nbd0 ~/VirtualBox\ VMs/ZealOS/ZealOS.vdi
# sudo qemu-nbd -c dev/nbd0 ~/vmware/ZealOS/ZealOS.vmdk # sudo qemu-nbd -c dev/nbd0 ~/vmware/ZealOS/ZealOS.vmdk
# sudo qemu-nbd -c dev/nbd0 ZealOS.qcow2 # sudo qemu-nbd -c dev/nbd0 ZealOS.qcow2

37
mnt.sh
View file

@ -1,37 +0,0 @@
#!/bin/bash
echo "mounting..."
sudo modprobe nbd
sudo qemu-nbd -c dev/nbd0 ~/VirtualBox\ VMs/ZealOS/ZealOS.vdi #Replace with path to disk
#sudo qemu-nbd -c dev/nbd0 ~/vmware/ZealOS/ZealOS.vmdk #Replace with path to disk
sudo partprobe /dev/nbd0
sudo mount /dev/nbd0p1 /mnt
echo "mounted .vdi"
echo "removing src/ files"
rm -rf src/*
echo "copying src/ files from root of mounted .vdi"
sudo cp -r /mnt/* src/
echo "src/ files copied"
echo "removing doc/ files"
rm -rf docs/*
echo "copying docs/ files from HTML/ folder of mounted .vdi"
sudo cp -r /mnt/HTML/* docs/
echo "docs/ files copied"
echo "unmounting..."
sudo umount /mnt
sudo qemu-nbd -d /dev/nbd0
echo "unmounted .vdi"
echo "set perms, update ISO."
sudo chown -R $USER:$USER src/*
sudo chown -R $USER:$USER docs/*
rm ZealOS-*
mv src/Tmp/MyDistro.ISO.C ./ZealOS-$(date +%Y-%m-%d-%H_%M_%S).iso
mv src/Tmp/AUTO.ISO.C ./build/AUTO.ISO
echo "removing duplicates"
rm -rf ./src/HTML/*
echo "finished."
git status

View file

@ -3,10 +3,9 @@
// Used by host OS to create a full Distro ISO synced with GitHub repo. // Used by host OS to create a full Distro ISO synced with GitHub repo.
#define STD_DISTRO_DVD_CONFIG "TB\nScale2Mem(2048,0x40000)\nT\n\n1024\n768\n\n\n" #define STD_DISTRO_DVD_CONFIG "TB\nScale2Mem(2048,0x40000)\nT\n\n1024\n768\n\n\n"

U0 MakeMyISO(U8 *_out_iso_filename) U0 MakeMyISO(U8 *_out_iso_filename)
{//Does everything with current drive. {//Does everything with current drive.
//If you have not recompiled $FG,2$Kernel$FG$ and defined your CD/DVD drive, use $LK,"Mount",A="MN:Mount"$.
U8 *out_iso_filename = FileNameAbs(_out_iso_filename); U8 *out_iso_filename = FileNameAbs(_out_iso_filename);
if (!DriveIsWritable) if (!DriveIsWritable)
{ {
@ -45,7 +44,4 @@ U0 MakeMyISO(U8 *_out_iso_filename)
DelTree("/Distro"); DelTree("/Distro");
Free(out_iso_filename); Free(out_iso_filename);
} }
MakeMyISO("/Tmp/AUTO.ISO.C"); MakeMyISO("/Tmp/AUTO.ISO.C");
// Study the account examples $LK,"Config Strs",A="FL:::/Demo/AcctExample/TOS/TOSConfig.CC,1"$, $LK,"Update Funs",A="FL:::/Demo/AcctExample/TOS/TOSDistro.CC,1"$.

View file

@ -0,0 +1,29 @@
U0 Auto()
{
I64 i, ata_port = -1;
CAHCIPort *port;
U8 *in_str;
for (i = 0; i < AHCI_MAX_PORTS; i++)
{
if (Bt(&blkdev.ahci_hba->ports_implemented, i))
{
port = &blkdev.ahci_hba->ports[i];
if (port->signature == AHCI_PxSIG_ATA)
{
ata_port = i;
break;
}
}
}
BootMHDIns('C');
in_str = MStrPrint("Sleep(700);In(\"CC\\n%d\\n\\n1024\\n768\\n\\n\\n\");", ata_port);
OnceDrive('C', in_str);
Free(in_str);
in_str = MStrPrint("BootHDIns;OnceFlush;Once(\"#include \\\"/Misc/Auto/AutoFullDistro1\\\";;Auto;\");Reboot;");
OnceDrive('C', in_str);
OutU8(0x501,0x31);
}
Auto;

View file

@ -96,12 +96,7 @@ U0 VMInstallWiz()
BootMHDIns('C'); BootMHDIns('C');
} }
in_str = MStrPrint("Sleep(300);In(\"CC\\n%d\\n\\n1024\\n768\\n\\n\\n\");", ata_port); Copy("::/Misc/Auto/BootMHD2.CC", "C:/System/Boot/BootMHD2.CC");
OnceDrive('C', in_str);
Free(in_str);
in_str = MStrPrint("BootHDIns;BootMHDIns('c');OnceFlush;"
"Once(\"#include \\\"/Misc/Auto/AutoFullDistro1\\\";;Auto;\");Reboot;");
OnceDrive('C', in_str);
//////////////////////////////////// ////////////////////////////////////
@ -117,8 +112,9 @@ Bool DoInstall(Bool prompt_reboot)
DocBottom; DocBottom;
VMInstallWiz(); VMInstallWiz();
res = TRUE; res = TRUE;
OutU8(0x501,0x31); OnceDrive('C', "PopUp(\"#include \\\"/Misc/Auto/AutoFullDistro0\\\";\");");
return res; BootRAM("C:" BOOT_DIR_KERNEL_BIN_C);
 return res;
} }
Bool OSInstall(Bool prompt_reboot=TRUE) Bool OSInstall(Bool prompt_reboot=TRUE)

122
src/Misc/Auto/BootMHD2.CC Executable file
View file

@ -0,0 +1,122 @@
#define MODULE_SIZE 2 * BLK_SIZE
#define BOOT_HIGH_LOC_MHD2 ((BOOT_RAM_LIMIT - (BOOT_STACK_SIZE + MODULE_SIZE)) >> 4)
DefinePrint("DD_BOOT_HIGH_LOC_MHD2", "%08X", BOOT_HIGH_LOC_MHD2 << 4);
asm {
USE16
BMHD2_START::
MOV U32 FS:[0], 'B' + 0x2000 + ('2' + 0x2000) << 16
MOV AX, BOOT_HIGH_LOC_MHD2
MOV ES, AX
//This copies this bootloader's code to 0x$TX,"00096A00",D="DD_BOOT_HIGH_LOC_MHD2"$
MOV AX, CS
MOV DS, AX
MOV U32 [BMHD2_OLD_CS_RIP - BMHD2_START], EBX
MOV U8 [BMHD2_BIOS_DRIVE_NUM - BMHD2_START], DL
MOV CX, MODULE_SIZE
XOR SI, SI
XOR DI, DI
REP_MOVSB
MOV AX, BOOT_HIGH_LOC_MHD2
MOV DS, AX
//The assembler doesn't support 16-bit very well.
DU8 0xEA; //JMP BOOT_HIGH_LOC_MHD2:BMHD2_HISTART
DU16 BMHD2_HISTART - BMHD2_START, BOOT_HIGH_LOC_MHD2;
BMHD2_BOOT_MESSAGE::
DU8 256 DUP(0);
BMHD2_BIOS_DRIVE_NUM: DU8 0;
BMHD2_PAGE: DU8 0;
BMHD2_BLK_ARRAY:: DU64 8 DUP(0);
BMHD2_DAP: DU8 16, 0, 1, 0; //One block at a time
BMHD2_DAP_BUF: DU16 0, 0;
BMHD2_DAP_BLK:: //64-bit
BMHD2_DAP_BLK_LO: DU32 0;
BMHD2_DAP_BLK_HI: DU32 0;
BMHD2_PUT_CHAR::
MOV AH, 0xE
MOV BL, 7 //Might be foreground color on some BIOS's
MOV BH, U8 [BMHD2_PAGE - BMHD2_START]
INT 0x10
BMHD2_RET::
RET
BMHD2_PUTS::
@@1: LODSB
TEST AL, AL
JZ BMHD2_RET
CALL BMHD2_PUT_CHAR
JMP @@1
BMHD2_GETCHAR:
XOR AH, AH
INT 0x16
PUSH AX
MOV AH, 0x0E
MOV BX, 0x07
INT 0x10
POP AX
RET
BMHD2_HISTART:
MOV AH, 0xF
INT 0x10
MOV U8 [BMHD2_PAGE - BMHD2_START], BH //Video page
MOV U32 FS:[0], 0
@@5: MOV SI, BMHD2_BOOT_MESSAGE - BMHD2_START
CALL BMHD2_PUTS
// CALL BMHD2_GETCHAR
MOV AL, '1' // go directly to C:/
CMP AL, '0'
JB @@5
CMP AL, '8'
JAE @@5
AND EAX, 7
MOV EBX, U32 BMHD2_BLK_ARRAY - BMHD2_START[EAX * 8]
MOV EAX, U32 BMHD2_BLK_ARRAY + 4 - BMHD2_START[EAX * 8]
TEST EBX, EBX
JNZ @@10
TEST EAX, EAX
JZ @@5
@@10: MOV U32 [BMHD2_DAP_BLK_LO - BMHD2_START], EBX
MOV U32 [BMHD2_DAP_BLK_HI - BMHD2_START], EAX
MOV AX, U16 [BMHD2_OLD_CS_RIP - BMHD2_START]
SHR AX, 4
ADD AX, U16 [BMHD2_OLD_CS_RIP + 2 - BMHD2_START]
MOV U16 [BMHD2_DAP_BUF + 2 - BMHD2_START], AX //ES:0000
MOV SI, BMHD2_DAP - BMHD2_START //DS:SI=DAP
MOV DL, U8 [BMHD2_BIOS_DRIVE_NUM - BMHD2_START]
MOV AH, 0x42
INT 0x13
POP EBP
POP EDX
POP EBX
POP ECX
XOR EAX, EAX
POP GS
POP FS
POP ES
POP DS
POPF
//The assembler doesn't support 16-bit very well.
DU8 0xEA; //JMP xxxx:yyyy
BMHD2_OLD_CS_RIP:
DU16 0, 0;
BMHD2_END::
//Continues here $LK,"::/System/Boot/BootHD.CC",A="FF:::/System/Boot/BootHD.CC,START"$
#assert BMHD2_END - BMHD2_START < MODULE_SIZE
}

View file

@ -1,8 +1,5 @@
//Place this file in /Home and change
//anything you want.
U0 UserStartUp() U0 UserStartUp()
{//Run each time a user a spawned {
DocTermNew; DocTermNew;
Type("::/Doc/Start.DD"); Type("::/Doc/Start.DD");
LBts(&Fs->display_flags, DISPLAYf_SHOW); LBts(&Fs->display_flags, DISPLAYf_SHOW);
@ -12,7 +9,7 @@ U0 UserStartUp()
} }
U0 ServerStartUp() U0 ServerStartUp()
{//Run each time a server task is spawned. {
DocTermNew; DocTermNew;
LBts(&Fs->display_flags, DISPLAYf_SHOW); LBts(&Fs->display_flags, DISPLAYf_SHOW);
WinToTop; WinToTop;
@ -30,9 +27,9 @@ U0 StartUpTasks()
WinTileVert; WinTileVert;
"Boot Time:%7.3fs\n", tS; "Boot Time:%7.3fs\n", tS;
XTalk(user, "Cd; #include \"Once\";\n"); XTalk(user, "Cd; #include \"Once\";\n");
Silent; //no output to screen Silent;
Silent(OFF); //no output to screen Silent(OFF);
} }
StartUpTasks; StartUpTasks;

View file

@ -5,9 +5,7 @@
//first terminal window upon start-up. //first terminal window upon start-up.
//See $LK,"Once",A="FF:~/HomeSys.CC,Once"$ and $LK,"Home Files",A="FF:::/Doc/GuideLines.DD,/Home Files"$. //See $LK,"Once",A="FF:~/HomeSys.CC,Once"$ and $LK,"Home Files",A="FF:::/Doc/GuideLines.DD,/Home Files"$.
//Delete the rest from this file. U0 Tmp()
U0 Tmp()
{ {
OnceExe; OnceExe;
switch (sys_boot_src.u16[0]) switch (sys_boot_src.u16[0])