Compare commits
42
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64a83a6c83 | ||
|
|
81d1b97cd0 | ||
|
|
84b589c856 | ||
|
|
8b80b6864b | ||
|
|
232f6b5485 | ||
|
|
569b2f0bca | ||
|
|
ed0f8d9c08 | ||
|
|
a2f6d7e76d | ||
|
|
babe4290e4 | ||
|
|
05eab23956 | ||
|
|
f04f8aa411 | ||
|
|
6a3ebf1387 | ||
|
|
b2ecbe58da | ||
|
|
2014ce4f9c | ||
|
|
6cd9ae4f46 | ||
|
|
0855abfd41 | ||
|
|
fd0de9f1d2 | ||
|
|
920aca5bbf | ||
|
|
837d69a44b | ||
|
|
f0d5eb21f1 | ||
|
|
07e9095582 | ||
|
|
72769fbef7 | ||
|
|
95599c0e7c | ||
|
|
fcaafa0d12 | ||
|
|
e490b95f1d | ||
|
|
b601080960 | ||
|
|
27177979a2 | ||
|
|
f88a282893 | ||
|
|
ff4c597ff3 | ||
|
|
24c371cab1 | ||
|
|
7588a4c9cb | ||
|
|
5cb415c76b | ||
|
|
118d8b0c03 | ||
|
|
28caca3bcc | ||
|
|
6476a774dc | ||
|
|
e791edb02a | ||
|
|
da36f6fabb | ||
|
|
97e1a18253 | ||
|
|
88a850e8fc | ||
|
|
10c9194c5f | ||
|
|
94b477d8f7 | ||
|
|
ba38f4fd19 |
No files matched your search
-52
@@ -1,52 +0,0 @@
|
|||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: build
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build-image
|
|
||||||
image: plugins/docker
|
|
||||||
settings:
|
|
||||||
repo: t3hn3rd/asuro-build
|
|
||||||
tags: latest
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
registry: docker.io
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
|
|
||||||
- name: compile
|
|
||||||
image: t3hn3rd/asuro-build:latest
|
|
||||||
depends_on:
|
|
||||||
- build-image
|
|
||||||
commands:
|
|
||||||
- git fetch --tags
|
|
||||||
- find . -type f -print0 | xargs -0 dos2unix
|
|
||||||
- chmod +x /drone/src/*.sh
|
|
||||||
- /drone/src/compile.sh
|
|
||||||
|
|
||||||
- name: upload-iso-artifact
|
|
||||||
image: alpine/git
|
|
||||||
depends_on:
|
|
||||||
- compile
|
|
||||||
when:
|
|
||||||
branch:
|
|
||||||
- master
|
|
||||||
environment:
|
|
||||||
GITEA_TOKEN:
|
|
||||||
from_secret: gitea_token
|
|
||||||
commands:
|
|
||||||
- apk add --no-cache curl
|
|
||||||
- chmod +w Asuro.iso
|
|
||||||
- cp Asuro.iso "Asuro-$(git rev-parse --short HEAD).iso"
|
|
||||||
- echo "Uploading Asuro-$(git rev-parse --short HEAD).iso to Gitea Packages..."
|
|
||||||
- |
|
|
||||||
curl -X PUT "https://gitea.spexeah.com/api/packages/Spexeah/generic/asuro-iso/$(git rev-parse --short HEAD)/Asuro.iso" \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" --upload-file "Asuro-$(git rev-parse --short HEAD).iso"
|
|
||||||
- echo "Updating latest ISO reference..."
|
|
||||||
- |
|
|
||||||
curl -X DELETE https://gitea.spexeah.com/api/packages/Spexeah/generic/asuro-iso/latest/Asuro.iso \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" || echo "No previous latest version found."
|
|
||||||
- |
|
|
||||||
curl -X PUT https://gitea.spexeah.com/api/packages/Spexeah/generic/asuro-iso/latest/Asuro.iso \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" --upload-file "Asuro-$(git rev-parse --short HEAD).iso"
|
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
stages:
|
||||||
|
- Compile Versions
|
||||||
|
- Compile Sources
|
||||||
|
- Link
|
||||||
|
- Generate Documentation
|
||||||
|
- Deploy
|
||||||
|
|
||||||
|
cache:
|
||||||
|
- key: ${CI_COMMIT_REF_SLUG}
|
||||||
|
paths:
|
||||||
|
- lib/*.o
|
||||||
|
- bin/kernel.bin
|
||||||
|
- doc
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- chmod +x *.sh
|
||||||
|
|
||||||
|
versions:
|
||||||
|
stage: Compile Versions
|
||||||
|
script:
|
||||||
|
- ./compile_vergen.sh
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- release/*.svg
|
||||||
|
- src/include/asuro.pas
|
||||||
|
|
||||||
|
compile_sources:
|
||||||
|
stage: Compile Sources
|
||||||
|
script:
|
||||||
|
- rm -f lib/*.so
|
||||||
|
- ./compile_sources.sh
|
||||||
|
needs:
|
||||||
|
- versions
|
||||||
|
|
||||||
|
link:
|
||||||
|
stage: Link
|
||||||
|
script:
|
||||||
|
- ./compile_stub.sh
|
||||||
|
- ./compile_link.sh
|
||||||
|
needs:
|
||||||
|
- versions
|
||||||
|
- compile_sources
|
||||||
|
|
||||||
|
isogen:
|
||||||
|
stage: Deploy
|
||||||
|
script:
|
||||||
|
- ./compile_isogen.sh
|
||||||
|
- ./compile_sumgen.sh
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- ./Asuro.iso
|
||||||
|
- ./release/checksum.svg
|
||||||
|
needs:
|
||||||
|
- link
|
||||||
|
|
||||||
|
docgen:
|
||||||
|
stage: Generate Documentation
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
script:
|
||||||
|
- ./compile_sourcelist.sh
|
||||||
|
- ./compile_docs.sh
|
||||||
|
# Remove comments when we want to use gitlab pages.
|
||||||
|
#- cp doc public
|
||||||
|
allow_failure: true
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- doc
|
||||||
|
#- public/*
|
||||||
|
#- ./sources.list
|
||||||
|
needs:
|
||||||
|
- versions
|
||||||
+1
-1
@@ -16,7 +16,7 @@ RUN curl -sL https://sourceforge.net/projects/freepascal/files/Linux/$FPC_VERSIO
|
|||||||
|
|
||||||
COPY compile.sh /compile.sh
|
COPY compile.sh /compile.sh
|
||||||
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 mkdir /code && chmod +x /usr/bin/semver
|
||||||
WORKDIR /code
|
WORKDIR /code
|
||||||
RUN find . -type f -print0 | xargs -0 dos2unix
|
RUN find . -type f -print0 | xargs -0 dos2unix
|
||||||
ENTRYPOINT ["/bin/bash", "-c"]
|
ENTRYPOINT ["/bin/bash", "-c"]
|
||||||
|
|||||||
+14
-18
@@ -20,30 +20,26 @@ runOrFail() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
declare -a run_steps=(
|
runOrFail $(pwd)/compile_stub.sh "Failed to compile stub!"
|
||||||
"compile_stub.sh" "Failed to compile stub!"
|
|
||||||
"compile_vergen.sh" "Versions failed to compile"
|
|
||||||
"compile_sources.sh" "Failed to compile FPC Sources!"
|
|
||||||
"compile_link.sh" "Failed linking!"
|
|
||||||
"compile_isogen.sh" "Failed to create ISO!"
|
|
||||||
)
|
|
||||||
|
|
||||||
for ((i=0; i<${#run_steps[@]}; i+=2))
|
#Generate .pas with versioning headers.
|
||||||
do
|
runOrFail $(pwd)/compile_vergen.sh "Versions failed to compile"
|
||||||
if [ "$ERRCOUNT" -eq "0" ]
|
|
||||||
then
|
#Compile all .pas sources
|
||||||
script=$(pwd)/"${run_steps[$i]}"
|
runOrFail $(pwd)/compile_sources.sh "Failed to compile FPC Sources!"
|
||||||
message="${run_steps[$i+1]}"
|
|
||||||
runOrFail "$script" "$message"
|
#Link into a binary.
|
||||||
fi
|
runOrFail $(pwd)/compile_link.sh "Failed linking!"
|
||||||
done
|
|
||||||
|
#Generate an ISO with GRUB as the Bootloader.
|
||||||
|
runOrFail ./compile_isogen.sh "Failed to create ISO!"
|
||||||
|
|
||||||
#Call generate final artifacts based on failure or success of the above.
|
#Call generate final artifacts based on failure or success of the above.
|
||||||
if [ "$ERRCOUNT" -ne "0" ]
|
if [ "$ERRCOUNT" -ne "0" ]
|
||||||
then
|
then
|
||||||
. ./compile_finish.sh "failed"
|
./compile_finish.sh "failed"
|
||||||
else
|
else
|
||||||
. ./compile_finish.sh "success"
|
./compile_finish.sh "success"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
+1
-1
@@ -4,4 +4,4 @@ echo "======================="
|
|||||||
echo " "
|
echo " "
|
||||||
echo "Compiling FPC Sources..."
|
echo "Compiling FPC Sources..."
|
||||||
echo " "
|
echo " "
|
||||||
fpc -Aelf -gw -g -gl -n -vlewn -O3 -Op3 -Si -Sc -Sg -Xd -CX -XXs -CfSSE -CfSSE2 -Rintel -Pi386 -Tlinux -FElib/ -Fusrc/* -Fusrc/driver/* -Fusrc/driver/net/* src/kernel.pas
|
fpc -Aelf -gw -n -O3 -Op3 -Si -Sc -Sg -Xd -CX -XXs -CfSSE -CfSSE2 -Rintel -Pi386 -Tlinux -FElib/ -Fusrc/* -Fusrc/driver/storage/* -Fusrc/driver/storage/AHCI/* -Fusrc/driver/* -Fusrc/driver/net/* -Fusrc/prog/* src/kernel.pas
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#Flat filesystem
|
||||||
|
|
||||||
|
A super simple filesystem for asuro. Folders are emulated in filenames.
|
||||||
|
|
||||||
|
Starts with disk info sector, sector 0 of volume
|
||||||
|
|
||||||
|
---
|
||||||
|
#### disk info
|
||||||
|
|
||||||
|
jmp2boot : ubit24;
|
||||||
|
OEMName : array[0..7] of char;
|
||||||
|
version : uint16 // numerical version of filesystem
|
||||||
|
sectorCount : uint16;
|
||||||
|
fileCount : uint16
|
||||||
|
signature : uint32 = 0x0B00B1E5
|
||||||
|
|
||||||
|
|
||||||
|
the Rest of the sector is reserved
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Starting from sector 1 is the file table. Table size is determined by entry size (64) * fileCount
|
||||||
|
|
||||||
|
---
|
||||||
|
####File entry
|
||||||
|
|
||||||
|
name : array[0..59] of char //file name max 60 chars
|
||||||
|
fileStart : 16bit // start sector of data
|
||||||
|
fileSize : 16bit // data size in sectors
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Hello from the Asuro ISO!
|
||||||
+1
-2
@@ -2,7 +2,7 @@ ENTRY(loader)
|
|||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
. = 0xC0100000;
|
. = 0xC0100000;
|
||||||
kernel_start = .;
|
|
||||||
.text : AT(ADDR(.text) - 0xC0000000)
|
.text : AT(ADDR(.text) - 0xC0000000)
|
||||||
{
|
{
|
||||||
text = .; _text = .; __text = .;
|
text = .; _text = .; __text = .;
|
||||||
@@ -33,5 +33,4 @@ SECTIONS
|
|||||||
. = ALIGN(4096);
|
. = ALIGN(4096);
|
||||||
}
|
}
|
||||||
end = .; _end = .; __end = .;
|
end = .; _end = .; __end = .;
|
||||||
kernel_end = .;
|
|
||||||
}
|
}
|
||||||
+2
-3
@@ -1776,15 +1776,14 @@ var
|
|||||||
fb: puint32;
|
fb: puint32;
|
||||||
|
|
||||||
Begin
|
Begin
|
||||||
Ready:= False;
|
|
||||||
fb:= puint32(uint32(multibootinfo^.framebuffer_addr));
|
fb:= puint32(uint32(multibootinfo^.framebuffer_addr));
|
||||||
Console_Properties.Width:= multibootinfo^.framebuffer_width;
|
Console_Properties.Width:= multibootinfo^.framebuffer_width;
|
||||||
Console_Properties.Height:= multibootinfo^.framebuffer_height;
|
Console_Properties.Height:= multibootinfo^.framebuffer_height;
|
||||||
Console_Properties.BitsPerPixel:= multibootinfo^.framebuffer_bpp;
|
Console_Properties.BitsPerPixel:= multibootinfo^.framebuffer_bpp;
|
||||||
Console_Properties.MAX_CELL_X:= (Console_Properties.Width div 8) - 1;
|
Console_Properties.MAX_CELL_X:= (Console_Properties.Width div 8) - 1;
|
||||||
Console_Properties.MAX_CELL_Y:= (Console_Properties.Height div 16) - 1;
|
Console_Properties.MAX_CELL_Y:= (Console_Properties.Height div 16) - 1;
|
||||||
If Console_Properties.BitsPerPixel <> 16 then begin
|
If Console_Properties.BitsPerPixel <> 16 then while true do begin
|
||||||
exit;
|
|
||||||
end;
|
end;
|
||||||
kpalloc(uint32(fb));
|
kpalloc(uint32(fb));
|
||||||
keyboard.hook(@keyhook);
|
keyboard.hook(@keyhook);
|
||||||
|
|||||||
-23
@@ -291,28 +291,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure enableAVX();
|
|
||||||
begin
|
|
||||||
if CPUID.Capabilities1^.AVX then begin
|
|
||||||
asm
|
|
||||||
PUSH EAX
|
|
||||||
PUSH ECX
|
|
||||||
PUSH EDX
|
|
||||||
XOR ECX, ECX
|
|
||||||
db $0F
|
|
||||||
db $01
|
|
||||||
db $D0
|
|
||||||
OR EAX, 7
|
|
||||||
db $0F
|
|
||||||
db $01
|
|
||||||
db $D1
|
|
||||||
POP EDX
|
|
||||||
POP ECX
|
|
||||||
POP EAX
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure init();
|
procedure init();
|
||||||
begin
|
begin
|
||||||
terminal.registerCommand('CPU', @Terminal_Command_CPU, 'CPU Info.');
|
terminal.registerCommand('CPU', @Terminal_Command_CPU, 'CPU Info.');
|
||||||
@@ -322,7 +300,6 @@ begin
|
|||||||
getCPUCapabilities;
|
getCPUCapabilities;
|
||||||
getCPUClockSpeed;
|
getCPUClockSpeed;
|
||||||
enableSSE;
|
enableSSE;
|
||||||
enableAVX;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
+585
File diff suppressed because it is too large.
Load diff
@@ -91,6 +91,7 @@ function getDeviceInfo(class_code : uint8; subclass_code : uint8; prog_if : uint
|
|||||||
procedure requestConfig(bus : uint8; slot : uint8; func : uint8; row : uint8);
|
procedure requestConfig(bus : uint8; slot : uint8; func : uint8; row : uint8);
|
||||||
procedure writeConfig(bus: uint8; slot : uint8; func : uint8; row : uint8; val : uint32);
|
procedure writeConfig(bus: uint8; slot : uint8; func : uint8; row : uint8; val : uint32);
|
||||||
procedure setBusMaster(bus : uint8; slot : uint8; func : uint8; master : boolean);
|
procedure setBusMaster(bus : uint8; slot : uint8; func : uint8; master : boolean);
|
||||||
|
procedure enableDevice(bus : uint8; slot : uint8; func : uint8);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@@ -442,4 +443,34 @@ begin
|
|||||||
pop_trace;
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
//Enable device inturrupts and set bus master
|
||||||
|
procedure enableDevice(bus : uint8; slot : uint8; func : uint8);
|
||||||
|
var
|
||||||
|
addr : uint32;
|
||||||
|
cmd : uint32;
|
||||||
|
begin
|
||||||
|
push_trace('PCI.enableDevice');
|
||||||
|
|
||||||
|
addr := ($1 shl 31);
|
||||||
|
addr := addr or (bus shl 16);
|
||||||
|
addr := addr or ((slot) shl 11);
|
||||||
|
addr := addr or ((func) shl 8);
|
||||||
|
addr := addr or ($04 and $FC);
|
||||||
|
|
||||||
|
outl(PCI_CONFIG_ADDRESS_PORT, addr);
|
||||||
|
cmd := inl(PCI_CONFIG_DATA_PORT);
|
||||||
|
cmd := cmd or PCI_COMMAND_MEM_SPACE;
|
||||||
|
cmd := cmd or PCI_COMMAND_BUS_MASTER;
|
||||||
|
cmd := cmd or (3 shl 1);
|
||||||
|
|
||||||
|
//enable interrupts, remove disable interrupt bit maybe
|
||||||
|
cmd := cmd and not PCI_COMMAND_INT_DISABLE;
|
||||||
|
// cmd := cmd and not (1 shl 9);
|
||||||
|
|
||||||
|
outl(PCI_CONFIG_ADDRESS_PORT, addr);
|
||||||
|
outl(PCI_CONFIG_DATA_PORT, cmd);
|
||||||
|
|
||||||
|
pop_trace;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
@@ -21,6 +21,29 @@ unit drivertypes;
|
|||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
|
const
|
||||||
|
PCI_CONFIG_ADDRESS_PORT = $0CF8;
|
||||||
|
PCI_CONFIG_DATA_PORT = $0CFC;
|
||||||
|
|
||||||
|
PCI_COMMAND_IO_SPACE = $0001;
|
||||||
|
PCI_COMMAND_MEM_SPACE = $0002;
|
||||||
|
PCI_COMMAND_BUS_MASTER = $0004;
|
||||||
|
PCI_COMMAND_SPECIAL_CYC = $0008;
|
||||||
|
PCI_COMMAND_MEM_WRITE = $0010;
|
||||||
|
PCI_COMMAND_VGA_PALETTE = $0020;
|
||||||
|
PCI_COMMAND_PARITY = $0040;
|
||||||
|
PCI_COMMAND_WAIT = $0080;
|
||||||
|
PCI_COMMAND_SERR = $0100;
|
||||||
|
PCI_COMMAND_FAST_BACK = $0200;
|
||||||
|
PCI_COMMAND_INT_DISABLE = $0400;
|
||||||
|
PCI_COMMAND_SERR_ENABLE = $8000;
|
||||||
|
|
||||||
|
PCI_CAP_ID_MSI = $05;
|
||||||
|
|
||||||
|
// Bits in the MSI Control register (16-bit):
|
||||||
|
MSI_CONTROL_ENABLE = 1 shl 0; // Bit 0
|
||||||
|
MSI_CONTROL_64BIT = 1 shl 7; // Bit 7
|
||||||
|
MSI_CONTROL_PVMASK = 1 shl 8; // Bit 8 (optional: per-vector masking)
|
||||||
type
|
type
|
||||||
|
|
||||||
PPCI_Device = ^TPCI_Device;
|
PPCI_Device = ^TPCI_Device;
|
||||||
@@ -44,6 +67,7 @@ type
|
|||||||
address1 : uint32;
|
address1 : uint32;
|
||||||
address2 : uint32;
|
address2 : uint32;
|
||||||
address3 : uint32;
|
address3 : uint32;
|
||||||
|
|
||||||
address4 : uint32;
|
address4 : uint32;
|
||||||
address5 : uint32;
|
address5 : uint32;
|
||||||
CIS_pointer : uint32;
|
CIS_pointer : uint32;
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,58 @@
|
|||||||
|
# AHCI Driver Notes
|
||||||
|
|
||||||
|
## Pre-scheduling / Process Kill Hazards
|
||||||
|
|
||||||
|
### 1. Dangling DMA Buffer (critical)
|
||||||
|
When a process is killed, its `kalloc`'d buffers get freed. But the AHCI hardware
|
||||||
|
is still DMA'ing into that physical memory. The DMA write lands on whatever now
|
||||||
|
occupies that memory, silently corrupting the kernel heap or another process.
|
||||||
|
|
||||||
|
**Fix:** Before freeing a process's memory, either:
|
||||||
|
- Wait for all its pending AHCI slots to drain (`cmd_issue` bits clear), or
|
||||||
|
- Issue a port reset to abort in-flight commands, *then* free memory.
|
||||||
|
|
||||||
|
### 2. Dangling Completion Callback / Userdata Pointer (critical)
|
||||||
|
In `storage_read`/`storage_write`, the completion callback writes to `@done` —
|
||||||
|
a **stack-local variable**. If the scheduler preempts or kills the process while
|
||||||
|
it's in the `hlt` loop, that stack frame is gone. The ISR fires and writes to a
|
||||||
|
dangling stack address, corrupting whatever now uses that stack page.
|
||||||
|
|
||||||
|
**Fix:** The `done` flag and completion context must be heap-allocated (or in a
|
||||||
|
kernel-owned structure that outlives the process). A per-request struct like:
|
||||||
|
```pascal
|
||||||
|
type TPendingIO = record
|
||||||
|
done : uint32;
|
||||||
|
ownerPID : uint32; { skip delivery if process is dead }
|
||||||
|
end;
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Command Slot Leak
|
||||||
|
If a process is killed with pending I/O, `pending[slot].inUse` stays `true`
|
||||||
|
forever. Eventually all 32 slots fill up and the device becomes unusable.
|
||||||
|
|
||||||
|
**Fix:** When killing a process, scan all AHCI devices for `pending[]` entries
|
||||||
|
belonging to that process, and either:
|
||||||
|
- Let the hardware finish but null out the completion callback (ISR just frees slot), or
|
||||||
|
- Abort the command (port reset) and clear the slot.
|
||||||
|
|
||||||
|
### 4. Interrupt-Disabled Preemption
|
||||||
|
The `asm sti` before the `hlt` loop is fine, but if the timer fires during setup
|
||||||
|
(between `readCallbackAsync(...)` and `asm sti`), the process could be switched
|
||||||
|
out with interrupts in an unexpected state. `hlt` is also not preemption-safe.
|
||||||
|
|
||||||
|
**Fix:** Move to a proper wait-queue/sleep mechanism instead of `hlt`.
|
||||||
|
|
||||||
|
## Recommended Path Forward
|
||||||
|
Implement a small **I/O request queue** owned by the kernel (not the process stack):
|
||||||
|
1. Allocate a request struct
|
||||||
|
2. Put it on a per-device queue
|
||||||
|
3. ISR completes it
|
||||||
|
4. Process kill walks the queue and cancels entries for that PID
|
||||||
|
|
||||||
|
## Other Bugs Fixed (2026-03-03)
|
||||||
|
- **vtop mask bug:** `$FFFFFF` (24-bit) → `$3FFFFF` (22-bit) for 4MB page offset
|
||||||
|
- **find_cmd_slot:** Now checks `pending[].inUse` in addition to `cmd_issue` bit
|
||||||
|
- **Missing lba5:** Both `send_read_dma_async` and `send_write_dma_async` now write all 48 LBA bits
|
||||||
|
- **IOAPIC routing:** PCI interrupts routed through IOAPIC so AHCI interrupts actually reach the CPU
|
||||||
|
- **LAPIC EOI:** `ISR_N` now sends LAPIC EOI for IOAPIC-delivered interrupts
|
||||||
|
- **PxIS pre-clear removed:** No longer blanket-clears port interrupt status before issuing commands (was eating other slots' completions)
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
// Copyright 2021 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.
|
|
||||||
|
|
||||||
{
|
|
||||||
Drivers->Storage->ATA_ISR - Primary ATA IRQ.
|
|
||||||
|
|
||||||
@author(Aaron Hance <[email protected]>)
|
|
||||||
}
|
|
||||||
unit ATA_ISR;
|
|
||||||
|
|
||||||
interface
|
|
||||||
|
|
||||||
uses
|
|
||||||
util,
|
|
||||||
console,
|
|
||||||
isr_types,
|
|
||||||
isrmanager,
|
|
||||||
IDT;
|
|
||||||
|
|
||||||
procedure register();
|
|
||||||
procedure hook(hook_method : uint32);
|
|
||||||
procedure unhook(hook_method : uint32);
|
|
||||||
|
|
||||||
implementation
|
|
||||||
|
|
||||||
var
|
|
||||||
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
|
|
||||||
|
|
||||||
procedure Main(); interrupt;
|
|
||||||
var
|
|
||||||
i : integer;
|
|
||||||
|
|
||||||
begin
|
|
||||||
CLI;
|
|
||||||
for i:=0 to MAX_HOOKS-1 do begin
|
|
||||||
if uint32(Hooks[i]) <> 0 then Hooks[i](void($00000000));
|
|
||||||
end;
|
|
||||||
console.writestringln('Disk Operation Complete');
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure register();
|
|
||||||
begin
|
|
||||||
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
|
|
||||||
//isrmanager.registerISR(76, @Main);
|
|
||||||
//IDT.set_gate(76, uint32(@Main), $08, ISR_RING_0);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure hook(hook_method : uint32);
|
|
||||||
var
|
|
||||||
i : uint32;
|
|
||||||
|
|
||||||
begin
|
|
||||||
for i:=0 to MAX_HOOKS-1 do begin
|
|
||||||
if uint32(Hooks[i]) = hook_method then exit;
|
|
||||||
end;
|
|
||||||
for i:=0 to MAX_HOOKS-1 do begin
|
|
||||||
if uint32(Hooks[i]) = 0 then begin
|
|
||||||
Hooks[i]:= pp_hook_method(hook_method);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure unhook(hook_method : uint32);
|
|
||||||
var
|
|
||||||
i : uint32;
|
|
||||||
begin
|
|
||||||
for i:=0 to MAX_HOOKS-1 do begin
|
|
||||||
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
end.
|
|
||||||
@@ -23,14 +23,16 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
console,
|
console,
|
||||||
storagemanagement,
|
|
||||||
util, terminal,
|
|
||||||
lmemorymanager,
|
|
||||||
strings,
|
|
||||||
lists,
|
lists,
|
||||||
tracer,
|
lmemorymanager,
|
||||||
|
rtc,
|
||||||
serial,
|
serial,
|
||||||
rtc;
|
storagemanagement,
|
||||||
|
storagemanager,
|
||||||
|
strings,
|
||||||
|
terminal,
|
||||||
|
tracer,
|
||||||
|
util;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@@ -99,7 +101,7 @@ begin
|
|||||||
filesystemRecord^.endOfData := filesystemRecord.sectorsPerTable;
|
filesystemRecord^.endOfData := filesystemRecord.sectorsPerTable;
|
||||||
//filesystemRecord.volumeLabel := config^
|
//filesystemRecord.volumeLabel := config^
|
||||||
|
|
||||||
disk^.writecallback(disk, start, 1, buffer);
|
storagemanager.storage_write(disk, start, 1, buffer);
|
||||||
memset(uint32(buffer), 0, disk^.sectorSize);
|
memset(uint32(buffer), 0, disk^.sectorSize);
|
||||||
|
|
||||||
fileEntry := PFileEntry(buffer)[0];
|
fileEntry := PFileEntry(buffer)[0];
|
||||||
@@ -112,7 +114,7 @@ begin
|
|||||||
fileEntry^.attributes := 0;
|
fileEntry^.attributes := 0;
|
||||||
fileEntry^.location := 1;
|
fileEntry^.location := 1;
|
||||||
|
|
||||||
disk^.writecallback(disk, start + 1, 1, buffer);
|
storagemanager.storage_write(disk, start + 1, 1, buffer);
|
||||||
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
Loaded 20 of 66 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user