@@ -74,7 +74,7 @@ build: prepare_dirs fonts ./bin/boot_with_size.bin ./bin/kernel.bin user_program
7474 @echo " To install user programs to disk image, run: make install"
7575
7676fonts :
77- ./generateFonts.sh
77+ ./utilities/ generateFonts.sh
7878
7979install : ./bin/os.bin
8080ifeq ($(UNAME_S ) ,Linux)
@@ -87,66 +87,51 @@ ifeq ($(UNAME_S),Linux)
8787 @sudo umount /mnt/d
8888 @echo "User programs and assets installed to disk image!"
8989else ifeq ($(UNAME_S),Darwin)
90- @echo "Preparing disk image for macOS..."
91- @bash -c "\
92- set -e; \
93- echo 'Attaching disk image...'; \
94- ATTACH_OUTPUT=\$$(hdiutil attach -imagekey diskimage-class=CRawDiskImage -nomount ./bin/os.bin 2>/dev/null); \
95- DISK_ID=\$$(echo \"\$$ATTACH_OUTPUT\" | grep -o '/dev/disk[0-9]*' | head -1); \
96- PARTITION_ID=\"\$${DISK_ID}s1\"; \
97- if [ -z \"\$$DISK_ID\" ]; then echo 'Failed to attach disk image'; exit 1; fi; \
98- echo \"Attached as \$$DISK_ID, partition \$$PARTITION_ID\"; \
99- echo 'Formatting partition as FAT32...'; \
100- diskutil eraseVolume MS-DOS VIOSFAT32 \"\$$PARTITION_ID\" >/dev/null 2>&1 || { echo 'Failed to format partition'; hdiutil detach \"\$$DISK_ID\" 2>/dev/null; exit 1; }; \
101- echo 'Copying files...'; \
102- if [ -d './assets' ]; then \
103- echo 'Copying assets...'; \
104- cp -r ./assets/* /Volumes/VIOSFAT32/ || { echo 'Failed to copy assets'; diskutil unmount \"\$$PARTITION_ID\"; hdiutil detach \"\$$DISK_ID\" 2>/dev/null; exit 1; }; \
105- else \
106- echo 'No assets directory found, skipping...'; \
107- fi; \
108- if [ -d './assets/etc/default/user/programs' ]; then \
109- echo 'Copying .elf files...'; \
110- find ./assets/etc/default/user/programs -name '*.elf' -exec cp {} /Volumes/VIOSFAT32/ \; || { echo 'Failed to copy .elf files'; diskutil unmount \"\$$PARTITION_ID\"; hdiutil detach \"\$$DISK_ID\" 2>/dev/null; exit 1; }; \
111- else \
112- echo 'No programs directory found, skipping...'; \
113- fi; \
90+ @echo "Attaching disk image (macOS)..."
91+ @bash -c '\
92+ DISK_ID=$$(hdiutil attach -imagekey diskimage-class=CRawDiskImage -nomount ./bin/os.bin | awk "/\/dev\// {print \$$1}"); \
93+ echo "Attached as $$DISK_ID"; \
94+ sudo mkdir -p /Volumes/viosmnt; \
95+ sudo mount -t msdos $$DISK_ID /Volumes/viosmnt || { echo "Failed to mount $$DISK_ID"; exit 1; }; \
96+ echo "Copying files..."; \
97+ sudo cp -r ./assets/* /Volumes/viosmnt/ 2>/dev/null || true; \
11498 sync; \
115- echo 'Unmounting for boot sector update...'; \
116- diskutil unmount \"\$$PARTITION_ID\" >/dev/null 2>&1 || echo 'Unmount failed, continuing...'; \
117- echo 'Installing custom boot sector...'; \
118- dd if=./bin/vbr.bin of=\"\$$PARTITION_ID\" bs=512 count=1 conv=notrunc 2>/dev/null || echo 'Warning: Failed to install custom boot sector'; \
119- hdiutil detach \"\$$DISK_ID\" >/dev/null 2>&1 || echo 'Detach failed, continuing...'; \
120- echo 'User programs and assets installed to disk image!'; \
121- "
99+ echo "Unmounting..."; \
100+ sudo umount /Volumes/viosmnt; \
101+ hdiutil detach $$DISK_ID; \
102+ echo "User programs and assets installed to disk image!" \
103+ '
122104endif
123105
124106
125107./bin/kernel.bin : prepare_dirs $(FILES )
126108 i686-elf-gcc $(FLAGS ) -T ./src/linker.ld -o ./bin/kernel.bin -ffreestanding -O0 -nostdlib $(FILES )
127109
128- ./bin/boot.bin : prepare_dirs ./src/boot/mbr.asm ./src/boot/vbrEntry.asm ./src/boot/vbrMain.asm ./src/boot/fsinfo.asm
129- nasm -f bin ./src/boot/mbr.asm -o ./bin/mbr.bin
130- nasm -f bin ./src/boot/vbrEntry.asm -o ./bin/vbrEntry.bin
131- nasm -f bin ./src/boot/vbrMain.asm -o ./bin/vbrMain.bin
132- nasm -f bin ./src/boot/fsinfo.asm -o ./bin/fsinfo.bin
133- dd if=./bin/vbrEntry.bin of=./bin/vbr.bin bs=512 count=1 conv=notrunc status=none
134- dd if=./bin/vbrMain.bin of=./bin/vbr.bin bs=512 seek=1 count=2 conv=notrunc status=none
135- dd if=./bin/mbr.bin of=$@ bs=512 count=1 conv=notrunc status=none
136- dd if=./bin/vbr.bin of=$@ bs=512 seek=2050 count=3 conv=notrunc status=none
137- dd if=./bin/fsinfo.bin of=$@ bs=512 seek=2060 count=1 conv=notrunc status=none
110+ ./bin/boot.bin : prepare_dirs ./src/boot/boot.asm
111+ nasm -f bin ./src/boot/boot.asm -o ./bin/boot.bin
138112
139113# Calculate kernel size and update boot sector
140114./bin/boot_with_size.bin : ./bin/boot.bin ./bin/kernel.bin
141115 @echo " Calculating kernel size and updating boot sector..."
142- cp ./bin/boot.bin ./bin/boot_with_size.bin
116+ ./utilities/updateBoot.sh
143117
118+ # ./bin/boot.bin: prepare_dirs ./src/boot/mbr.asm ./src/boot/vbrEntry.asm ./src/boot/vbrMain.asm ./src/boot/fsinfo.asm
119+ # # nasm -f bin ./src/boot/mbr.asm -o ./bin/mbr.bin
120+ # # nasm -f bin ./src/boot/vbrEntry.asm -o ./bin/vbrEntry.bin
121+ # # nasm -f bin ./src/boot/vbrMain.asm -o ./bin/vbrMain.bin
122+ # # nasm -f bin ./src/boot/fsinfo.asm -o ./bin/fsinfo.bin
123+ # # dd if=./bin/vbrEntry.bin of=./bin/vbr.bin bs=512 count=1 conv=notrunc status=none
124+ # # dd if=./bin/vbrMain.bin of=./bin/vbr.bin bs=512 seek=1 count=2 conv=notrunc status=none
125+ # # dd if=./bin/mbr.bin of=$@ bs=512 count=1 conv=notrunc status=none
126+ # # dd if=./bin/vbr.bin of=$@ bs=512 seek=2050 count=3 conv=notrunc status=none
127+ # # dd if=./bin/fsinfo.bin of=$@ bs=512 seek=2060 count=1 conv=notrunc status=nonez
144128
145- ./bin/os.bin : ./bin/boot_with_size.bin
129+
130+ ./bin/os.bin : ./bin/boot_with_size.bin ./bin/kernel.bin
146131 rm -rf ./bin/os.bin
147132 dd if=./bin/boot_with_size.bin of=./bin/os.bin bs=512 conv=notrunc
148- dd if=./bin/kernel.bin of= ./bin/os.bin bs=512 seek=2070 conv=notrunc
149- dd if=/dev/zero bs=1048576 count=128 >> ./bin/os.bin
133+ dd if=./bin/kernel.bin >> ./bin/os.bin
134+ dd if=/dev/zero bs=1048576 count=1500 >> ./bin/os.bin
150135
151136# Generic C and ASM file rules
152137./build/% .o : ./src/% .c
0 commit comments