Pyro Kernel
Functions
Pyro System Calls

Functions

area_id sys_clone_area (const char *pzName, void **ppAddress, flags_t nProtection, flags_t nLockMode, area_id hSrcArea)
 Clones the specified area at a new address. More...
 
area_id sys_create_area (const char *pzName, void **ppAddress, size_t nSize, flags_t nProtection, flags_t nLockMode)
 Creates a new memory area with the specified attributes. More...
 
status_t sys_delete_area (area_id hArea)
 Deletes the specified area. More...
 
status_t sys_get_area_info (area_id hArea, AreaInfo_s *psInfo)
 Returns an AreaInfo_s for the specified area. More...
 
status_t sys_remap_area (area_id hArea, void *pPhysAddress)
 Remaps the specified area to use a different region of physical memory. More...
 
void * sys_sbrk (int nDelta)
 Adjusts the upper bound of a user process's data segment. More...
 
int alloc_tld (void)
 Allocates a TLD slot. More...
 
void * get_tld_addr (int nHandle)
 Gives the address on the stack of the TLD. More...
 
int free_tld (int nHandle)
 Releases a TLD slot previously allocated with alloc_tld(). More...
 
int sys_get_raw_system_time (bigtime_t *pRes)
 Returns the time elapsed since last system boot, in microseconds. More...
 
int sys_get_raw_real_time (bigtime_t *pRes)
 Returns the number of microseconds since 1970-01-01. More...
 
int sys_get_raw_idle_time (bigtime_t *pRes, int nProcessor)
 Returns the total idle time for the given CPU, in microseconds. More...
 
int sys_set_real_time (uint32 nTimeLow, uint32 nTimeHigh)
 Sets the system clock to a new time. More...
 
int sys_aio_worker (void)
 Start the async I/O worker. More...
 
int sys_aio_request (struct aiocb *psAiocb)
 Queue an async I/O request. More...
 
void set_tld (int nHandle, int nValue)
 Assign a value to a TLD slot. More...
 
int get_tld (int nHandle)
 Retrieve the value stored in a TLD. More...
 

Detailed Description

Function Documentation

int alloc_tld ( void  )

Allocates a TLD slot.

Description:
Allocates a TLD. A TLD (thread local storage) is an integer that is allocated on the process level but accessed by threads. A thread can assign an arbitrary value to a TLD and then retrieve the value later. The TLD handle can be distributed among the threads but each thread will have its own private storage for the TLD. This means that both thread A and thread B can store different values to the same TLD without overwriting each other's TLD. This is for example used to give each thread a private "errno" global variable.
Returns
On success a positive handle is returned. On error -1 is returned; "errno" will receive the error code.
Error codes:
ENOMEM All TLD slots are in use.
See Also
free_tld(), set_tld(), get_tld()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
int free_tld ( int  nHandle)

Releases a TLD slot previously allocated with alloc_tld().

Parameters
nHandleThe TLD slot to release.
Returns
On success 0 is returned. On error -1 is returned "errno" will receive the error code.
Error codes:
  • EINVAL Invalid TLD handle.
See Also
alloc_tld(), set_tld(), get_tld()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
int get_tld ( int  nHandle)

Retrieve the value stored in a TLD.

Description:
Retrieve the value stored earlier by this thread.
Parameters
nHandleThe TLD to examine.
Returns
The value of the given TLD
See Also
set_tld(), alloc_tld(), free_tld()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
void* get_tld_addr ( int  nHandle)

Gives the address on the stack of the TLD.

Parameters
nHandleThe TLD to calculate the address for. Deprecated & marked for removal.
Returns
On success the address of the TLD is returned. On failure, NULL is returned.
Error codes:
  • NULL Invalid TLD handle.
See Also
alloc_tld(), set_tld(), get_tld()
Author
Kristian Van Der Vliet (vande.nosp@m.rs@l.nosp@m.iqwyd.nosp@m..com)
void set_tld ( int  nHandle,
int  nValue 
)

Assign a value to a TLD slot.

Description:
Assign a value to the calling thread's storage associated with the given TLD handle. This will not affect the value of the same TLD in another thread and the value can only be read back by the thread that actually assigned it.
Parameters
nHandleHandle to a TLD slot previously allocated by alloc_tld()
nValueThe value to assign to the TLD.
See Also
get_tld(), alloc_tld(), free_tld()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
int sys_aio_request ( struct aiocb psAiocb)

Queue an async I/O request.

Parameters
psAiocb- pointer to a struct aiocb structure.
Author
Kristian Van Der Vliet (vande.nosp@m.rs@l.nosp@m.iqwyd.nosp@m..org)
int sys_aio_worker ( void  )

Start the async I/O worker.

Author
Kristian Van Der Vliet (vande.nosp@m.rs@l.nosp@m.iqwyd.nosp@m..org)
area_id sys_clone_area ( const char *  pzName,
void **  ppAddress,
flags_t  nProtection,
flags_t  nLockMode,
area_id  hSrcArea 
)

Clones the specified area at a new address.

Parameters
pzNamea pointer to the string containing the name of the new area.
ppAddressa pointer to the variable where the start address of the new area will be stored, or NULL. If non- NULL, the previous value of the variable it points to will be used as the preferred start address of the new area.
nProtectiona protection bitmask containing any combination of: AREA_READ, AREA_WRITE, AREA_EXEC, AREA_KERNEL, and AREA_WRCOMB.
nLockModethe locking mode to use: AREA_NO_LOCK, AREA_LAZY_LOCK, AREA_FULL_LOCK, or AREA_CONTIGUOUS.
hSrcAreathe area_id of the area to clone.
Returns
-EFAULT if there is a memory access violation while copying pzName; -EINVAL if the preferred starting address at *ppAddress is not a multiple of PAGE_SIZE; the area_id of the new area otherwise.
See Also
alloc_area()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
area_id sys_create_area ( const char *  pzName,
void **  ppAddress,
size_t  nSize,
flags_t  nProtection,
flags_t  nLockMode 
)

Creates a new memory area with the specified attributes.

Parameters
pzNamea pointer to the string containing the name for the new area.
ppAddressa pointer to the variable where the start address of the new area will be stored, or NULL. If non- NULL, the previous value of the variable it points to will be used as the preferred start address of the new area.
nSizethe size in bytes of the requested area.
nProtectiona protection bitmask containing any combination of AREA_READ, AREA_WRITE, AREA_EXEC, AREA_KERNEL, and AREA_WRCOMB.
nLockModethe locking mode to use: AREA_NO_LOCK, AREA_LAZY_LOCK, AREA_FULL_LOCK, or AREA_CONTIGUOUS.
Returns
-EFAULT if there is a memory access violation while copying pzName; -EINVAL if the preferred start address at *ppAddress is not a multiple of PAGE_SIZE; -ENOADDRSPC if there isn't enough virtual address space, -ENOMEM if there isn't enough physical memory; the area_id of the new area otherwise.
See Also
alloc_area(), do_create_area()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
status_t sys_delete_area ( area_id  hArea)

Deletes the specified area.

Parameters
hAreaa handle to the area to delete.
Returns
-EINVAL if the area handle is invalid or if the area doesn't belong to this process; 0 otherwise.
See Also
do_delete_area()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
status_t sys_get_area_info ( area_id  hArea,
AreaInfo_s psInfo 
)

Returns an AreaInfo_s for the specified area.

Parameters
hAreaa handle to the area for which to return info.
psInfoa pointer to the AreaInfo_s in which to store the results.
Returns
-EINVAL if the area handle is invalid or the area doesn't belong to this process; -EFAULT if there is a memory access violation while copying to psInfo; 0 otherwise.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
int sys_get_raw_idle_time ( bigtime_t *  pRes,
int  nProcessor 
)

Returns the total idle time for the given CPU, in microseconds.

Parameters
pResa pointer to the bigtime_t in which to store the CPU idle time.
nProcessorthe processor for which to return the idle time.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
int sys_get_raw_real_time ( bigtime_t *  pRes)

Returns the number of microseconds since 1970-01-01.

Parameters
pResa pointer to the bigtime_t in which to store the current time.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
int sys_get_raw_system_time ( bigtime_t *  pRes)

Returns the time elapsed since last system boot, in microseconds.

Parameters
pResa pointer to the bigtime_t in which to store the system time.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
status_t sys_remap_area ( area_id  hArea,
void *  pPhysAddress 
)

Remaps the specified area to use a different region of physical memory.

Parameters
hAreaa handle to the area to remap.
pPhysAddressthe new start address in physical memory for the region.
Returns
-EINVAL if the area handle is invalid or if nPhysAddress isn't a multiple of PAGE_SIZE; 0 otherwise.
See Also
do_remap_area()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
void* sys_sbrk ( int  nDelta)

Adjusts the upper bound of a user process's data segment.

Parameters
nDeltathe number of bytes by which to increase or decrease the data segment.
Returns
-1 if there was an error adjusting the data segment; otherwise, the old upper bound of the process's data segment.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
int sys_set_real_time ( uint32  nTimeLow,
uint32  nTimeHigh 
)

Sets the system clock to a new time.

Does not set the RTC.

Parameters
nTimeLowthe low 32 bits of the new system time, in microseconds since 1970-01-01.
nTimeHighthe high 32 bits of the new system time
Returns
Always returns 0.
Attention
Missing check for sufficient privileges to set the system clock.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)