Skip to content

Commit cb63dde

Browse files
Update the tools and make them buildable (#7)
Update the tools for building, running and debugging ChaOS. Provide source code and build instructions for these tools. This way the codebase no longer depends on pre-built binaries.
1 parent 68236be commit cb63dde

File tree

130 files changed

+66559
-176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+66559
-176
lines changed

.github/workflows/main.yml

Lines changed: 134 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,157 @@ name: CI
33
on: [push, pull_request]
44

55
jobs:
6-
download_tools:
7-
name: Download tools
8-
strategy:
9-
matrix:
10-
os: ["ubuntu-latest", "windows-latest"]
11-
runs-on: ${{ matrix.os }}
6+
build_tools_linux:
7+
name: Build tools for Linux
8+
runs-on: "ubuntu-latest"
129
steps:
13-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v3
1411
- name: Cache tools
1512
id: cache
16-
uses: actions/cache@v2
13+
uses: actions/cache@v3
1714
env:
1815
cache-name: cache-tools
1916
with:
2017
path: tools
21-
key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('download_tools.sh', 'DOWNLOAD_TOOLS.BAT') }}
22-
- name: Download tools (Linux)
23-
if: runner.os == 'Linux' && steps.cache.outputs.cache-hit != 'true'
24-
run: ./download_tools.sh
18+
key: linux-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('tools/src') }}
19+
- name: Install build requirements
20+
if: steps.cache.outputs.cache-hit != 'true'
21+
run: sudo apt install wget build-essential file
22+
- name: Build i686-elf-tools
23+
if: steps.cache.outputs.cache-hit != 'true'
24+
run: tools/src/build-i686-elf-tools.sh
2525
shell: sh
26-
- name: Download tools (Windows)
27-
if: runner.os == 'Windows' && steps.cache.outputs.cache-hit != 'true'
28-
run: DOWNLOAD_TOOLS.BAT
29-
shell: cmd
30-
build:
31-
name: Build
32-
needs: [download_tools]
33-
strategy:
34-
matrix:
35-
os: ["ubuntu-latest", "windows-latest"]
36-
type: ["floppy", "hd", "hd --mbr"]
37-
debug: ["", "--debug"]
38-
test: ["", "--test"]
39-
efi: ["", "--efi"]
40-
runs-on: ${{ matrix.os }}
26+
- name: Cleanup after i686-elf-tools build
27+
if: steps.cache.outputs.cache-hit != 'true'
28+
run: rm -rf tools/src/binutils-* tools/src/gcc-*
29+
- name: Build GenFw
30+
if: steps.cache.outputs.cache-hit != 'true'
31+
run: tools/src/GenFw/build.sh
32+
shell: sh
33+
- name: Build imgtools
34+
if: steps.cache.outputs.cache-hit != 'true'
35+
run: tools/src/imgtools/build.sh
36+
shell: sh
37+
- name: Build mkdosfs
38+
if: steps.cache.outputs.cache-hit != 'true'
39+
run: tools/src/mkdosfs/build.sh
40+
shell: sh
41+
- name: Tar tools
42+
run: tar -cf chaostools-linux.tar --exclude='src' -C tools .
43+
- name: Archive artifacts
44+
uses: actions/upload-artifact@v3
45+
with:
46+
name: chaostools-linux.tar
47+
path: chaostools-linux.tar
48+
build_tools_windows:
49+
name: Build tools for Windows
50+
needs: [build_tools_linux]
51+
runs-on: ubuntu-latest
4152
steps:
42-
- uses: actions/checkout@v2
53+
- uses: actions/checkout@v3
4354
- name: Cache tools
4455
id: cache
45-
uses: actions/cache@v2
56+
uses: actions/cache@v3
4657
env:
4758
cache-name: cache-tools
4859
with:
4960
path: tools
50-
key: ${{ runner.os }}-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('download_tools.sh', 'DOWNLOAD_TOOLS.BAT') }}
51-
- name: Download tools (Linux)
52-
if: runner.os == 'Linux' && steps.cache.outputs.cache-hit != 'true'
53-
run: ./download_tools.sh
61+
key: windows-${{ env.cache-name }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('tools/src') }}
62+
- name: Install build requirements
63+
if: steps.cache.outputs.cache-hit != 'true'
64+
run: sudo apt install wget build-essential file git automake autopoint bison flex libgdk-pixbuf2.0-dev gperf intltool libtool libltdl-dev python3-mako ruby unzip p7zip-full lzip libtool-bin python-is-python3 gcc-mingw-w64-x86-64
65+
- name: Download linux tools artifact
66+
if: steps.cache.outputs.cache-hit != 'true'
67+
uses: actions/download-artifact@v3
68+
with:
69+
name: chaostools-linux.tar
70+
- name: Untar tools
71+
if: steps.cache.outputs.cache-hit != 'true'
72+
run: tar -xvf chaostools-linux.tar -C tools
73+
- name: Build i686-elf-tools
74+
if: steps.cache.outputs.cache-hit != 'true'
75+
run: tools/src/build-i686-elf-tools-win.sh
5476
shell: sh
55-
- name: Download tools (Windows)
56-
if: runner.os == 'Windows' && steps.cache.outputs.cache-hit != 'true'
57-
run: DOWNLOAD_TOOLS.BAT
58-
shell: cmd
59-
- name: Run the build script (Linux)
60-
if: runner.os == 'Linux'
77+
- name: Cleanup after i686-elf-tools build
78+
if: steps.cache.outputs.cache-hit != 'true'
79+
run: rm -rf tools/src/mxe tools/src/binutils-* tools/src/gcc-*
80+
- name: Build GenFw
81+
if: steps.cache.outputs.cache-hit != 'true'
82+
run: tools/src/GenFw/build-win.sh
83+
shell: sh
84+
- name: Build imgtools
85+
if: steps.cache.outputs.cache-hit != 'true'
86+
run: tools/src/imgtools/build-win.sh
87+
shell: sh
88+
- name: Build mkdosfs
89+
if: steps.cache.outputs.cache-hit != 'true'
90+
run: tools/src/mkdosfs/build-win.sh
91+
shell: sh
92+
- name: Remove linux tools
93+
if: steps.cache.outputs.cache-hit != 'true'
94+
run: tar -tf chaostools-linux.tar | tail -n +2 | sed -e 's!^!tools/!' | xargs rm -rf
95+
- name: Archive artifacts
96+
uses: actions/upload-artifact@v3
97+
with:
98+
name: chaostools-windows
99+
path: |
100+
tools
101+
!tools/src
102+
build_linux:
103+
name: Build on Linux
104+
needs: [build_tools_linux]
105+
strategy:
106+
matrix:
107+
type: ["floppy", "hd", "hd --mbr"]
108+
debug: ["", "--debug"]
109+
test: ["", "--test"]
110+
efi: ["", "--efi"]
111+
runs-on: ubuntu-latest
112+
steps:
113+
- uses: actions/checkout@v3
114+
- name: Install tools
115+
run: sudo apt install nasm make qemu-utils python3
116+
- name: Download additional tools artifact
117+
uses: actions/download-artifact@v3
118+
with:
119+
name: chaostools-linux.tar
120+
- name: Untar tools
121+
if: steps.cache.outputs.cache-hit != 'true'
122+
run: tar -xvf chaostools-linux.tar -C tools
123+
- name: Run the build script
61124
run: ./build_image.sh ${{ matrix.type }} ${{ matrix.debug }} ${{ matrix.test }} ${{ matrix.efi }} --user-programs-all
62125
shell: sh
63-
- name: Run the build script (Windows)
64-
if: runner.os == 'Windows'
126+
build_windows:
127+
name: Build on Windows
128+
needs: [build_tools_windows]
129+
strategy:
130+
matrix:
131+
type: ["floppy", "hd", "hd --mbr"]
132+
debug: ["", "--debug"]
133+
test: ["", "--test"]
134+
efi: ["", "--efi"]
135+
runs-on: windows-latest
136+
steps:
137+
- uses: actions/checkout@v3
138+
- name: Install nasm
139+
uses: ilammy/setup-nasm@v1
140+
- name: Install Python3
141+
uses: actions/setup-python@v4
142+
with:
143+
python-version: '3.11'
144+
- name: Install winget
145+
uses: Cyberboss/install-winget@v1
146+
- name: Install QEMU
147+
run: winget install --accept-source-agreements --accept-package-agreements --id=SoftwareFreedomConservancy.QEMU -e
148+
- name: Add QEMU to the PATH
149+
shell: pwsh
150+
run: |
151+
"C:\Program Files\qemu" >> $env:GITHUB_PATH
152+
- name: Download tools artifact
153+
uses: actions/download-artifact@v3
154+
with:
155+
name: chaostools-windows
156+
path: tools
157+
- name: Run the build script
65158
run: BUILD_IMAGE.BAT ${{ matrix.type }} ${{ matrix.debug }} ${{ matrix.test }} ${{ matrix.efi }} --user-programs-all
66159
shell: cmd

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/tools
21
*.o
32
*.map
43
*.elf
@@ -20,3 +19,12 @@
2019
*.i
2120
*.iii
2221
*.lst
22+
*.pyc
23+
/tools
24+
!/tools
25+
/tools/*
26+
!/tools/src
27+
!/tools/python
28+
!/tools/Trim
29+
!/tools/Trim.bat
30+
!/tools/bios32.bin

.vscode/launch.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
"launchCompleteCommand": "exec-run",
1616
"windows": {
1717
"MIMode": "gdb",
18-
"miDebuggerPath": "${workspaceRoot}/tools/gdb-multiarch.bat"
18+
"miDebuggerPath": "gdb"
1919
},
2020
"linux": {
2121
"MIMode": "gdb",
22-
"miDebuggerPath": "${workspaceRoot}/tools/gdb-multiarch.sh"
22+
"miDebuggerPath": "gdb"
2323
},
2424
"preLaunchTask": "QEMU Boot Floppy & Run GDB Server",
2525
"internalConsoleOptions": "openOnSessionStart"
@@ -38,11 +38,11 @@
3838
"launchCompleteCommand": "exec-run",
3939
"windows": {
4040
"MIMode": "gdb",
41-
"miDebuggerPath": "${workspaceRoot}/tools/gdb-multiarch.bat"
41+
"miDebuggerPath": "gdb"
4242
},
4343
"linux": {
4444
"MIMode": "gdb",
45-
"miDebuggerPath": "${workspaceRoot}/tools/gdb-multiarch.sh"
45+
"miDebuggerPath": "gdb"
4646
},
4747
"preLaunchTask": "QEMU Boot Floppy EFI & Run GDB Server",
4848
"internalConsoleOptions": "openOnSessionStart"
@@ -61,11 +61,11 @@
6161
"launchCompleteCommand": "exec-run",
6262
"windows": {
6363
"MIMode": "gdb",
64-
"miDebuggerPath": "${workspaceRoot}/tools/gdb-multiarch.bat"
64+
"miDebuggerPath": "gdb"
6565
},
6666
"linux": {
6767
"MIMode": "gdb",
68-
"miDebuggerPath": "${workspaceRoot}/tools/gdb-multiarch.sh"
68+
"miDebuggerPath": "gdb"
6969
},
7070
"preLaunchTask": "QEMU Boot HD & Run GDB Server",
7171
"internalConsoleOptions": "openOnSessionStart"
@@ -84,11 +84,11 @@
8484
"launchCompleteCommand": "exec-run",
8585
"windows": {
8686
"MIMode": "gdb",
87-
"miDebuggerPath": "${workspaceRoot}/tools/gdb-multiarch.bat"
87+
"miDebuggerPath": "gdb"
8888
},
8989
"linux": {
9090
"MIMode": "gdb",
91-
"miDebuggerPath": "${workspaceRoot}/tools/gdb-multiarch.sh"
91+
"miDebuggerPath": "gdb"
9292
},
9393
"preLaunchTask": "QEMU Boot HD EFI & Run GDB Server",
9494
"internalConsoleOptions": "openOnSessionStart"

.vscode/tasks.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
"label": "QEMU Boot Floppy & Run GDB Server",
2828
"type": "shell",
2929
"windows": {
30-
"command": "echo a & \"${workspaceRoot}/tools/qemu-windows/qemu-system-i386\" -audiodev dsound,id=stdsound -machine pcspk-audiodev=stdsound -drive format=raw,file=FloppyImage.bin,index=0,if=floppy -boot a -S -s"
30+
"command": "echo a & call \"${workspaceRoot}/SET_ENV_VARS.BAT\" & qemu-system-i386 -audiodev dsound,id=stdsound -machine pcspk-audiodev=stdsound -drive format=raw,file=FloppyImage.bin,index=0,if=floppy -boot a -S -s"
3131
},
3232
"linux": {
33-
"command": "cd \"${workspaceRoot}/tools/qemu-linux\" && export LD_LIBRARY_PATH=\"${workspaceRoot}/tools/qemu-linux/lib\" && echo a && ${workspaceRoot}/tools/qemu-linux/qemu-system-i386 -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -drive format=raw,file=../../FloppyImage.bin,index=0,if=floppy -boot a -S -s || ${workspaceRoot}/tools/qemu-linux/qemu-system-i386 -curses -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -drive format=raw,file=../../FloppyImage.bin,index=0,if=floppy -boot a -S -s"
33+
"command": "echo a && qemu-system-i386 -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -drive format=raw,file=FloppyImage.bin,index=0,if=floppy -boot a -S -s || qemu-system-i386 -curses -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -drive format=raw,file=FloppyImage.bin,index=0,if=floppy -boot a -S -s"
3434
},
3535
"group": "none",
3636
"presentation": {
@@ -64,10 +64,10 @@
6464
"label": "QEMU Boot Floppy EFI & Run GDB Server",
6565
"type": "shell",
6666
"windows": {
67-
"command": "echo a & \"${workspaceRoot}/tools/qemu-windows/qemu-system-i386\" -audiodev dsound,id=stdsound -machine pcspk-audiodev=stdsound -bios tools/bios32.bin -drive format=raw,file=FloppyImage.bin,index=0,if=floppy -boot a -S -s"
67+
"command": "echo a & call \"${workspaceRoot}/SET_ENV_VARS.BAT\" & qemu-system-i386 -audiodev dsound,id=stdsound -machine pcspk-audiodev=stdsound -bios tools/bios32.bin -drive format=raw,file=FloppyImage.bin,index=0,if=floppy -boot a -S -s"
6868
},
6969
"linux": {
70-
"command": "cd \"${workspaceRoot}/tools/qemu-linux\" && export LD_LIBRARY_PATH=\"${workspaceRoot}/tools/qemu-linux/lib\" && echo a && ${workspaceRoot}/tools/qemu-linux/qemu-system-i386 -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -bios ../bios32.bin -drive format=raw,file=../../FloppyImage.bin,index=0,if=floppy -boot a -S -s || ${workspaceRoot}/tools/qemu-linux/qemu-system-i386 -curses -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -bios ../bios32.bin -drive format=raw,file=../../FloppyImage.bin,index=0,if=floppy -boot a -S -s"
70+
"command": "echo a && qemu-system-i386 -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -bios tools/bios32.bin -drive format=raw,file=FloppyImage.bin,index=0,if=floppy -boot a -S -s || qemu-system-i386 -curses -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -bios tools/bios32.bin -drive format=raw,file=FloppyImage.bin,index=0,if=floppy -boot a -S -s"
7171
},
7272
"group": "none",
7373
"presentation": {
@@ -101,10 +101,10 @@
101101
"label": "QEMU Boot HD & Run GDB Server",
102102
"type": "shell",
103103
"windows": {
104-
"command": "echo a & \"${workspaceRoot}/tools/qemu-windows/qemu-system-i386.exe\" -audiodev dsound,id=stdsound -machine pcspk-audiodev=stdsound -drive format=raw,file=HDImage.bin,index=0,if=ide -boot c -S -s"
104+
"command": "echo a & call \"${workspaceRoot}/SET_ENV_VARS.BAT\" & qemu-system-i386 -audiodev dsound,id=stdsound -machine pcspk-audiodev=stdsound -drive format=raw,file=HDImage.bin,index=0,if=ide -boot c -S -s"
105105
},
106106
"linux": {
107-
"command": "cd \"${workspaceRoot}/tools/qemu-linux\" && export LD_LIBRARY_PATH=\"${workspaceRoot}/tools/qemu-linux/lib\" && echo a && ${workspaceRoot}/tools/qemu-linux/qemu-system-i386 -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -drive format=raw,file=../../HDImage.bin,index=0,if=ide -boot c -S -s || ${workspaceRoot}/tools/qemu-linux/qemu-system-i386 -curses -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -drive format=raw,file=../../HDImage.bin,index=0,if=ide -boot c -S -s"
107+
"command": "echo a && qemu-system-i386 -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -drive format=raw,file=HDImage.bin,index=0,if=ide -boot c -S -s || qemu-system-i386 -curses -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -drive format=raw,file=HDImage.bin,index=0,if=ide -boot c -S -s"
108108
},
109109
"group": "none",
110110
"presentation": {
@@ -138,10 +138,10 @@
138138
"label": "QEMU Boot HD EFI & Run GDB Server",
139139
"type": "shell",
140140
"windows": {
141-
"command": "echo a & \"${workspaceRoot}/tools/qemu-windows/qemu-system-i386\" -audiodev dsound,id=stdsound -machine pcspk-audiodev=stdsound -bios tools/bios32.bin -drive format=raw,file=HDImage.bin,index=0,if=ide -boot c -S -s"
141+
"command": "echo a & call \"${workspaceRoot}/SET_ENV_VARS.BAT\" & qemu-system-i386 -audiodev dsound,id=stdsound -machine pcspk-audiodev=stdsound -bios tools/bios32.bin -drive format=raw,file=HDImage.bin,index=0,if=ide -boot c -S -s"
142142
},
143143
"linux": {
144-
"command": "cd \"${workspaceRoot}/tools/qemu-linux\" && export LD_LIBRARY_PATH=\"${workspaceRoot}/tools/qemu-linux/lib\" && echo a && ${workspaceRoot}/tools/qemu-linux/qemu-system-i386 -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -bios ../bios32.bin -drive format=raw,file=../../HDImage.bin,index=0,if=ide -boot c -S -s || ${workspaceRoot}/tools/qemu-linux/qemu-system-i386 -curses -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -bios ../bios32.bin -drive format=raw,file=../../HDImage.bin,index=0,if=ide -boot c -S -s"
144+
"command": "echo a && qemu-system-i386 -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -bios tools/bios32.bin -drive format=raw,file=HDImage.bin,index=0,if=ide -boot c -S -s || qemu-system-i386 -curses -audiodev pa,id=stdsound -machine pcspk-audiodev=stdsound -bios tools/bios32.bin -drive format=raw,file=HDImage.bin,index=0,if=ide -boot c -S -s"
145145
},
146146
"group": "none",
147147
"presentation": {

BUILD_IMAGE.BAT

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ for %%a in ("%user_programs_paths: =" "%") do (
8888
:imageBuilt
8989
if "%IMAGE_TYPE%"=="HD" (
9090
del HDImage.vdi >nul 2>&1
91-
VBoxManage convertfromraw --uuid d32a4d71-7ccb-4864-a684-c9d7c7a425f5 -format VDI HDImage.bin HDImage.vdi || echo Failed building VDI HD image&&goto ERROR
91+
qemu-img convert -f raw -O vdi HDImage.bin HDImage.vdi || echo Failed building VDI HD image&&goto ERROR
92+
python3 -c "f = open('HDImage.vdi', 'r+b'); f.seek(0x188); f.write(b'\x71\x4d\x2a\xd3\xcb\x7c\x64\x48\xa6\x84\xc9\xd7\xc7\xa4\x25\xf5'); f.close();"
9293
)
9394
echo %IMAGE_TYPE% Image was built
9495
goto eof

DOWNLOAD_TOOLS.BAT

Lines changed: 0 additions & 9 deletions
This file was deleted.

QEMU_BOOT.BAT

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
@echo off
22
cd %~d0%~p0
3+
call SET_ENV_VARS.BAT
34

45
set IMAGE_TYPE=
56
set DEBUG=0
67
set EFI=0
78
set SECONDARY_HD_IMAGE=
8-
set QEMU_CMD=tools\qemu-windows\qemu-system-i386.exe
9+
set QEMU_CMD=qemu-system-i386
910
set QEMU_ARGS=-audiodev dsound,id=stdsound -machine pcspk-audiodev=stdsound
1011

1112
:argLoop
@@ -22,7 +23,7 @@ if "%1" neq "" (
2223
) else if "%1"=="--efi" (
2324
set EFI=1
2425
) else if "%1"=="--x64" (
25-
set QEMU_CMD=tools\qemu-windows\qemu-system-x86_64.exe
26+
set QEMU_CMD=qemu-system-x86_64
2627
) else if "%1"=="--secondary-hd-image" (
2728
set SECONDARY_HD_IMAGE=%2
2829
set SECONDARY_HD_IMAGE=!SECONDARY_HD_IMAGE:"=!
@@ -48,10 +49,9 @@ if "%IMAGE_TYPE%"=="HD" (
4849
)
4950

5051
if "%DEBUG%"=="1" (
51-
call SET_ENV_VARS.BAT
5252
if not exist kernel\CHAOSKRN.SYS_debug echo WARNING^^! CHAOSKRN.SYS_debug does not exist
5353
start /b cmd /c %QEMU_CMD% %QEMU_ARGS% -S -s
54-
tools\gdb-multiarch.bat -x kernel_debug.gdb
54+
gdb -x kernel_debug.gdb
5555
) else (
5656
%QEMU_CMD% %QEMU_ARGS%
5757
)

0 commit comments

Comments
 (0)