1 ; =============================================================================
2 ; BareMetal -- a 64-bit OS written in Assembly for x86-64 systems
3 ; Copyright (C) 2008-2011 Return Infinity -- see LICENSE.TXT
5 ; Include file for Bare Metal program development (API version 2.0)
6 ; =============================================================================
9 b_print_string
equ 0x0000000000100010 ; Displays text. IN: RSI = message location (zero-terminated string)
10 b_print_char
equ 0x0000000000100020 ; Displays a char. IN: AL = char to display
11 b_print_char_hex
equ 0x0000000000100030 ; Displays a char in hex mode. IN: AL = char to display
12 b_print_newline
equ 0x0000000000100040 ; Print a new line
13 b_input_key_check
equ 0x0000000000100050 ; Scans keyboard for input, but doesn't wait. OUT: AL = ASCII code or 0 if no key pressed
14 b_input_key_wait
equ 0x0000000000100060 ; Waits for keypress and returns key. OUT: AL = key pressed
15 b_input_string
equ 0x0000000000100070 ; Take string from keyboard entry. IN: RDI = location where string will be stored. RCX = max chars to accept
16 b_delay
equ 0x0000000000100080 ; Pause for a set time. IN: RAX = Time in hundredths of a second
17 b_speaker_tone
equ 0x0000000000100090 ; Generate PC speaker tone (call b_speaker_off after). IN: RAX = note frequency
18 b_speaker_off
equ 0x00000000001000A0 ; Shut off the PC speaker
19 b_speaker_beep
equ 0x00000000001000B0 ; Play a standard beep noise
20 b_move_cursor
equ 0x00000000001000C0 ; Move the cursor on screen. IN: AL = column, AH = row
21 b_string_length
equ 0x00000000001000D0 ; Return the length of a string. IN: RSI = string address. OUT: RCX = string length
22 b_find_char_in_string
equ 0x00000000001000E0 ; Find first location of character in a string. IN: RSI = string location, AL = character to find. OUT: RAX = location in string, or 0 if char not present
23 b_string_copy
equ 0x00000000001000F0 ; Copy the contents of one string into another. IN: RSI = source, RDI = destination
24 b_string_truncate
equ 0x0000000000100100 ; Chop string down to specified number of characters. IN: RSI = string location, RAX = number of characters
25 b_string_join
equ 0x0000000000100110 ; Join two strings into a third string. IN: RAX = string one, RBX = string two, RDI = destination string
26 b_string_chomp
equ 0x0000000000100120 ; Strip leading and trailing spaces from a string. IN: RSI = string location
27 b_string_strip
equ 0x0000000000100130 ; Removes specified character from a string. IN: RSI = string location, AL = character to remove
28 b_string_compare
equ 0x0000000000100140 ; See if two strings match. IN: RSI = string one, RDI = string two. OUT: Carry flag set if same
29 b_string_uppercase
equ 0x0000000000100150 ; Convert a string to all uppercase characters. IN: RSI = string address
30 b_string_lowercase
equ 0x0000000000100160 ; Convert a string to all lowercase characters. IN: RSI = string address
31 b_int_to_string
equ 0x0000000000100170 ; Convert an integer to a string. IN: RAX = interger. OUT: RDI = destination string
32 b_string_to_int
equ 0x0000000000100180 ; Convert a string to an interger. IN: RSI = source string. OUT: RAX = interger
33 b_debug_dump_reg
equ 0x0000000000100190 ; Dump the registers to the screen
34 b_debug_dump_mem
equ 0x00000000001001A0 ; Dump contents of memory to the screen. IN: RSI = Start of memory address to dump, RCX = number of bytes to dump
35 b_debug_dump_rax
equ 0x00000000001001B0 ; Dump the content of RAX (64-bit) to the screen
36 b_debug_dump_eax
equ 0x00000000001001C0 ; Dump the content of EAX (32-bit) to the screen
37 b_debug_dump_ax
equ 0x00000000001001D0 ; Dump the content of AX (16-bit) to the screen
38 b_debug_dump_al
equ 0x00000000001001E0 ; Dump the content of AL (8-bit) to the screen
39 b_smp_reset
equ 0x00000000001001F0 ; Resets a CPU/Core. IN: AL = CPU #
40 b_smp_get_id
equ 0x0000000000100200 ; Returns the APIC ID of the CPU that ran this function. OUT: RAX = CPU's APIC ID number
41 b_smp_enqueue
equ 0x0000000000100210 ; Add a workload to the processing queue. IN: RAX = Code to execute, RBX = Variable/Data to work on
42 b_smp_dequeue
equ 0x0000000000100220 ; Dequeue a workload from the processing queue. OUT: RAX = Code to execute, RBX = Variable/Data to work on
43 b_serial_send
equ 0x0000000000100230 ; Send a byte over the primary serial port. IN: AL = Byte to send over serial port
44 b_serial_recv
equ 0x0000000000100240 ; Receive a byte from the primary serial port. OUT: AL = Byte recevied, Carry flag is set if a byte was received (otherwise AL is trashed)
45 b_string_parse
equ 0x0000000000100250 ; Parse a string into individual words. IN: RSI = Address of string. OUT: RCX = word count
46 b_get_argc
equ 0x0000000000100260 ; Return the number arguments passed to the program. OUT: AL = Number of arguments
47 b_get_argv
equ 0x0000000000100270 ; Get the value of an argument that was passed to the program. IN: AL = Argument number. OUT: RSI = Start of numbered argument string
48 b_smp_queuelen
equ 0x0000000000100280 ; Returns the number of items in the processing queue. OUT: RAX = number of items in processing queue
49 b_smp_wait
equ 0x0000000000100290 ; Wait until all other CPU Cores are finished processing
50 b_get_timecounter
equ 0x00000000001002A0 ; Get the current RTC clock couter value. OUT: RAX = Time in eights of a second since clock started
51 b_string_append
equ 0x00000000001002B0 ; Append a string to an existing string. IN: RSI = String to be appended, RDI = Destination string
52 b_int_to_hex_string
equ 0x00000000001002C0 ; Convert an integer to a hex string. IN: RAX = Integer value. RDI = location to store string
53 b_hex_string_to_int
equ 0x00000000001002D0 ; Convert up to 8 hexascii to bin. IN: RSI = Location of hex asciiz string. OUT: RAX = binary value of hex string
54 b_string_change_char
equ 0x00000000001002E0 ; Change all instances of a character in a string. IN: RSI = string location, AL = character to replace, BL = replacement character
55 b_is_digit
equ 0x00000000001002F0 ; Check if character is a digit. IN: AL = ASCII char. OUT: EQ flag set if numeric
56 b_is_alpha
equ 0x0000000000100300 ; Check if character is a letter. IN: AL = ASCII char. OUT: EQ flag set if alpha
57 b_file_read
equ 0x0000000000100310 ; Read a file from disk into memory. IN: RSI = Address of filename string, RDI = Memory location where file will be loaded to. OUT: Carry is set if the file was not found or an error occured
58 b_file_write
equ 0x0000000000100320 ; Write memory to a file on disk. IN: RSI = Memory location of data to be written, RDI = Address of filename string, RCX = Number of bytes to write. OUT: Carry is set if an error occured
59 b_file_delete
equ 0x0000000000100330 ; Delete a file from disk. IN: RSI = Memory location of file name to delete. OUT: Carry is set if the file was not found or an error occured
60 b_file_get_list
equ 0x0000000000100340 ; Generate a list of files on disk. IN: RDI = Location to store list. OUT: RDI = pointer to end of list
61 b_smp_run
equ 0x0000000000100350 ; Call the function address in RAX. IN: RAX = Memory location of code to run
62 b_smp_lock
equ 0x0000000000100360 ; Lock a variable. IN: RAX = Memory address of variable
63 b_smp_unlock
equ 0x0000000000100370 ; Unlock a variable. IN: RAX = Memory address of variable
64 b_print_string_with_color
equ 0x0000000000100380 ; Displays text in colour. IN: RSI = message location (zero-terminated string), BL = colour
65 b_print_char_with_color
equ 0x0000000000100390 ; Displays a char in colour. IN: AL = char to display, BL = colour
66 b_ethernet_tx
equ 0x00000000001003A0 ; Transmit a packet via Ethernet. IN: RSI = Memory location where data is stored, RDI = Pointer to 48 bit destination address, BX = Type of packet (If set to 0 then the EtherType will be set to the length of data), CX = Length of data
67 b_ethernet_rx
equ 0x00000000001003B0 ; Polls the Ethernet card for received data. IN: RDI = Memory location where packet will be stored. OUT: RCX = Length of packet
68 b_mem_allocate
equ 0x00000000001003C0 ; Allocates the requested number of 2 MiB pages. IN: RCX = Number of pages to allocate. OUT: RAX = Starting address, RCX = Number of pages allocated (Set to the value asked for or 0 on failure)
69 b_mem_release
equ 0x00000000001003D0 ; Frees the requested number of 2 MiB pages. IN: RAX = Starting address, RCX = Number of pages to free. OUT: RCX = Number of pages freed
70 b_mem_get_free
equ 0x00000000001003E0 ; Returns the number of 2 MiB pages that are available. OUT: RCX = Number of free 2 MiB pages
71 b_smp_numcores
equ 0x00000000001003F0 ; Returns the number of cores in this computer. OUT: RAX = number of cores in this computer
72 b_file_get_size
equ 0x0000000000100400 ; Return the size of a file on disk. IN: RSI = Address of filename string. OUT: RCX = Size in bytes, Carry is set if the file was not found or an error occured
73 b_ethernet_avail
equ 0x0000000000100410 ; Check if Ethernet is available. IN: Nothing. OUT: RAX = Set to 1 if Ethernet is enabled on host
74 b_print_char_hex_with_color
equ 0x0000000000100420 ; Displays a char in hex mode with color. IN: AL = char to display, BL = colour
75 b_screen_clear
equ 0x0000000000100440 ; Clear the screen
76 b_show_cursor
equ 0x0000000000100450 ; Turns on cursor in text mode
77 b_hide_cursor
equ 0x0000000000100460 ; Turns off cursor in text mode
78 b_show_statusbar
equ 0x0000000000100470 ; Show the system status bar
79 b_hide_statusbar
equ 0x0000000000100480 ; Hide the system status bar
80 b_screen_update
equ 0x0000000000100490 ; Manually refresh the screen from the frame buffer
81 b_print_chars
equ 0x00000000001004A0 ; Displays text. IN: RSI = message location (A string, not zero-terminated), RCX = number of chars to print
82 b_print_chars_with_color
equ 0x00000000001004B0 ; Displays text with color. IN: RSI = message location (A string, not zero-terminated), BL = color, RCX = number of chars to print
85 ; =============================================================================