I/O System (IOsys)
Brainstem - Input/Output Management
Overview
The I/O System (IOsys) provides standardized I/O operations for Chapp-E, abstracting BIOS calls and providing a clean API for console I/O, keyboard input, and screen output. It's mapped to the Brainstem in Chapp-E's brain architecture.
File Descriptors
| FD | Constant | Description |
|---|---|---|
0 |
IO_STDIN |
Standard input (keyboard) |
1 |
IO_STDOUT |
Standard output (screen) |
2 |
IO_STDERR |
Standard error (screen, error output) |
API Reference
Console Output
iosys_print_char
Print a single character to the screen.
; Print character
mov al, 'A'
call iosys_print_char
iosys_print_string
Print a null-terminated string to the screen.
; Print string
mov si, message_string
call iosys_print_string
iosys_print_newline
Print a newline character (carriage return + line feed).
; Print newline
call iosys_print_newline
Console Input
iosys_read_char
Read a single character from keyboard (waits for input).
; Read character
call iosys_read_char
; Output: AL = character read
iosys_read_key_status
Check if a key is available (non-blocking).
; Check key status
call iosys_read_key_status
; Output: CF = 1 if key available, CF = 0 if no key
iosys_read_string
Read a string from keyboard (until Enter is pressed).
; Read string
mov di, buffer_address
mov cx, buffer_size
call iosys_read_string
Port I/O
iosys_port_out
Write a byte to an I/O port.
; Write to port
mov dx, port_number
mov al, value
call iosys_port_out
iosys_port_in
Read a byte from an I/O port.
; Read from port
mov dx, port_number
call iosys_port_in
; Output: AL = value read
Buffer Management
iosys_clear_buffer
Clear the input buffer.
; Clear buffer
call iosys_clear_buffer
BIOS Integration
BIOS Interrupts
The I/O System uses BIOS interrupts for hardware access:
| Interrupt | Function | Purpose |
|---|---|---|
0x10 |
BIOS_VIDEO |
Video/display operations |
0x16 |
BIOS_KEYBOARD |
Keyboard input operations |
BIOS Functions
- 0x0E (BIOS_TELETYPE): Print character with teletype output
- 0x00 (BIOS_READ_KEY): Read key from keyboard (blocking)
- 0x01 (BIOS_KEY_STATUS): Check keyboard status (non-blocking)
Brain Architecture
Brainstem Mapping
In the human brain, the Brainstem:
- Handles basic survival functions - Like I/O System handling basic I/O
- Controls sensory/motor pathways - Like I/O System managing input/output
- Acts as interface to body - Like I/O System interfacing with hardware
System ID
The I/O System is registered with Brain Controller as:
- System ID:
SYS_ID_IO(0x01) - Brain Region: Brainstem
Integration
Shell Integration
The shell uses I/O System for:
- Displaying the prompt
- Reading user input
- Printing command output
- Error message display
Brain Controller Integration
The I/O System communicates through the Brain Controller:
- Receives output requests from subsystems
- Sends input events to GCS/FSM
- Coordinates with other systems
File Locations
- 16-bit Implementation:
system/iosys/iosys.asm - Brain Region: Brainstem
Related Documentation
- Brain Architecture - System organization
- Shell System - Uses I/O System for input/output
- GCS System - Receives input from I/O System
- Brain Controller - Routes I/O messages