Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a6be7f66e | ||
|
|
6a1eb5e2ac |
No files matched your search
@@ -1,6 +1,8 @@
|
|||||||
/lib/*.ppu
|
/lib/*.ppu
|
||||||
/lib/*.a
|
/lib/*.a
|
||||||
/lib/*.o
|
/lib/*.o
|
||||||
|
/lib/x86_64/
|
||||||
|
/bin/x86_64/
|
||||||
/release/*.svg
|
/release/*.svg
|
||||||
/release/*.iso
|
/release/*.iso
|
||||||
/bin/*.bin
|
/bin/*.bin
|
||||||
|
|||||||
+3
-3
@@ -6,7 +6,7 @@ ENV DEBIAN_FRONTEND=noninteractive
|
|||||||
RUN dpkg --add-architecture i386
|
RUN dpkg --add-architecture i386
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
curl dos2unix wget git make nasm binutils xorriso grub-pc-bin gcc gcc-multilib \
|
curl dos2unix wget git make nasm binutils xorriso grub-pc-bin gcc gcc-multilib \
|
||||||
python3 python3-pip python3-pil && \
|
python3 python3-pip python3-pil fp-compiler && \
|
||||||
apt-get clean my room
|
apt-get clean my room
|
||||||
|
|
||||||
RUN pip3 install --no-cache-dir --break-system-packages "mkdocs>=1.6,<2" mkdocs-material
|
RUN pip3 install --no-cache-dir --break-system-packages "mkdocs>=1.6,<2" mkdocs-material
|
||||||
@@ -20,6 +20,6 @@ RUN curl -sL https://sourceforge.net/projects/freepascal/files/Linux/$FPC_VERSIO
|
|||||||
ADD https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver /usr/bin/semver
|
ADD https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver /usr/bin/semver
|
||||||
RUN chmod +x /usr/bin/semver
|
RUN chmod +x /usr/bin/semver
|
||||||
WORKDIR /code
|
WORKDIR /code
|
||||||
RUN find . -type f -print0 | xargs -0 dos2unix
|
# Sources are mounted at runtime; the CMD below normalizes build scripts.
|
||||||
ENTRYPOINT ["/bin/bash", "-c"]
|
ENTRYPOINT ["/bin/bash", "-c"]
|
||||||
CMD ["find toolchain -name '*.sh' -exec dos2unix {} + 2>/dev/null; find toolchain -name '*.sh' -exec chmod +x {} +; bash toolchain/compile.sh"]
|
CMD ["find toolchain -name '*.sh' -exec dos2unix {} + 2>/dev/null; find toolchain -name '*.sh' -exec chmod +x {} +; bash toolchain/compile.sh"]
|
||||||
File diff suppressed because it is too large.
Load diff
+4
-1
@@ -1,5 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
builder:
|
builder:
|
||||||
build: .
|
build: .
|
||||||
|
environment:
|
||||||
|
ASURO_ARCH: ${ASURO_ARCH:-x86}
|
||||||
|
ASURO_BOOT_TEST: ${ASURO_BOOT_TEST:-none}
|
||||||
volumes:
|
volumes:
|
||||||
- .:/code
|
- .:/code
|
||||||
@@ -295,6 +295,7 @@ nav:
|
|||||||
|
|
||||||
- Planning:
|
- Planning:
|
||||||
- Architecture: planning/architecture.md
|
- Architecture: planning/architecture.md
|
||||||
|
- x86-64 Migration: planning/x86_64.md
|
||||||
- USB: planning/USB.md
|
- USB: planning/USB.md
|
||||||
- XHCI: planning/XHCI.md
|
- XHCI: planning/XHCI.md
|
||||||
- FlatFS: planning/flatfs.md
|
- FlatFS: planning/flatfs.md
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
// Copyright 2026 Aaron Hance
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
unit arch.common.interrupts;
|
||||||
|
interface
|
||||||
|
function lock: PtrUInt;
|
||||||
|
procedure unlock(flags: PtrUInt);
|
||||||
|
implementation
|
||||||
|
uses arch.platform.cpu;
|
||||||
|
function lock: PtrUInt;
|
||||||
|
begin lock := arch.platform.cpu.lock; end;
|
||||||
|
procedure unlock(flags: PtrUInt);
|
||||||
|
begin arch.platform.cpu.unlock(flags); end;
|
||||||
|
end.
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// Copyright 2026 Aaron Hance
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
{ Shared PC interrupt-controller programming. Call with interrupts disabled. }
|
||||||
|
unit arch.common.legacyirq;
|
||||||
|
interface
|
||||||
|
const
|
||||||
|
PIT_INPUT_HZ = 1193182;
|
||||||
|
PIT_DIVISOR = 149;
|
||||||
|
procedure remap(masterMask, slaveMask: uint8);
|
||||||
|
procedure masks(masterMask, slaveMask: uint8);
|
||||||
|
procedure timerStart;
|
||||||
|
function realIRQ(line: uint8): boolean;
|
||||||
|
procedure acknowledge(line: uint8);
|
||||||
|
implementation
|
||||||
|
uses arch.platform.cpu;
|
||||||
|
procedure writeSlow(port: uint16; value: uint8);
|
||||||
|
begin
|
||||||
|
outb(port, value);
|
||||||
|
outb($80, 0);
|
||||||
|
end;
|
||||||
|
procedure masks(masterMask, slaveMask: uint8);
|
||||||
|
begin
|
||||||
|
writeSlow($21, masterMask); writeSlow($A1, slaveMask);
|
||||||
|
end;
|
||||||
|
procedure remap(masterMask, slaveMask: uint8);
|
||||||
|
begin
|
||||||
|
writeSlow($20, $11); writeSlow($A0, $11);
|
||||||
|
writeSlow($21, $20); writeSlow($A1, $28);
|
||||||
|
writeSlow($21, $04); writeSlow($A1, $02);
|
||||||
|
writeSlow($21, $01); writeSlow($A1, $01);
|
||||||
|
masks(masterMask, slaveMask);
|
||||||
|
end;
|
||||||
|
procedure timerStart;
|
||||||
|
begin
|
||||||
|
{ Channel 0, low/high byte, mode 2, binary. }
|
||||||
|
outb($43, $34);
|
||||||
|
outb($40, PIT_DIVISOR and $FF);
|
||||||
|
outb($40, PIT_DIVISOR shr 8);
|
||||||
|
end;
|
||||||
|
function realIRQ(line: uint8): boolean;
|
||||||
|
begin
|
||||||
|
realIRQ := line < 16;
|
||||||
|
if line = 7 then begin
|
||||||
|
outb($20, $0B);
|
||||||
|
realIRQ := (inb($20) and $80) <> 0;
|
||||||
|
end else if line = 15 then begin
|
||||||
|
outb($A0, $0B);
|
||||||
|
realIRQ := (inb($A0) and $80) <> 0;
|
||||||
|
{ A spurious slave request still put master IRQ2 in service. }
|
||||||
|
if not realIRQ then outb($20, $20);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
procedure acknowledge(line: uint8);
|
||||||
|
begin
|
||||||
|
if line >= 16 then exit;
|
||||||
|
if line >= 8 then outb($A0, $20);
|
||||||
|
outb($20, $20);
|
||||||
|
end;
|
||||||
|
end.
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2026 Aaron Hance
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
{ Shared contract; implemented by each build-selected adapter. }
|
||||||
|
function lock: PtrUInt;
|
||||||
|
procedure unlock(flags: PtrUInt);
|
||||||
|
procedure outb(port: uint16; value: uint8);
|
||||||
|
function inb(port: uint16): uint8;
|
||||||
|
procedure copyBytes(source, dest: PtrUInt; bytes: SizeUInt);
|
||||||
|
procedure zero(dest: pointer; bytes: SizeUInt);
|
||||||
|
procedure idle;
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2026 Aaron Hance
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
{ Shared contract; implemented by each build-selected adapter. }
|
||||||
|
procedure log(tag, message: pchar);
|
||||||
|
procedure push_trace(name: pchar);
|
||||||
|
procedure pop_trace;
|
||||||
|
procedure fatal(tag, message: pchar);
|
||||||
|
procedure testSummary(tag, passedKey, failedKey: pchar; passed, failed: uint32);
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2026 Aaron Hance
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
{ Shared contract; implemented by each build-selected adapter. }
|
||||||
|
function allocateHeapPage: PtrUInt;
|
||||||
|
function allocateLarge(pages: uint32): PtrUInt;
|
||||||
|
procedure release(address: PtrUInt; pages: uint32);
|
||||||
|
function identityReserve(address: PtrUInt): pointer;
|
||||||
|
function freeBacking: uint64;
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright 2026 Aaron Hance
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
{ Shared contract; implemented by each build-selected adapter. }
|
||||||
|
function prepare(stack: pointer; bytes: SizeUInt; entry: pointer): PtrUInt;
|
||||||
|
function timerTicks: uint32;
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,82 @@
|
|||||||
|
// Copyright 2026 Aaron Hance
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
{ Commands extracted from io.stdio (Kieron Morris). }
|
||||||
|
unit arch.x86.console;
|
||||||
|
interface
|
||||||
|
procedure init;
|
||||||
|
implementation
|
||||||
|
uses io.stdio, core.version, driver.timer.rtc, arch.x86.util;
|
||||||
|
procedure cmd_version(params: PParamList; stdin_buf, stdout_buf, stderr_buf: POutBuf);
|
||||||
|
begin
|
||||||
|
bufWriteStr(stdout_buf, ' Asuro Version: ');
|
||||||
|
bufWriteStrLn(stdout_buf, core.version.VERSION);
|
||||||
|
bufWriteStr(stdout_buf, ' Compiled on: ');
|
||||||
|
bufWriteStr(stdout_buf, core.version.COMPILE_DATE);
|
||||||
|
bufWriteStr(stdout_buf, ' ');
|
||||||
|
bufWriteStrLn(stdout_buf, core.version.COMPILE_TIME);
|
||||||
|
bufWriteStrLn(stdout_buf, ' Compiled With: ');
|
||||||
|
bufWriteStr(stdout_buf, ' NASM - Version: ');
|
||||||
|
bufWriteStrLn(stdout_buf, core.version.NASM_VERSION);
|
||||||
|
bufWriteStr(stdout_buf, ' FPC - Version: ');
|
||||||
|
bufWriteStrLn(stdout_buf, core.version.FPC_VERSION);
|
||||||
|
bufWriteStr(stdout_buf, ' MAKE - Version: ');
|
||||||
|
bufWriteStrLn(stdout_buf, core.version.MAKE_VERSION);
|
||||||
|
bufWriteStr(stdout_buf, ' ');
|
||||||
|
bufWriteInt(stdout_buf, core.version.LINE_COUNT);
|
||||||
|
bufWriteStr(stdout_buf, ' lines, across ');
|
||||||
|
bufWriteInt(stdout_buf, core.version.FILE_COUNT);
|
||||||
|
bufWriteStrLn(stdout_buf, ' files.');
|
||||||
|
bufWriteStr(stdout_buf, ' Baked Drivers: ');
|
||||||
|
bufWriteIntLn(stdout_buf, core.version.DRIVER_COUNT);
|
||||||
|
bufWriteStr(stdout_buf, ' Checksum: ');
|
||||||
|
bufWriteStrLn(stdout_buf, core.version.CHECKSUM);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure cmd_time(params: PParamList; stdin_buf, stdout_buf, stderr_buf: POutBuf);
|
||||||
|
var
|
||||||
|
dt: TDateTime;
|
||||||
|
begin
|
||||||
|
dt := getDateTime;
|
||||||
|
if dt.Day < 10 then bufWriteChar(stdout_buf, '0');
|
||||||
|
bufWriteInt(stdout_buf, dt.Day);
|
||||||
|
bufWriteChar(stdout_buf, '/');
|
||||||
|
if dt.Month < 10 then bufWriteChar(stdout_buf, '0');
|
||||||
|
bufWriteInt(stdout_buf, dt.Month);
|
||||||
|
bufWriteChar(stdout_buf, '/');
|
||||||
|
bufWriteInt(stdout_buf, dt.Century);
|
||||||
|
bufWriteInt(stdout_buf, dt.Year);
|
||||||
|
bufWriteChar(stdout_buf, ' ');
|
||||||
|
if dt.Hours < 10 then bufWriteChar(stdout_buf, '0');
|
||||||
|
bufWriteInt(stdout_buf, dt.Hours);
|
||||||
|
bufWriteChar(stdout_buf, ':');
|
||||||
|
if dt.Minutes < 10 then bufWriteChar(stdout_buf, '0');
|
||||||
|
bufWriteInt(stdout_buf, dt.Minutes);
|
||||||
|
bufWriteChar(stdout_buf, ':');
|
||||||
|
if dt.Seconds < 10 then bufWriteChar(stdout_buf, '0');
|
||||||
|
bufWriteIntLn(stdout_buf, dt.Seconds);
|
||||||
|
bufWriteStr(stdout_buf, 'Weekday: ');
|
||||||
|
bufWriteStrLn(stdout_buf, WeekdayToString(dt.Weekday));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure cmd_reboot(params: PParamList; stdin_buf, stdout_buf, stderr_buf: POutBuf);
|
||||||
|
begin
|
||||||
|
resetSystem;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure init;
|
||||||
|
begin
|
||||||
|
registerCommand('VERSION', @cmd_version, 'Display the running version of Asuro.');
|
||||||
|
registerCommand('TIME', @cmd_time, 'Print the current time.');
|
||||||
|
registerCommand('REBOOT', @cmd_reboot, 'Reboot the system.');
|
||||||
|
end;
|
||||||
|
end.
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
// Copyright 2021 Kieron Morris
|
// Copyright 2021 Kieron Morris
|
||||||
|
// Copyright 2026 Aaron Hance
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@@ -22,7 +23,7 @@ unit arch.x86.irq;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
boot.mgr,
|
boot.mgr, arch.common.legacyirq,
|
||||||
core.util, arch.x86.util, io.syslog;
|
core.util, arch.x86.util, io.syslog;
|
||||||
|
|
||||||
procedure init();
|
procedure init();
|
||||||
@@ -32,26 +33,7 @@ implementation
|
|||||||
procedure init();
|
procedure init();
|
||||||
begin
|
begin
|
||||||
io.syslog.logln('IRQ','INIT START.');
|
io.syslog.logln('IRQ','INIT START.');
|
||||||
outb($20, $11);
|
arch.common.legacyirq.remap(0, 0);
|
||||||
io_wait;
|
|
||||||
outb($A0, $11);
|
|
||||||
io_wait;
|
|
||||||
outb($21, $20);
|
|
||||||
io_wait;
|
|
||||||
outb($A1, $28);
|
|
||||||
io_wait;
|
|
||||||
outb($21, $04);
|
|
||||||
io_wait;
|
|
||||||
outb($A1, $02);
|
|
||||||
io_wait;
|
|
||||||
outb($21, $01);
|
|
||||||
io_wait;
|
|
||||||
outb($A1, $01);
|
|
||||||
io_wait;
|
|
||||||
outb($21, $00);
|
|
||||||
io_wait;
|
|
||||||
outb($A1, $00);
|
|
||||||
io_wait;
|
|
||||||
io.syslog.logln('IRQ','INIT END.');
|
io.syslog.logln('IRQ','INIT END.');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 Kieron Morris
|
// Copyright 2021 Kieron Morris & Aaron Hance
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@@ -21,65 +21,22 @@ unit arch.x86.multiboot;
|
|||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
|
uses boot.multiboot;
|
||||||
|
|
||||||
const
|
const
|
||||||
KERNEL_STACKSIZE = $4000;
|
KERNEL_STACKSIZE = $4000;
|
||||||
MULTIBOOT_BOOTLOADER_MAGIC = $2BADB002;
|
MULTIBOOT_BOOTLOADER_MAGIC = $2BADB002;
|
||||||
|
|
||||||
type
|
type
|
||||||
Pelf_section_header_table_t = ^elf_section_header_table_t;
|
elf_section_header_table_t = boot.multiboot.elf_section_header_table_t;
|
||||||
elf_section_header_table_t = packed record
|
Pelf_section_header_table_t = boot.multiboot.Pelf_section_header_table_t;
|
||||||
num: uint32;
|
multiboot_info_t = boot.multiboot.multiboot_info_t;
|
||||||
size: uint32;
|
Pmultiboot_info_t = boot.multiboot.Pmultiboot_info_t;
|
||||||
addr: uint32;
|
module_t = boot.multiboot.module_t;
|
||||||
shndx: uint32;
|
Pmodule_t = boot.multiboot.Pmodule_t;
|
||||||
end;
|
memory_map_t = boot.multiboot.memory_map_t;
|
||||||
|
Pmemory_map_t = boot.multiboot.Pmemory_map_t;
|
||||||
Pmultiboot_info_t = ^multiboot_info_t;
|
|
||||||
multiboot_info_t = packed record
|
|
||||||
flags: uint32;
|
|
||||||
mem_lower: uint32;
|
|
||||||
mem_upper: uint32;
|
|
||||||
boot_device: uint32;
|
|
||||||
cmdline: uint32;
|
|
||||||
mods_count: uint32;
|
|
||||||
mods_addr: uint32;
|
|
||||||
elf_sec: elf_section_header_table_t;
|
|
||||||
mmap_length: uint32;
|
|
||||||
mmap_addr: uint32;
|
|
||||||
drives_legnth : uint32;
|
|
||||||
drives_addr: uint32;
|
|
||||||
config_table : uint32;
|
|
||||||
boot_loader_name : uint32;
|
|
||||||
apm_table: uint32;
|
|
||||||
vbe_control_info : uint32;
|
|
||||||
vbe_mode_info : uint32;
|
|
||||||
vbe_mode : uint16;
|
|
||||||
vbe_interface_seg : uint16;
|
|
||||||
vbe_interface_off : uint16;
|
|
||||||
vbe_interface_len : uint16;
|
|
||||||
framebuffer_addr : uint64;
|
|
||||||
framebuffer_pitch : uint32;
|
|
||||||
framebuffer_width : uint32;
|
|
||||||
framebuffer_height: uint32;
|
|
||||||
framebuffer_bpp : uint8;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Pmodule_t = ^module_t;
|
|
||||||
module_t = packed record
|
|
||||||
mod_start: uint32;
|
|
||||||
mod_end: uint32;
|
|
||||||
name: uint32;
|
|
||||||
reserved: uint32;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Pmemory_map_t = ^memory_map_t;
|
|
||||||
memory_map_t = packed record
|
|
||||||
size: uint32;
|
|
||||||
base_addr : uint64;
|
|
||||||
length : uint64;
|
|
||||||
mtype: uint32;
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
var
|
||||||
multibootinfo : Pmultiboot_info_t = nil;
|
multibootinfo : Pmultiboot_info_t = nil;
|
||||||
multibootmagic : uint32;
|
multibootmagic : uint32;
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// Copyright 2026 Aaron Hance
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
{ Compose shared services with the i386 boot manager and platform commands. }
|
||||||
|
unit arch.x86.startup;
|
||||||
|
interface
|
||||||
|
implementation
|
||||||
|
uses boot.mgr, memory.heap, proc.mgr, io.stdio, arch.x86.console;
|
||||||
|
procedure consoleInit;
|
||||||
|
begin io.stdio.init; arch.x86.console.init; end;
|
||||||
|
initialization
|
||||||
|
boot.mgr.registerBoot('memory.heap', @memory.heap.init, 'Heap Memory Manager', 'arch.*.memory.*');
|
||||||
|
boot.mgr.registerBoot('io.stdio', @consoleInit, 'Standard I/O Abstraction', BOOT_MGR_BARRIER_EARLY);
|
||||||
|
boot.mgr.registerBoot('proc.mgr', @proc.mgr.init, 'Process Manager', 'driver.storage.fs*');
|
||||||
|
end.
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
// Copyright 2021 Kieron Morris
|
// Copyright 2021 Kieron Morris
|
||||||
|
// Copyright 2026 Aaron Hance
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@@ -22,14 +23,14 @@ unit arch.x86.isr.tmr0;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
core.util, arch.x86.util,
|
core.util, arch.x86.util, arch.common.legacyirq,
|
||||||
arch.x86.isr.types,
|
arch.x86.isr.types,
|
||||||
arch.x86.isr.mgr,
|
arch.x86.isr.mgr,
|
||||||
arch.x86.idt;
|
arch.x86.idt;
|
||||||
|
|
||||||
const
|
const
|
||||||
PIT_INPUT_HZ = 1193182;
|
PIT_INPUT_HZ = arch.common.legacyirq.PIT_INPUT_HZ;
|
||||||
PIT_DIVISOR = 149;
|
PIT_DIVISOR = arch.common.legacyirq.PIT_DIVISOR;
|
||||||
|
|
||||||
procedure register();
|
procedure register();
|
||||||
procedure hook(hook_method : uint32);
|
procedure hook(hook_method : uint32);
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
// Copyright 2026 Aaron Hance
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
{ Build-selected x86 adapter. }
|
||||||
|
unit arch.platform.cpu;
|
||||||
|
interface
|
||||||
|
{$i ../../common/platform.cpu.inc}
|
||||||
|
implementation
|
||||||
|
uses arch.x86.util, memory.raw;
|
||||||
|
function lock: PtrUInt; assembler; nostackframe;
|
||||||
|
asm pushfd; cli; pop eax end;
|
||||||
|
procedure unlock(flags: PtrUInt);
|
||||||
|
begin if (flags and $200) <> 0 then asm sti end; end;
|
||||||
|
procedure idle;
|
||||||
|
begin asm hlt end; end;
|
||||||
|
procedure outb(port: uint16; value: uint8);
|
||||||
|
begin arch.x86.util.outb(port, value); end;
|
||||||
|
function inb(port: uint16): uint8;
|
||||||
|
begin inb := arch.x86.util.inb(port); end;
|
||||||
|
procedure copyBytes(source, dest: PtrUInt; bytes: SizeUInt);
|
||||||
|
begin
|
||||||
|
if bytes >= 16 then arch.x86.util.__REP_MOVSB_memcpy(source, dest, bytes)
|
||||||
|
else memory.raw.move(pointer(source), pointer(dest), bytes);
|
||||||
|
end;
|
||||||
|
procedure zero(dest: pointer; bytes: SizeUInt);
|
||||||
|
var d: pointer; b: SizeUInt;
|
||||||
|
begin
|
||||||
|
d := dest; b := bytes;
|
||||||
|
if b = 0 then exit;
|
||||||
|
asm
|
||||||
|
push edi
|
||||||
|
mov edi, d
|
||||||
|
mov ecx, b
|
||||||
|
shr ecx, 2
|
||||||
|
xor eax, eax
|
||||||
|
cld
|
||||||
|
rep stosd
|
||||||
|
mov ecx, b
|
||||||
|
and ecx, 3
|
||||||
|
rep stosb
|
||||||
|
pop edi
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end.
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Copyright 2026 Aaron Hance
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
{ Build-selected x86 adapter. }
|
||||||
|
unit arch.platform.diagnostics;
|
||||||
|
interface
|
||||||
|
{$i ../../common/platform.diagnostics.inc}
|
||||||
|
implementation
|
||||||
|
uses io.syslog, debug.tracer, core.panic;
|
||||||
|
procedure log(tag, message: pchar);
|
||||||
|
begin io.syslog.logln(tag, message); end;
|
||||||
|
procedure push_trace(name: pchar);
|
||||||
|
begin debug.tracer.push_trace(name); end;
|
||||||
|
procedure pop_trace;
|
||||||
|
begin debug.tracer.pop_trace; end;
|
||||||
|
procedure fatal(tag, message: pchar);
|
||||||
|
begin core.panic.panic(tag, message, nil); end;
|
||||||
|
procedure testSummary(tag, passedKey, failedKey: pchar; passed, failed: uint32);
|
||||||
|
begin
|
||||||
|
io.syslog.log(tag, '');
|
||||||
|
io.syslog.writeint(passed); io.syslog.writestring(' passed, ');
|
||||||
|
io.syslog.writeint(failed); io.syslog.writestringln(' failed.');
|
||||||
|
end;
|
||||||
|
end.
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
// Copyright 2026 Aaron Hance
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
{ Mapping policy extracted from memory.heap (Kieron Morris). }
|
||||||
|
unit arch.platform.memory;
|
||||||
|
interface
|
||||||
|
const MAX_HEAP_REGIONS = 256;
|
||||||
|
{$i ../../common/platform.memory.inc}
|
||||||
|
implementation
|
||||||
|
uses arch.x86.memory.virtual, arch.x86.memory.physical, arch.platform.diagnostics;
|
||||||
|
function allocateHeapPage: PtrUInt;
|
||||||
|
var i: uint32;
|
||||||
|
begin
|
||||||
|
allocateHeapPage := 0;
|
||||||
|
i := KERNEL_PAGE_NUMBER + 4;
|
||||||
|
while i < 1024 do begin
|
||||||
|
if arch.x86.memory.virtual.new_page(i) then begin
|
||||||
|
allocateHeapPage := i shl 22; exit;
|
||||||
|
end;
|
||||||
|
inc(i);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
function allocateLarge(pages: uint32): PtrUInt;
|
||||||
|
var curr_page, i: uint16; miss: boolean;
|
||||||
|
begin
|
||||||
|
allocateLarge := 0;
|
||||||
|
if (pages = 0) or (pages > MAX_HEAP_REGIONS) then exit;
|
||||||
|
curr_page := 5;
|
||||||
|
while uint32(curr_page) + pages - 1 < KERNEL_PAGE_NUMBER do begin
|
||||||
|
miss := false;
|
||||||
|
for i := 0 to pages - 1 do begin
|
||||||
|
if not page_mappable(curr_page + i) then begin
|
||||||
|
miss := true; curr_page := curr_page + i; break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if not miss then begin
|
||||||
|
i := 0;
|
||||||
|
while i < pages do begin
|
||||||
|
if not arch.x86.memory.virtual.new_page(curr_page + i) then begin
|
||||||
|
while i > 0 do begin
|
||||||
|
dec(i); arch.x86.memory.virtual.free_page(curr_page + i);
|
||||||
|
end;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
inc(i);
|
||||||
|
end;
|
||||||
|
allocateLarge := uint32(curr_page) shl 22;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
inc(curr_page);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
procedure release(address: PtrUInt; pages: uint32);
|
||||||
|
var i: uint32; page_num: uint16;
|
||||||
|
begin
|
||||||
|
if (pages = 0) or (pages > MAX_HEAP_REGIONS) then begin
|
||||||
|
fatal('LMM', 'Invalid heap region release'); exit;
|
||||||
|
end;
|
||||||
|
page_num := address shr 22;
|
||||||
|
for i := 0 to pages - 1 do arch.x86.memory.virtual.free_page(page_num + uint16(i));
|
||||||
|
end;
|
||||||
|
function identityReserve(address: PtrUInt): pointer;
|
||||||
|
var block: uint16;
|
||||||
|
begin
|
||||||
|
block := address shr 22;
|
||||||
|
force_alloc_block(block, 0);
|
||||||
|
map_page(block, block);
|
||||||
|
identityReserve := pointer(uint32(block) shl 22);
|
||||||
|
end;
|
||||||
|
function freeBacking: uint64;
|
||||||
|
begin freeBacking := pmm_free_blocks; end;
|
||||||
|
end.
|
||||||
Loaded 20 of 75 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user