WonderWitch/FreyaBIOS/System

From WSdev Wiki
Revision as of 11:30, 15 December 2024 by Asie (talk | contribs) (initially document sys_set/get_resume)
Jump to navigationJump to search

The System interrupt provides assorted system-related functionality.

Interrupts

INT $17/AH=$00 - sys_interrupt_set_hook

  • AH = $00
  • AL = Interrupt index
  • DS:BX = Pointer to new vector (read from)
  • DS:DX = Pointer to old vector (written to)

INT $17/AH=$01 - sys_interrupt_reset_hook

  • AH = $01
  • AL = Interrupt index
  • DS:BX = Pointer to old vector (read from)

INT $17/AH=$02 - sys_wait

  • AH = $02
  • CX = Frames to wait

INT $17/AH=$03 - sys_get_tick_count

  • AH = $03

Return:

  • DX:AX = Number of frames since system start

INT $17/AH=$04 - sys_sleep

INT $17/AH=$05 - sys_set_sleep_time

INT $17/AH=$06 - sys_get_sleep_time

INT $17/AH=$07 - sys_set_awake_key

INT $17/AH=$08 - sys_get_awake_key

INT $17/AH=$09 - sys_set_keepalive_int

INT $17/AH=$0A - sys_get_ownerinfo

  • AH = $0A
  • DS:DX = Output buffer
  • CX = Output buffer size, in bytes

Errata:

  • The FreyaBIOS implementation only works correctly in the "mono" mode. An alternate implementation that supports "color" mode is provided as part of libwwc.

INT $17/AH=$0B - sys_suspend

  • AH = $0B
  • AL = Suspend slot (see below)
  • DS:BX = Pointer to I/O resume table (see below)

Return:

  • AX = 0 if suspend successful, 1 if returning from suspend (via sys_resume).

Makes a copy of the execution state (IRAM, I/O ports, stack) to be restored via sys_resume (see below).

Suspend/resume structure

This structure is stored in SRAM block 3, offset $7E00 (slot 1) and $BF00 (slot 0).

Offset Size Contents
$0000 16384 Copy of RAM area $0000 - $3FFF
$4000 4 Far pointer to I/O resume table (DS:BX), plus 1
$4004 224 Copy of IO ports $00 - $DF
$40E4 2 Value of CX?
$40E6 2 Value of SP?
$40E8 2 Value of SS?

In addition, these SRAM block 3 locations are used:

Offset Contents
$FFEE Resumable status for slot 0 (bit 7 = resumable?, bit ?..0 = ID)
$FFEF Resumable status for slot 1 (bit 7 = resumable?, bit ?..0 = ID)

I/O resume table

Offset Size Contents
$00 2 'IO'
$02 224 Resume configuration for each I/O port

INT $17/AH=$0C - sys_resume

  • AH = $0C
  • AL = Suspend slot?

Resumes execution from an existing suspend slot. Returns to where sys_suspend was last called, but with a different return value.

INT $17/AH=$0D - sys_set_remote

INT $17/AH=$0E - sys_get_remote

INT $17/AH=$0F - sys_alloc_iram

INT $17/AH=$10 - sys_free_iram

INT $17/AH=$11 - sys_get_my_iram

INT $17/AH=$12 - sys_get_version

  • AH = $12

Return:

  • AX = BIOS version

INT $17/AH=$13 - sys_swap

INT $17/AH=$14 - sys_set_resume

  • AH = $14
  • BL = Resumable flag for slot ?
  • BH = Resumable flag for slot ?

INT $17/AH=$15 - sys_get_resume

  • AH = $14

Return:

  • AL = Resumable flag for slot ?
  • AH = Resumable flag for slot ?