Difference between revisions of "Foenix Kernel Documentation"
m (→Foenix Kernel Documentation) |
(→Kernel Calls) |
||
Line 75: | Line 75: | ||
|} | |} | ||
|- | |- | ||
− | | PRINTAH || $00:1080 || Prints hex value in A. Printed value is 2 wide if M flag is 1, 4 wide if M | + | | PRINTAH || $00:1080 || Prints hex value in A. Printed value is 2 wide if M flag is 1, 4 wide if M |
|- | |- | ||
| LOCATE || $00:1084 || Move the cursor to a new position on the screen. | | LOCATE || $00:1084 || Move the cursor to a new position on the screen. | ||
Line 120: | Line 120: | ||
|- | |- | ||
| INITVKYGRPMODE || $00:10D8 || Init the Basic Registers for the Graphic Mode | | INITVKYGRPMODE || $00:10D8 || Init the Basic Registers for the Graphic Mode | ||
+ | |- | ||
+ | | F_OPEN || $00:10F0 || Open a file for reading/writing. DOS_FD_PTR points to a file descriptor for the file. | ||
+ | |- | ||
+ | | F_CREATE || $00:10F4 || Create a new file and write its first cluster. DOS_FD_PTR points to a file descriptor for the file. | ||
+ | |- | ||
+ | | F_CLOSE || $00:10F8 || Close a file (make sure last cluster is written). DOS_FD_PTR points to a file descriptor for the file. | ||
+ | |- | ||
+ | | F_WRITE || $00:10FC || Write the current cluster to the file. DOS_FD_PTR points to a file descriptor for the file. | ||
+ | |- | ||
+ | | F_READ || $00:1100 || Read the next cluster from the file. DOS_FD_PTR points to a file descriptor for the file. | ||
+ | |- | ||
+ | | F_DELETE || $00:1104 || Delete a file / directory. DOS_PATH_BUFF = a buffer containing the full path to the file (NULL terminated). | ||
+ | |- | ||
+ | | F_DIROPEN || $00:1108 || Open a directory and seek the first directory entry. NOTE: currently only works with the root directory. | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Variable !! Direction !! Contents | ||
+ | |- | ||
+ | | DOS_FD_PTR || IN || Points to a file descriptor for the path to lookup. NOTE: currently unused. | ||
+ | |- | ||
+ | | DOS_DIR_PTR || OUT || Pointer to the first FAT directory entry in that directory. | ||
+ | |} | ||
+ | |- | ||
+ | | F_DIRNEXT || $00:110C || seek to the next directory of an open directory | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Variable !! Direction !! Contents | ||
+ | |- | ||
+ | | DOS_DIR_PTR || IN || Pointer to the current FAT directory entry. | ||
+ | |- | ||
+ | | DOS_DIR_PTR || OUT || Pointer to the next FAT directory entry. | ||
+ | |} | ||
+ | |- | ||
+ | | F_DIRREAD || $00:1110 || Read the directory entry for the specified file | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Variable !! Direction !! Contents | ||
+ | |- | ||
+ | | DOS_PATH_BUFF || IN || The buffer containing the path to the file to lookup. | ||
+ | |- | ||
+ | | DOS_DIR_PTR || OUT || Pointer to the FAT directory entry for that file. | ||
+ | |} | ||
+ | |- | ||
+ | | F_DIRWRITE || $00:1114 || Write any changes in the current directory cluster back to the drive | ||
+ | |- | ||
+ | | F_LOAD || $00:1118 || load a binary file into memory, supports multiple file formats | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Variable !! Contents | ||
+ | |- | ||
+ | | DOS_FD_PTR || Points to a file descriptor for the file to lookup. | ||
+ | |- | ||
+ | | DOS_DST_PTR || Pointer to the location to load the file (any value > $3F:FFFF to load the file where the file specifies). | ||
+ | |} | ||
+ | |- | ||
+ | | F_SAVE || $00:111C || Save memory to a binary file | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Variable !! Contents | ||
+ | |- | ||
+ | | DOS_FD_PTR || Points to a file descriptor for the file to create. | ||
+ | |- | ||
+ | | DOS_SRC_PTR || Address of the first byte to save. | ||
+ | |- | ||
+ | | DOS_END_PTR || Address of the last byte to save. | ||
+ | |} | ||
|} | |} | ||
Revision as of 15:09, 11 April 2020
Contents
Foenix Kernel Documentation
Kernel Essentials
Source Code: https://github.com/Trinity-11/Kernel_FMX
On the FMX, the Foenix Kernel resides in bank $39 of the system RAM. It provides for the initialization of the hardware and a certain minimalist level of access to the hardware. Kernel routines are called through a kernel jump table that starts at $00:1000. All kernel routines must be called using the JSL instruction (long, or 24-bit subroutine call), since they all terminate with an RTL. This allows the kernel routines to be called from anywhere in system memory.
Kernel Calls
Name | Address | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
BOOT | $00:1000 | Cold boot routine | ||||||||||||
PUTC | $00:1018 | Print a character to the currently selected channel
| ||||||||||||
PUTS | $00:101C | Print a null-terminated ASCII string to the currently selected channel
| ||||||||||||
SETIN | $00:1038 | Set the current input channel used by the GET subroutines
| ||||||||||||
SETOUT | $00:103C | Set the current output channel used by the PUT subroutines
| ||||||||||||
GETCHW | $00:104C | Get a character from the input channel. Waits until data received. A=0 and Carry=1 if no data is waiting | ||||||||||||
GETCHE | $00:1050 | Get a character from the input channel and echo to the screen. Wait if data is not ready. | ||||||||||||
PRINTCR | $00:106C | Print Carriage Return | ||||||||||||
PRINTH | $00:1078 | Print hex value in memory.
| ||||||||||||
PRINTAH | $00:1080 | Prints hex value in A. Printed value is 2 wide if M flag is 1, 4 wide if M | ||||||||||||
LOCATE | $00:1084 | Move the cursor to a new position on the screen.
| ||||||||||||
CSRRIGHT | $00:1090 | Move the cursor one position to the right | ||||||||||||
CSRLEFT | $00:1094 | Move the cursor one position to the left | ||||||||||||
CSRUP | $00:1098 | Move the cursor up one row | ||||||||||||
CSRDOWN | $00:109C | Move the cursor down one row | ||||||||||||
CSRHOME | $00:10A0 | Move the cursor to the upper-left corner | ||||||||||||
SCROLLUP | $00:10A4 | Scroll the screen up one line. Creates an empty line at the bottom. | ||||||||||||
CLRSCREEN | $00:10B0 | Clear the screen | ||||||||||||
INITCHLUT | $00:10B4 | Init character look-up table | ||||||||||||
INITSUPERIO | $00:10B8 | Init Super-IO chip | ||||||||||||
INITKEYBOARD | $00:10BC | Init keyboard | ||||||||||||
INITRTC | $00:10C0 | Init Real-Time Clock | ||||||||||||
INITCURSOR | $00:10C4 | Init the Cursors registers | ||||||||||||
INITFONTSET | $00:10C8 | Init the Internal FONT Memory | ||||||||||||
INITGAMMATABLE | $00:10CC | Init the RGB GAMMA Look Up Table | ||||||||||||
INITALLLUT | $00:10D0 | Init the Graphic Engine (Bitmap/Tile/Sprites) LUT | ||||||||||||
INITVKYTXTMODE | $00:10D4 | Init the Text Mode @ Reset Time | ||||||||||||
INITVKYGRPMODE | $00:10D8 | Init the Basic Registers for the Graphic Mode | ||||||||||||
F_OPEN | $00:10F0 | Open a file for reading/writing. DOS_FD_PTR points to a file descriptor for the file. | ||||||||||||
F_CREATE | $00:10F4 | Create a new file and write its first cluster. DOS_FD_PTR points to a file descriptor for the file. | ||||||||||||
F_CLOSE | $00:10F8 | Close a file (make sure last cluster is written). DOS_FD_PTR points to a file descriptor for the file. | ||||||||||||
F_WRITE | $00:10FC | Write the current cluster to the file. DOS_FD_PTR points to a file descriptor for the file. | ||||||||||||
F_READ | $00:1100 | Read the next cluster from the file. DOS_FD_PTR points to a file descriptor for the file. | ||||||||||||
F_DELETE | $00:1104 | Delete a file / directory. DOS_PATH_BUFF = a buffer containing the full path to the file (NULL terminated). | ||||||||||||
F_DIROPEN | $00:1108 | Open a directory and seek the first directory entry. NOTE: currently only works with the root directory.
| ||||||||||||
F_DIRNEXT | $00:110C | seek to the next directory of an open directory
| ||||||||||||
F_DIRREAD | $00:1110 | Read the directory entry for the specified file
| ||||||||||||
F_DIRWRITE | $00:1114 | Write any changes in the current directory cluster back to the drive | ||||||||||||
F_LOAD | $00:1118 | load a binary file into memory, supports multiple file formats
| ||||||||||||
F_SAVE | $00:111C | Save memory to a binary file
|
Console Special Characters
The console routines support several special control codes for both input and output. When the key on the keyboard is pressed, the associated code is returned by the GET routines. If the code is printed through the PUTC or PUTS, the associated operation will be performed on the screen. Note that this means that any graphics characters associated with those code points will not be displayed by PUTC or PUTS. If those characters must be displayed, they would have to be written to the text memory directly.
Code | Name | Keyboard | Description |
---|---|---|---|
$08 | BS | Backspace | Deletes the character to the left of the cursor, pulling characters in from the right. |
$09 | TAB | TAB | Moves the cursor right to the next tabulated column (every eight columns). |
$0A | LF | N/A | Puts the cursor at column 0 on the next line on the same column. |
$0D | CR | RETURN | Creates a newline on the screen. Puts the cursor at column 0 on the next line. |
$0F | INS | Insert | Inserts a blank space under the cursor (pushing characters to the right). |
$11 | UP | Up Arrow | Moves the cursor up one row. |
$1D | RIGHT | Right Arrow | Moves the cursor right one column. May wrap to the next line. |
$7F | DEL | Delete | Deletes the character under the cursor, pulling characters in from the right. |
$91 | DOWN | Down Arrow | Moves the cursor down one row. May scroll the screen. |
$9D | LEFT | Left Arrow | Moves the cursor left one column. |
Special Kernel Variables
The kernel keeps track of several variables. Most kernel variables should be left alone by applications, but there are some which an application might want to set or read.
Start Address | End Address | Name | R/W | Description |
---|---|---|---|---|
$00:000C | $00:000E | SCREENBEGIN | RO | Address of the first character of the text display |
$00:000C | $00:000E | SCREENBEGIN | RO | Address of the first character of the text display |
$00:000F | $00:0010 | COLS_VISIBLE | RW | The number of columns currently displayed |
$00:0013 | $00:0014 | LINES_VISIBLE | RW | The number of rows currently displayed |
$00:0017 | $00:0018 | CURSORPOS | RO | The address of the text character under the cursor |
$00:001A | $00:001B | CURSORX | RO | The address of the text character under the cursor |
$00:001C | $00:001D | CURSORY | RO | The address of the text character under the cursor |
$00:001E | CURCOLOR | RW | The foreground and background colors to be used when printing via PUTC and PUTS | |
$00:001F | $00:0020 | COLORPOS | RO | The address of the text color cell under the cursor |