feature: Upgrade FPC from 2.6.4 to 3.2.2
continuous-integration/drone Build was killed

Migrate the build toolchain from Free Pascal Compiler 2.6.4 to 3.2.2.
FPC 3.2.2 requires a significantly expanded custom system unit and
several syntactic adjustments across the codebase.

Dockerfile:
- Bump FPC_VERSION from 2.6.4 to 3.2.2

compile_sources.sh:
- Replace obsolete -Op3 flag with -OpPENTIUM3

linker.script:
- Add /DISCARD/ section for .init_array, .fini_array, .ctors, .dtors,
  .eh_frame, .gcc_except_table, and .note.GNU-stack sections emitted
  by FPC 3.2.2

system.pas:
- Fix hresult to 'type longint' (was cardinal, incompatible with 3.2.2)
- Add required types: SizeInt, SizeUInt, PtrInt, PtrUInt, NativeInt,
  NativeUInt, CodePointer, TTypeKind, jmp_buf, TExceptAddr, TGuid,
  FileRec, TextRec
- Add required globals: ExceptAddrStack, ExitCode, ErrorAddr, ErrorCode,
  ExitProc, StackBottom, StackLength, RandSeed
- Implement compilerprocs: fpc_initializeunits, fpc_do_exit,
  fpc_handleerror, fpc_rangeerror, fpc_overflow, fpc_divbyzero,
  fpc_objecterror, fpc_abstracterror, fpc_stackcheck, fpc_iocheck,
  fpc_pushexceptaddr, fpc_popaddrstack, fpc_setjmp (asm),
  fpc_longjmp (asm), fpc_shortstr_assign, fpc_mul_int64 (asm),
  fpc_getmem, fpc_freemem, fpc_reraise, fpc_raiseexception,
  fpc_catches, fpc_doneexception
- Add move() procedure with FPC_MOVE alias

util.pas, serial.pas:
- Fix inline asm functions (getESP, inl, inw, inb, sinb) to use temp
  variables instead of function-name result — FPC 3.2.2 no longer
  allows 'MOV funcname, reg' syntax in inline asm blocks

lmemorymanager.pas:
- Export kalloc/kfree with public aliases (kernel_kalloc, kernel_kfree)
  so system.pas fpc_getmem/fpc_freemem can link to them
This commit is contained in:
2026-02-26 00:01:40 +00:00
parent 1145b900e4
commit 2b071a58c7
7 changed files with 382 additions and 10 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ RUN apt-get update && apt-get install -y \
apt-get clean my room
SHELL ["/bin/bash", "-c"]
ARG FPC_VERSION=2.6.4
ARG FPC_VERSION=3.2.2
RUN curl -sL https://sourceforge.net/projects/freepascal/files/Linux/$FPC_VERSION/fpc-$FPC_VERSION.i386-linux.tar/download | tar -xf - && \
pushd fpc-$FPC_VERSION.i386-linux && ./install.sh && popd && \
rm -rf fpc-$FPC_VERSION.i386-linux
+1 -1
View File
@@ -4,4 +4,4 @@ echo "======================="
echo " "
echo "Compiling FPC Sources..."
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 -g -gl -n -vlewn -O3 -OpPENTIUM3 -Si -Sc -Sg -Xd -CX -XXs -CfSSE -CfSSE2 -Rintel -Pi386 -Tlinux -FElib/ -Fusrc/* -Fusrc/driver/* -Fusrc/driver/net/* src/kernel.pas
+10
View File
@@ -34,4 +34,14 @@ SECTIONS
}
end = .; _end = .; __end = .;
kernel_end = .;
/DISCARD/ : {
*(.init_array*)
*(.fini_array*)
*(.ctors)
*(.dtors)
*(.eh_frame*)
*(.gcc_except_table*)
*(.note.GNU-stack)
}
}
+4 -1
View File
@@ -58,16 +58,19 @@ begin
end;
function sinb(port : uint16) : uint8;
var
tmp : uint8;
begin
asm
PUSH EAX
PUSH EDX
MOV DX, port
IN AL, DX
MOV sinb, AL
MOV tmp, AL
POP EDX
POP EAX
end;
sinb := tmp;
io_wait;
end;
+348 -1
View File
File diff suppressed because it is too large Load Diff
+16 -4
View File
@@ -130,10 +130,13 @@ begin
end;
function getESP : uint32;
var
tmp: uint32;
begin
asm
MOV getESP, ESP
MOV tmp, ESP
end;
getESP := tmp;
end;
function HexCharToDecimal(hex : char) : uint8;
@@ -362,6 +365,8 @@ begin
end;
function inl(port : uint16) : uint32; [public, alias: 'util_inl'];
var
tmp : uint32;
begin
//serial.sendString('[inl]');
//serial.sendHex(port);
@@ -370,14 +375,17 @@ begin
PUSH EDX
MOV DX, port
IN EAX, DX
MOV inl, EAX
MOV tmp, EAX
POP EDX
POP EAX
end;
inl := tmp;
io_wait;
end;
function inw(port : uint16) : uint16; [public, alias: 'util_inw'];
var
tmp : uint16;
begin
//serial.sendString('[inw]');
//serial.sendHex(port);
@@ -386,14 +394,17 @@ begin
PUSH EDX
MOV DX, port
IN AX, DX
MOV inw, AX
MOV tmp, AX
POP EDX
POP EAX
end;
inw := tmp;
io_wait;
end;
function inb(port : uint16) : uint8; [public, alias: 'util_inb'];
var
tmp : uint8;
begin
//serial.sendString('[inb]');
//serial.sendHex(port);
@@ -402,10 +413,11 @@ begin
PUSH EDX
MOV DX, port
IN AL, DX
MOV inb, AL
MOV tmp, AL
POP EDX
POP EAX
end;
inb := tmp;
io_wait;
end;
+2 -2
View File
@@ -170,7 +170,7 @@ begin
klalloc:= Address;
end;
function kalloc(size : uint32) : void;
function kalloc(size : uint32) : void; [public, alias: 'kernel_kalloc'];
var
Heap_Entries : uint32;
i, j : uint32;
@@ -217,7 +217,7 @@ begin
//pop_trace;
end;
procedure kfree(area : void);
procedure kfree(area : void); [public, alias: 'kernel_kfree'];
var
hp : PHeapPage;
entry : uint32;