replace nob with ms' build, move disk creation to build.bat, major comment cleanup, remove old and stupid tests, overhaul interrupt management with per-CPU vector allocation, affinity migration and safe teardown, add proper IOAPIC routing and PCI MSI/MSI-X/INTx support, migrate drivers to the new interrupt API, integrate ACPICA with a proper OS services layer, move ACPI firmware events, power button handling and S5 shutdown into acpi.sys, add parallel driver startup and atomic publication, replace PnP arrays with dynamic lists, redesign service startup again to be asynchronous, add delayed startup mode for services, allow omitting keys in services.ini, fix acpi ec deferred work handling, fix kernel threads having garbage exit code.
This commit is contained in:
1 parent
d36f19509c
commit
36eef8f58d
696 files changed
+147281
-7530
No files matched your search
@@ -1,9 +1,134 @@
|
||||
@echo off
|
||||
:: If the build system binary doesn't exist, bootstrap it!
|
||||
if not exist "code\build\build.exe" (
|
||||
echo Bootstrapping build system...
|
||||
cl.exe /nologo /Fe"code\build\build.exe" "code\build\build.c"
|
||||
setlocal EnableExtensions DisableDelayedExpansion
|
||||
pushd "%~dp0" || exit /b 1
|
||||
|
||||
if not exist "sdktools\out\build.exe" (
|
||||
call "sdktools\build.bat"
|
||||
if errorlevel 1 goto :fail
|
||||
)
|
||||
rem BUILD scans includes separately from the NMAKE compiler flags.
|
||||
set "INCLUDE=%CD%\code\public;%CD%\code\common\include;%INCLUDE%"
|
||||
"sdktools\out\build.exe" %*
|
||||
if errorlevel 1 goto :fail
|
||||
if /I "%NTL_SKIP_VHD%"=="1" goto :done
|
||||
|
||||
for %%T in (mformat mdir mmd mcopy) do (
|
||||
where %%T >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo Missing mtools utility: %%T 1>&2
|
||||
goto :fail
|
||||
)
|
||||
)
|
||||
|
||||
:: Run the build system, passing any args along
|
||||
"code\build\build.exe" %*
|
||||
if exist "disk.vhd" (
|
||||
call :ValidateVhd || goto :fail
|
||||
) else (
|
||||
call :CreateVhd || goto :fail
|
||||
)
|
||||
|
||||
set "ESP=disk.vhd@@1M"
|
||||
set "SYS=disk.vhd@@65M"
|
||||
for %%D in (EFI EFI/BOOT EFI/NTLite EFI/NTLite/fs) do (
|
||||
call :EnsureDir "%ESP%" "%%D" || goto :fail
|
||||
)
|
||||
for %%D in (apps system drivers) do (
|
||||
call :EnsureDir "%SYS%" "%%D" || goto :fail
|
||||
)
|
||||
|
||||
call :CopyFat "bin\bootx64.efi" "%ESP%" "EFI/BOOT/bootx64.efi" || goto :fail
|
||||
call :CopyFat "code\boot.ini" "%ESP%" "boot.ini" || goto :fail
|
||||
for %%F in ("code\boot\uefi\fs\*.efi") do (
|
||||
if exist "%%~fF" (
|
||||
call :CopyFat "%%~fF" "%ESP%" "EFI/NTLite/fs/%%~nxF" || goto :fail
|
||||
)
|
||||
)
|
||||
|
||||
call :CopyFat "bin\kernel.exe" "%SYS%" "system/colonel.exe" || goto :fail
|
||||
for %%F in (
|
||||
bin\hal.dll bin\syscall.dll bin\win32.dll bin\posix.dll
|
||||
bin\init.exe bin\rssrv.exe bin\posixsrv.exe bin\dwm.exe
|
||||
code\settings.ini code\services.ini
|
||||
) do (
|
||||
call :CopyFat "%%F" "%SYS%" "system/%%~nxF" || goto :fail
|
||||
)
|
||||
for %%F in (
|
||||
bin\pci.sys bin\ps2.sys bin\hda.sys bin\ata.sys bin\ahci.sys
|
||||
bin\fat.sys bin\ntfs.sys bin\ext4.sys bin\vmwaresvga.sys
|
||||
bin\lwip.sys bin\usb.sys bin\acpi.sys bin\rtl816x.sys bin\rtl8139.sys
|
||||
code\drivers.ini
|
||||
) do (
|
||||
call :CopyFat "%%F" "%SYS%" "drivers/%%~nxF" || goto :fail
|
||||
)
|
||||
call :CopyFat "bin\serial.sys" "%SYS%" "drivers/cereal.sys" || goto :fail
|
||||
for %%F in (
|
||||
bin\shell_win32.exe bin\shell_posix.exe bin\shell_native.exe
|
||||
bin\edit.exe bin\httpget.exe bin\tcpserve.exe bin\udp.exe
|
||||
bin\resolve.exe bin\ping.exe bin\doom.exe bin\video.exe bin\memtop.exe
|
||||
) do (
|
||||
call :CopyFat "%%F" "%SYS%" "apps/%%~nxF" || goto :fail
|
||||
)
|
||||
for %%F in (
|
||||
code\user\apps\video\bink2w64.dll
|
||||
code\user\apps\video\video.bk2
|
||||
code\user\apps\doom\doom1.wad
|
||||
) do (
|
||||
if exist "%%F" (
|
||||
call :CopyFat "%%F" "%SYS%" "apps/%%~nxF" || goto :fail
|
||||
)
|
||||
)
|
||||
if /I "%NTL_WITH_TESTS%"=="1" (
|
||||
call :EnsureDir "%SYS%" "tests" || goto :fail
|
||||
for /D %%D in ("code\user\tests\*") do (
|
||||
if exist "%%~fD\sources" (
|
||||
call :CopyFat "bin\%%~nxD.exe" "%SYS%" "tests/%%~nxD.exe" || goto :fail
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
echo Updated disk.vhd
|
||||
:done
|
||||
popd
|
||||
exit /b 0
|
||||
|
||||
:fail
|
||||
echo Build or VHD packaging failed. 1>&2
|
||||
popd
|
||||
exit /b 1
|
||||
|
||||
:EnsureDir
|
||||
mdir -i "%~1" "::%~2" >nul 2>&1
|
||||
if not errorlevel 1 exit /b 0
|
||||
mmd -i "%~1" "::%~2"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:CopyFat
|
||||
if not exist "%~1" (
|
||||
echo Missing build artifact: %~1 1>&2
|
||||
exit /b 1
|
||||
)
|
||||
mcopy -o -i "%~2" "%~1" "::%~3"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:ValidateVhd
|
||||
powershell -NoProfile -Command "$ErrorActionPreference='Stop'; $f=[IO.File]::OpenRead('disk.vhd'); try { $m=New-Object byte[] 512; if ($f.Length -ne 536871424 -or $f.Read($m,0,512) -ne 512) {throw 'Unexpected VHD size'}; if ([BitConverter]::ToUInt32($m,440) -ne 0x4E544C31 -or $m[510] -ne 85 -or $m[511] -ne 170) {throw 'Unexpected disk signature'}; if ([BitConverter]::ToUInt32($m,454) -ne 2048 -or [BitConverter]::ToUInt32($m,458) -ne 131072 -or [BitConverter]::ToUInt32($m,470) -ne 133120 -or [BitConverter]::ToUInt32($m,474) -ne 524288) {throw 'Unexpected partition layout'}; $f.Position=536870912; $v=New-Object byte[] 512; if ($f.Read($v,0,512) -ne 512 -or [Text.Encoding]::ASCII.GetString($v,0,8) -ne 'conectix') {throw 'Invalid VHD footer'} } finally {$f.Dispose()}"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:CreateVhd
|
||||
if exist "disk.vhd.new" (
|
||||
echo disk.vhd.new already exists; resolve it before initializing a disk. 1>&2
|
||||
exit /b 1
|
||||
)
|
||||
echo Creating 512 MiB fixed VHD...
|
||||
powershell -NoProfile -Command "$ErrorActionPreference='Stop'; function Be([byte[]]$a,[int]$o,[uint64]$v,[int]$n) {for($i=0;$i -lt $n;$i++) {$a[$o+$i]=[byte](($v -shr (8*($n-$i-1))) -band 255)}}; $s=[IO.File]::Open('disk.vhd.new',[IO.FileMode]::CreateNew,[IO.FileAccess]::ReadWrite); try { $s.SetLength(536871424); $m=New-Object byte[] 512; [BitConverter]::GetBytes([uint32]0x4E544C31).CopyTo($m,440); $m[510]=85; $m[511]=170; [byte[]]$p=0x80,0,2,0,12,254,255,255; [Array]::Copy($p,0,$m,446,8); [BitConverter]::GetBytes([uint32]2048).CopyTo($m,454); [BitConverter]::GetBytes([uint32]131072).CopyTo($m,458); [byte[]]$p=0,0,1,8,12,254,255,255; [Array]::Copy($p,0,$m,462,8); [BitConverter]::GetBytes([uint32]133120).CopyTo($m,470); [BitConverter]::GetBytes([uint32]524288).CopyTo($m,474); $s.Write($m,0,512); $v=New-Object byte[] 512; [Text.Encoding]::ASCII.GetBytes('conectix').CopyTo($v,0); $v[11]=2; $v[13]=1; for($i=16;$i -lt 24;$i++) {$v[$i]=255}; [Text.Encoding]::ASCII.GetBytes('qemu').CopyTo($v,28); $v[33]=2; [Text.Encoding]::ASCII.GetBytes('Wi2k').CopyTo($v,36); Be $v 40 ([uint64]536870912) 8; Be $v 48 ([uint64]536870912) 8; $v[56]=4; $v[58]=16; $v[59]=63; $v[63]=2; [byte[]]$id=0xA1,0xB2,0xC3,0xD4,0xE5,0xF6,0x78,0x90,0x12,0x34,0x56,0x78,0x9A,0xBC,0xDE,0xF0; [Array]::Copy($id,0,$v,68,16); $sum=0; foreach($b in $v) {$sum+=$b}; Be $v 64 ([uint64]([uint32]::MaxValue - [uint32]$sum)) 4; $s.Position=536870912; $s.Write($v,0,512) } finally {$s.Dispose()}"
|
||||
if errorlevel 1 goto :CreateFailed
|
||||
mformat -i "disk.vhd.new@@1M" -F -T 131072 -H 2048
|
||||
if errorlevel 1 goto :CreateFailed
|
||||
mformat -i "disk.vhd.new@@65M" -F -T 524288 -H 133120
|
||||
if errorlevel 1 goto :CreateFailed
|
||||
move /y "disk.vhd.new" "disk.vhd" >nul
|
||||
if errorlevel 1 goto :CreateFailed
|
||||
exit /b 0
|
||||
|
||||
:CreateFailed
|
||||
if exist "disk.vhd.new" del /q "disk.vhd.new"
|
||||
exit /b 1
|
||||
Reference in new issue
Block a user