Recent

Author Topic: [SOLVED] create system unit from scratch  (Read 1430 times)

Key-Real

  • Sr. Member
  • ****
  • Posts: 372
[SOLVED] create system unit from scratch
« on: April 18, 2024, 01:01:39 pm »
I looked at other implementation and the first thing all do is to include systemh.inc, so i do the same:

Code: Pascal  [Select][+][-]
  1. unit system;
  2. {$MODE FPC}
  3. interface
  4.  
  5. {$I systemh.inc}
  6.  
  7. implementation
  8. end.


but this gives me:



Compiling ./rtl/ps1/system.pp
systemh.inc(23,2) Error: Mode switch "OBJFPC" not allowed here
filerec.inc(33,17) Error: Identifier not found "THandle"
filerec.inc(33,24) Error: Error in type definition
textrec.inc(38,17) Error: Identifier not found "THandle"
textrec.inc(38,24) Error: Error in type definition
systemh.inc(867,17) Error: Identifier not found "TThreadID"
systemh.inc(867,26) Error: Error in type definition
mathh.inc(200,53) Fatal: Syntax error, ")" expected but "=" found
Fatal: Compilation aborted
« Last Edit: July 17, 2024, 09:54:03 am by Key-Real »

Key-Real

  • Sr. Member
  • ****
  • Posts: 372
Re: create system unit from scratch
« Reply #1 on: April 18, 2024, 01:14:09 pm »
OK, I can't define {$MODE FPC}

Laksen

  • Hero Member
  • *****
  • Posts: 785
    • J-Software
Re: create system unit from scratch
« Reply #2 on: April 18, 2024, 01:28:35 pm »
Those missing types are defined a platform specific sysosh.inc

For something like the PS1 maybe take a look at how the embedded platform structures the system unit and the sys*.inc contents

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: create system unit from scratch
« Reply #3 on: April 18, 2024, 02:02:25 pm »
To compare it with a hospital, you are currently doing a heart transplantation and you just cut off every connection.
So be a good surgeon and put back the missing parts or the heart stay dead.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Key-Real

  • Sr. Member
  • ****
  • Posts: 372
Re: create system unit from scratch
« Reply #4 on: April 19, 2024, 10:34:10 am »
I gonna implement only the minimal requered code in the system unit

pls explain what  type

1)  jmp_buf
2) TExceptAddr
3) TGuid

do and what is minimal implementation of thouse.

I found https://wiki.lazarus.freepascal.org/System_unit

but there is no detailed explanation

Laksen

  • Hero Member
  • *****
  • Posts: 785
    • J-Software
Re: create system unit from scratch
« Reply #5 on: April 19, 2024, 10:53:57 am »
jmp_buf is a record used to store the state of the CPU for the setjmp and longjmp procedures. This functionality is used for exception handling. They are already implemented for MIPS in rtl/mips/setjump*.inc which is included by systemh.inc

TExceptAddr is as the name hints also used for exception handling and implemented in a generic way shared by all the targets in excepth.inc included by systemh.inc
TGuid stores a GUID. The compiler needs to point to it during compilation when GUIDs are needed. Also implemented in a generic manner in objpash.inc included by systemh.inc


The key to implementing a systems unit is to get the proper defines, paths and system specific dummy functionality (usually residese in sys*/tthread/check.inc files) implemented. There's no documentation but you should see how other system units are structured

 

TinyPortal © 2005-2018