LF OS
Hobby operating system for amd64 with high ambitions
Loading...
Searching...
No Matches
syscalls.h File Reference
#include <stdbool.h>
#include <sys/types.h>
#include <stdint.h>
#include <sys/message_passing.h>
+ Include dependency graph for syscalls.h:

Go to the source code of this file.

Functions

static __attribute__ ((artificial)) void sc_do_scheduler_exit(uint8_t exit_code)
 
 asm ("syscall":"=a"(rax):"D"(rdi), "a"(rax), "d"(rdx):"rbx", "rcx", "r11", "memory")
 

Variables

static void * entry
 
static void pid_tpid
 
uint64_t rax = (uint64_t)(share_memory & 1)
 
uint64_t rdx = ((0 & 0xFF) << 24) | (1 & 0xFFFFFF)
 
static void ** data_end
 
static uint16_twidth = (rdi & 65535)
 
static uint16_t uint16_theight = ((rdi >> 16) & 65535)
 
static uint16_t uint16_t uint16_tstride = ((rdi >> 32) & 65535)
 
static uint16_t uint16_t uint16_t uint16_tcolorFormat
 
uint64_t rdi = (uint64_t)(queue)
 
framebuffer = (uint32_t*)(rax)
 
static uint16_t num
 
static uint16_t bool turn_on
 
static uint16_t bool uint64_terror
 
static bool notify
 
static bool uint64_t queue
 
mutex = (rax)
 
static bool trylock
 
condvar = (rax)
 
static uint64_t amount
 
static uint64_t timeout
 
static bool global_write
 
static bool size_t message_limit
 
static bool size_t size_t data_limit
 
static bool size_t size_t uint64_tmq = (rax)
 
static bool wait
 
static bool struct Messagemessage
 
static uint64_t process
 
uint64_t rsi = (uint64_t)(message)
 

Function Documentation

◆ __attribute__()

static __attribute__ ( (artificial)  )
inlinestatic

Syscall exit (group 0, call 0)

Exit the process, free all memory and deliver exit code to parent process. This syscall will never return.

Parameters
[in]exit_codeCode returned from the calling process to the parent process

Syscall clone (group 0, call 1)

Clone the process into a new process while optionally sharing all memory (which is commonly called a thread then).

Parameters
[in]share_memoryShare memory with original process
[in]entryEntrypoint of the child. Special case: NULL, will continue at the same code location (only valid if share_memory == 1)
[out]pidPID of the new process in the old process, 0 in the new process, -1 denotes an error

Syscall sleep (group 0, call 2)

Sleep for the given time or yield CPU time to another process, if given time is 0

Parameters
[in]nanosecondsNanoseconds until first normally scheduling the process again

Syscall get_pid (group 0, call 3)

Return own or parent PID

Parameters
[in]parentIf true, returns parent PID. Own PID otherwise
[out]pidOwn or parent PID

Syscall sbrk (group 1, call 0)

Increment the data segment by inc bytes and return the new end of the data segment.

Parameters
[in]incMinimum number of bytes to add the data segment
[out]data_endPointer to the last byte in the data segment

Syscall framebuffer (group 2, call 0)

Take control of the framebuffer (if still in control by kernel)

Parameters
[out]framebufferPointer to the framebuffer
[out]widthWidth of the framebuffer
[out]heightHeight of the framebuffer
[out]strideStride (number of bytes per pixel row) of the framebuffer
[out]colorFormatTBD

Syscall ioperm (group 2, call 1)

Request access to I/O ports, this is i386 and amd64 only

Parameters
[in]fromFirst port for which access is requested
[in]numNumber of ports for which access is requested
[in]turn_onRequest (true) or drop (false) access to port
[out]errorError code, zero on success

Syscall interrupt_notify (group 2, call 2)

Request to be notified of hardware interrupts or cancel notifications

Parameters
[in]interruptNumber of the interrupt to be notified for
[in]notifyAdd notification (true) or cancel (false)
[in]queueMessage queue to send notifications to
[out]errorError code, 0 if success

Syscall create_mutex (group 3, call 0)

This syscall creates a new mutex

Parameters
[out]mutexpthread_mutex_t value for the new mutex
[out]errorerror code, zero if success

Syscall destroy_mutex (group 3, call 1)

destroys the given mutex, returns an error if locked

Parameters
[in]mutexmutex to destroy as pthread_mutex_t
[out]errorerror code, zero if success

Syscall lock_mutex (group 3, call 2)

Waits for the mutex to be free and locks it or tries to lock it without blocking

Parameters
[in]mutexmutex to lock as pthread_mutex_t
[in]trylockTry to lock instead of block
[out]errorerror of this operation, zero if success

Syscall unlock_mutex (group 3, call 3)

Unlocks a mutex

Parameters
[in]mutexmutex to lock as pthread_mutex_t
[out]errorerror of this operation, zero if success

Syscall create_condvar (group 3, call 4)

Create a new condvar processes can wait on

Parameters
[out]condvarpthread_cond_t value for the new condvar
[out]errorerror code, zero if success

Syscall destroy_condvar (group 3, call 5)

Destroys a given condvar. Errors if processes are waiting on it

Parameters
[in]condvarpthread_cond_t value to destroy
[out]errorerror code, zero if success

Syscall signal_condvar (group 3, call 6)

Signals a condvar to unlock up to amount processes

Parameters
[in]condvarcondvar to signal
[in]amountmaximum amount of processes to unlock
[out]errorerror code, zero if success

Syscall wait_condvar (group 3, call 7)

Makes the calling process blocking wait on the condvar

Parameters
[in]condvarcondvar to wait on
[in]timeoutWait timeout, not yet implemented
[out]errorerror code, zero if success

Syscall mq_create (group 4, call 0)

create a new message queue

Parameters
[in]global_readAllow other processes to read from this queue
[in]global_writeAllow other processes to write to this queue
[in]message_limitMax count of messages to store in the queue
[in]data_limitMax amount of data to store in the queue
[out]mqUnique identifier for the new queue
[out]errorerror code, zero if success

Syscall mq_destroy (group 4, call 1)

Destroy a given message queue

Parameters
[in]mqID of the message queue to destroy
[out]errorerror code, zero if success

Syscall mq_poll (group 4, call 2)

Retrieve message from given queue

Parameters
[in]queueMessage queue ID, 0 is process queue
[in]waitWait for a message to be available
[in]messagePointer where to store the message, has to be allocated with enough storage
[out]errorError code, 0 on success

Syscall mq_send (group 4, call 3)

Send message to given queue

Parameters
[in]queueMessage queue ID, 0 is process queue
[in]processRecipient process, to send messages to other processes process queue
[in]messagePointer to message from queue
[out]errorError code, 0 if success

Syscall service_register (group 4, call 4)

Register as implementation of the given service

Parameters
[in]uuidUUID of the service to register for
[in]queueMessage queue ID, 0 is process queue
[out]errorError code, 0 if success

Syscall service_discover (group 4, call 5)

Send message to implementations of given service

Parameters
[in]uuidUUID of the service to discover
[in]queueMessage queue ID, 0 is process queue
[in]messageMessage to send, UUID will be filled in automatically, has to be of type ServiceDiscover
[out]errorError code, 0 if success

Syscall read (group 5, call 0)

Read nanoseconds since system start

Parameters
[out]nanosecondsNanoseconds since system start (or rather, since timer initialization)

Syscall print (group 255, call 0)

Print a message to the screen at a location defined by the kernel

Parameters
[in]strMessage to print

Definition at line 18 of file syscalls.h.

References rax, and rdx.

◆ asm()

asm ( )

Variable Documentation

◆ amount

uint64_t amount

Definition at line 263 of file syscalls.h.

◆ colorFormat

* colorFormat
Initial value:
{
uint64_t rdx = ((2 & 0xFF) << 24) | (0 & 0xFFFFFF)
unsigned long uint64_t
Definition arch.h:14
uint64_t rdx
Definition syscalls.h:37

Definition at line 104 of file syscalls.h.

◆ condvar

* condvar = (rax)

Definition at line 237 of file syscalls.h.

◆ data_end

* data_end
Initial value:
{
uint64_t rax
Definition syscalls.h:36

Definition at line 82 of file syscalls.h.

◆ data_limit

bool size_t size_t data_limit

Definition at line 303 of file syscalls.h.

◆ entry

void* entry

Definition at line 34 of file syscalls.h.

◆ error

* error
Initial value:
{
uint64_t rax = (uint64_t)(from & 65535) | ((uint64_t)(num & 65535) << 16) | ((uint64_t)(turn_on & 1) << 32)
static uint16_t num
Definition syscalls.h:126
static uint16_t bool turn_on
Definition syscalls.h:126

Definition at line 126 of file syscalls.h.

◆ framebuffer

* framebuffer = (uint32_t*)(rax)

Definition at line 115 of file syscalls.h.

◆ global_write

bool global_write

Definition at line 303 of file syscalls.h.

◆ height

* height = ((rdi >> 16) & 65535)

Definition at line 104 of file syscalls.h.

◆ message

static uint64_t struct Message * message

Definition at line 338 of file syscalls.h.

◆ message_limit

bool size_t message_limit

Definition at line 303 of file syscalls.h.

◆ mq

* mq = (rax)

Definition at line 303 of file syscalls.h.

◆ mutex

* mutex = (rax)

Definition at line 171 of file syscalls.h.

◆ notify

bool notify

Definition at line 143 of file syscalls.h.

◆ num

uint16_t num

Definition at line 126 of file syscalls.h.

◆ pid

* pid
Initial value:
{
static void * entry
Definition syscalls.h:34
uint64_t rdi
Definition syscalls.h:106

Definition at line 34 of file syscalls.h.

◆ process

uint64_t process

Definition at line 357 of file syscalls.h.

◆ queue

static uint64_t queue

Definition at line 143 of file syscalls.h.

◆ rax

uint64_t rax = (uint64_t)(share_memory & 1)

Definition at line 36 of file syscalls.h.

◆ rdi

Definition at line 106 of file syscalls.h.

◆ rdx

uint64_t rdx = ((0 & 0xFF) << 24) | (1 & 0xFFFFFF)

Definition at line 37 of file syscalls.h.

◆ rsi

Definition at line 396 of file syscalls.h.

◆ stride

* stride = ((rdi >> 32) & 65535)

Definition at line 104 of file syscalls.h.

◆ timeout

uint64_t timeout

Definition at line 280 of file syscalls.h.

◆ trylock

bool trylock

Definition at line 197 of file syscalls.h.

◆ turn_on

uint16_t bool turn_on

Definition at line 126 of file syscalls.h.

◆ wait

bool wait

Definition at line 338 of file syscalls.h.

◆ width

* width = (rdi & 65535)

Definition at line 104 of file syscalls.h.