Pyro device driver API
|
Data Structures | |
struct | Resource_s |
Descriptor of the resource. More... | |
Functions | |
status_t | alloc_area_list (uint32_t nProtection, uint32_t nLockMode, uintptr_t nAddress, uint_fast32_t nCount, const char *const *apzNames, size_t *panOffsets, size_t *panSizes, area_id *panAreas) |
Allocates an array of areas with the specified names, starting offsets and sizes. More... | |
status_t | resize_area (area_id hArea, size_t nNewSize, bool bAtomic) |
Resizes the specified area. More... | |
status_t | delete_area (area_id hArea) |
Deletes the specified area. More... | |
area_id | create_area (const char *pzName, void **ppAddress, size_t nSize, size_t nMaxSize, flags_t nProtection, flags_t nLockMode) |
Creates a new memory area in the current process. More... | |
status_t | get_area_physical_address (area_id hArea, uintptr_t *pnAddress) |
Returns the starting physical memory address for the specified area. More... | |
status_t | get_area_info (area_id hArea, AreaInfo_s *psInfo) |
Returns an AreaInfo_s for the specified area. More... | |
status_t | remap_area (area_id hArea, void *pPhysAddress) |
Remaps the specified area to use a different region of physical memory. More... | |
status_t | memcpy_to_user (void *pDst, const void *pSrc, size_t nSize) |
Copies a region of memory from kernel space into user space. More... | |
status_t | memcpy_from_user (void *pDst, const void *pSrc, size_t nSize) |
Copies a region of memory from user space into kernel space. More... | |
status_t | strncpy_from_user (char *pzDst, const char *pzSrc, size_t nMaxLen) |
Copies a string from user space into kernel space. More... | |
status_t | strndup_from_user (const char *pzSrc, size_t nMaxLen, char **ppzDst) |
Copies a string from user space into a newly allocated kernel region. More... | |
status_t | strcpy_to_user (char *pzDst, const char *pzSrc) |
Copies a string from kernel space into user space. More... | |
status_t | strlen_from_user (const char *pzString) |
Returns the length of the specified string. More... | |
status_t | verify_mem_area (const void *pAddress, size_t nSize, bool bWriteAccess) |
Verifies a region of user memory for kernel access. More... | |
int | register_device (const char *pzName, const char *pzBus) |
Registers a device and returns a handle to it. More... | |
void | unregister_device (int nHandle) |
Unregisters a previously registered device. More... | |
status_t | claim_device (int nDeviceID, int nHandle, const char *pzName, enum device_type eType) |
Claims a registered device. More... | |
void | release_device (int nHandle) |
Releases a device. More... | |
status_t | get_device_info (DeviceInfo_s *psInfo, int nIndex) |
Returns a DeviceInfo_s structure for a registered device. More... | |
void | set_device_data (int nHandle, void *pData) |
Sets private device driver data of one device. More... | |
void * | get_device_data (int nHandle) |
Returns the private device driver data of one device. More... | |
status_t | register_busmanager (int nDeviceID, const char *pzName, busmanager_get_hooks *pfHooks) |
Registers a busmanager. More... | |
void * | alloc_real (uint32 nSize, uint32 nFlags) |
Allocates memory in the real memory region. More... | |
void | free_real (void *pAddress) |
Frees memory in the real memory region. More... | |
status_t | rename_process (int nProcessID, const char *pzName) |
Rename a process. 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... | |
void | boot_reserve_io_region (uint nStart, uint nEnd, const char *pzName) |
Reserves I/O port region at boot time. More... | |
void | boot_reserve_mem_region (uint nStart, uint nEnd, const char *pzName) |
Reserves physical memory region at boot time. More... | |
Resource_s * | ioport_root_resource (void) |
Return pointer to the toplevel resource tree for I/O ports. More... | |
Resource_s * | memory_root_resource (void) |
Return pointer to the toplevel resource tree for physical memory areas. More... | |
int | request_resource (Resource_s *psRoot, Resource_s *psNew) |
Register resource in the specified resource tree. More... | |
Resource_s * | ____request_resource (Resource_s *psRoot, Resource_s *psNew) |
This function works similar to request_resource(), but it returns pointer to the conflicting resource. More... | |
int | release_resource (Resource_s *psOld) |
Removes source from the resource tree. More... | |
int | allocate_resource (Resource_s *psRoot, Resource_s *psNew, uint nSize, uint nMin, uint nMax, uint nAlign, void(*pfnAlign)(void *pData, Resource_s *psRes, uint nSize, uint nAlign), void *pAlignData) |
This function allocates resource in the resource tree. More... | |
int | insert_resource (Resource_s *psParent, Resource_s *psNew) |
Insert resource into the resource tree. More... | |
int | adjust_resource (Resource_s *psRes, uint nStart, uint nSize) |
Adjust new resource area for the given base and size. More... | |
Resource_s * | __request_region (Resource_s *psParent, uint nStart, uint nSize, const char *pzName) |
Request region in the given resource tree. More... | |
void | __release_region (Resource_s *psParent, uint nStart, uint nSize) |
Release region in the resource tree. More... | |
void | __free_resource (Resource_s *psRoot, uint nStart, uint nReqMask) |
Free resource which starts in the 1st level of the root children. More... | |
status_t | delete_semaphore (sem_id hSema) |
Delete a kernel semaphore. More... | |
status_t | lock_semaphore_ex (sem_id hSema, int nCount, uint32 nFlags, bigtime_t nTimeOut) |
Acquire a semaphore. More... | |
status_t | lock_semaphore (sem_id hSema, uint32 nFlags, bigtime_t nTimeOut) |
Lock a semaphore. More... | |
status_t | unlock_semaphore_ex (sem_id hSema, int nCount) |
Release a semaphore. More... | |
status_t | unlock_semaphore (sem_id hSema) |
Release a semaphore. More... | |
status_t | unlock_and_suspend (sem_id hWaitQueue, sem_id hSema) |
Unlock a reqular semaphore and block on a wait-queue. More... | |
status_t | spinunlock_and_suspend (sem_id hWaitQueue, SpinLock_s *psLock, uint32 nCPUFlags, bigtime_t nTimeOut) |
Release a spinlock and block on a wait-queue in one atomic operation. More... | |
status_t | reset_semaphore (sem_id hSema, int nCount) |
Reset the count on the given semaphore. More... | |
status_t | sleep_on_sem (sem_id hSema, bigtime_t nTimeOut) |
Non conditionally block on a semaphore (wait-queue) More... | |
status_t | wakeup_sem (sem_id hSema, bool bAll) |
Wake up threads blocked on a wait-queue. More... | |
void | disable_device_on_bus (int nDeviceID, const char *pzBus) |
Disable one device driver. More... | |
void | disable_device (int nDeviceID) |
Disable one PCI device driver. More... | |
void | enable_devices_on_bus (const char *pzBus) |
Enable all device drivers for devices on a specific bus. More... | |
void | enable_all_devices (void) |
Enable all device drivers. More... | |
int | create_device_node (int nDeviceID, int nDeviceHandle, const char *pzPath, const DeviceOperations_s *psOps, void *pNodeCookie) |
Publish a device node inside the /dev/ directory. More... | |
int | delete_device_node (int nHandle) |
Remove a device node from the /dev/ directory. More... | |
int | rename_device_node (int nHandle, const char *pzNewPath) |
Rename and/or move a device node. More... | |
int | decode_disk_partitions (device_geometry *psDiskGeom, Partition_s *pasPartitions, int nMaxPartitions, void *pCookie, disk_read_op *pfReadCallback) |
Decode a hard-disk partition table. More... | |
int | based_open (int nRootFD, const char *pzPath, int nFlags,...) |
Open a file relative to a given directory. More... | |
int | freadlink (int nFile, char *pzBuffer, size_t nBufSize) |
Read the content of an previously opened symlink. More... | |
Resource_s* ____request_resource | ( | Resource_s * | psRoot, |
Resource_s * | psNew | ||
) |
This function works similar to request_resource(), but it returns pointer to the conflicting resource.
psRoot | pointer to the root of the resource tree |
psNew | pointer to the resource descriptor to be inserted |
void __free_resource | ( | Resource_s * | psRoot, |
uint | nStart, | ||
uint | nReqMask | ||
) |
Free resource which starts in the 1st level of the root children.
Only resources that match given mask are freed. This is useful for free() like function when using resource manager to manage allocatable heaps.
psRoot | parent resource |
nStart | address of the beginning of the resource to be freed |
nReqMask | required bits must be set in the resource flags |
void __release_region | ( | Resource_s * | psParent, |
uint | nStart, | ||
uint | nSize | ||
) |
Release region in the resource tree.
Specified region is searched for in the resource tree. If the region wasn't found, function reports warning by the kernel message. Corresponding resource descriptor is removed and freed.
psParent | root resource |
nStart | start of the resource |
nEnd | end of thre resource |
Resource_s* __request_region | ( | Resource_s * | psParent, |
uint | nStart, | ||
uint | nSize, | ||
const char * | pzName | ||
) |
Request region in the given resource tree.
Caller provides region area and region name. Resource descriptor is automatically allocated. New resource is claimed.
psParent | parent resource |
nStart | beginning of the resource area |
nSize | size of the resource |
pzName | name of the resource |
int adjust_resource | ( | Resource_s * | psRes, |
uint | nStart, | ||
uint | nSize | ||
) |
Adjust new resource area for the given base and size.
Children areas aren't touched. If children wouldn't fit in the new rage, error is returned.
psRes | resource to be modified |
nStart | start of the resource |
nEnd | end of the resource |
status_t alloc_area_list | ( | uint32_t | nProtection, |
uint32_t | nLockMode, | ||
uintptr_t | nAddress, | ||
uint_fast32_t | nCount, | ||
const char *const * | apzNames, | ||
size_t * | panOffsets, | ||
size_t * | panSizes, | ||
area_id * | panAreas | ||
) |
Allocates an array of areas with the specified names, starting offsets and sizes.
All areas will have the same protection mask and locking mode.
nProtection | a protection bitmask containing any combination of: AREA_READ , AREA_WRITE , AREA_EXEC , AREA_KERNEL , and AREA_WRCOMB . |
nLockMode | the locking mode to use: AREA_NO_LOCK , AREA_LAZY_LOCK , AREA_FULL_LOCK , or AREA_CONTIGUOUS . |
nAddress | the base virtual memory address for the new areas. Each area will start at (nAddress + panOffsets[i]) . |
nCount | the number of areas to create. apzNames , panOffsets , panSizes , and panAreas are arrays of this size. |
apzNames | an array of pointers to strings containing the names to use for each area. Any entry can be NULL to create an unnamed area, or a NULL pointer can be passed here to create all areas without names. |
panOffsets | an array of byte offsets from nAddress to use as the start address for each area. |
panSizes | an array of sizes in bytes for each area. |
panAreas | the area_id s of the new areas will be copied to this array. |
-EINVAL
if any of the areas to create would overlap or if the starting offsets are not in sequential order, -ENOADDRSPC
if there isn't enough free virtual address space for the new areas, -ENOMEM
if there isn't enough physical memory available; 0
otherwise. void* alloc_real | ( | uint32 | nSize, |
uint32 | nFlags | ||
) |
Allocates memory in the real memory region.
nSize | the size in bytes to allocate. |
nFlags | MEMF_CLEAR is valid. |
int alloc_tld | ( | void | ) |
Allocates a TLD slot.
ENOMEM
All TLD slots are in use. int allocate_resource | ( | Resource_s * | psRoot, |
Resource_s * | psNew, | ||
uint | nSize, | ||
uint | nMin, | ||
uint | nMax, | ||
uint | nAlign, | ||
void(*)(void *pData, Resource_s *psRes, uint nSize, uint nAlign) | pfnAlign, | ||
void * | pAlignData | ||
) |
This function allocates resource in the resource tree.
It searches for the free area of the specified size and alignment. User has ability to modify resource alignment by the pfnAlign function. After the resource allocation, specified region is claimed in the resource tree.
psRoot | root resource node which we want to allocate resource in |
psNew | pointer to the new resource descriptor |
nSize | requested size |
nMin | minimal address |
nMax | maximal resource address |
nAlign | starting address alignment |
pfnAlign | user alignment function (optional) |
pAlignData | data passed to pfnAlign |
int based_open | ( | int | nRootFD, |
const char * | pzPath, | ||
int | nFlags, | ||
... | |||
) |
Open a file relative to a given directory.
The first parameter should be a file descriptor for a open directory and the path can be eighter absolute (starting with a "/") in which case the semantics is exactly the same as for open() or it can be relative to nRootFD
.
The "real" current working directory is not affected.
This provide a thread-safe way to do do the following:
The problem with the above example in a multithreaded environment is that other threads will be affected by the change of current working directory and might get into trouble while we temporarily change it. Using based_open() is also more efficient since only one kernel-call is done (based_open() is just as efficient as open()).
nRootFD | The directory to use as starting point when searching for pzPath |
pzPath | Path to the file to open. This can eighter be absolute or relative to nRootFD . |
nFlags | Flags controlling how to open the file. Look at open() for a full description of the flags. |
nMode | The access rights to set on the newly created file if O_CREAT is specified in nFlags |
nRootFD
is not a valid file descriptornRootFD
is not a directoryvoid boot_reserve_io_region | ( | uint | nStart, |
uint | nEnd, | ||
const char * | pzName | ||
) |
Reserves I/O port region at boot time.
nStart | start of the area |
nEnd | end of the area |
pzName | name of the area |
void boot_reserve_mem_region | ( | uint | nStart, |
uint | nEnd, | ||
const char * | pzName | ||
) |
Reserves physical memory region at boot time.
nStart | start of the area |
nEnd | end of the area |
pzName | name of the area |
status_t claim_device | ( | int | nDeviceID, |
int | nHandle, | ||
const char * | pzName, | ||
enum device_type | eType | ||
) |
Claims a registered device.
nDeviceID | the device id of the driver. |
nHandle | the handle returned by the register_device() call. |
pzName | the new name of the device. |
eType | the type of the device. |
0
if successful or another value if the device is already claimed. area_id create_area | ( | const char * | pzName, |
void ** | ppAddress, | ||
size_t | nSize, | ||
size_t | nMaxSize, | ||
flags_t | nProtection, | ||
flags_t | nLockMode | ||
) |
Creates a new memory area in the current process.
pzName | a pointer to the string containing the name for the new area. |
ppAddress | a 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. |
nSize | the size in bytes of the requested area. |
nMaxSize | the maximum size in bytes of the requested area. |
nProtection | a protection bitmask containing any combination of: AREA_READ , AREA_WRITE , AREA_EXEC , AREA_KERNEL , and AREA_WRCOMB . |
nLockMode | the locking mode to use: AREA_NO_LOCK , AREA_LAZY_LOCK , AREA_FULL_LOCK , or AREA_CONTIGUOUS . |
-EINVAL
if the preferred starting 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. int create_device_node | ( | int | nDeviceID, |
int | nDeviceHandle, | ||
const char * | pzPath, | ||
const DeviceOperations_s * | psOps, | ||
void * | pNodeCookie | ||
) |
Publish a device node inside the /dev/ directory.
nDeviceID | This is the unique device ID passed to the driver in the "device_init()" funcion. |
nDeviceHandle | The device handle for your device. You can probably ask the bus manager to get it. If you do not have a handle then you can also pass -1. |
pzPath | The path is relative to /dev/ and can specify directories in addition to the node name. For example "disk/scsi/hda/raw" will create a device node name "raw" inside /dev/disk/scsi/hda/". The path should not have any leading or trailing slashes. |
psOps | Pointer to a DeviceOperations_s structure containing a list of function pointers that will be called by the kernel on behalf of the user of the device. Functions like read(), write(), ioctl(), etc. will be mapped more or less directly into calls into the device driver through these function pointers. |
pNodeCookie | This is just a void pointer that the kernel will be associating with the device node and that will be passed back to the driver when calling functions in psOps (it will be passed to the psOps functions as the pNode parameter). This can be used by the driver to associate some private data with the device node. |
int decode_disk_partitions | ( | device_geometry * | psDiskGeom, |
Partition_s * | pasPartitions, | ||
int | nMaxPartitions, | ||
void * | pCookie, | ||
disk_read_op * | pfReadCallback | ||
) |
Decode a hard-disk partition table.
The caller must provide the device geometry and a callback that will be called to read the primary partition table and any existing nested extended partition tables.
The partition table is validated and the function will fail if it is found invalid. Checks performed include overlapping partitions, partitions ending outside the disk and the primary table containing more than one extended partition.
psDiskGeom | Pointer to a device_geometry structure describing the disk's geometry. |
pasPartitions | Pointer to an array of partition descriptors that will be filled in. |
nMaxPartitions | Number of entries allocated for pasPartitions. Maximum nMaxPartitions number of partitions will be returned. If the function returns exactly nMaxPartitions it might have overflowed and the call should be repeated with a larger buffer. |
pCookie | Pointer private to the caller that will be passed back to the pfReadCallback call-back function. |
pfReadCallback | Pointer to a function that will be called to read in partition tables. |
status_t delete_area | ( | area_id | hArea | ) |
Deletes the specified area.
hArea | a handle to the area to resize. |
-EINVAL
if the area handle is invalid, -ENOADDRSPC
if there isn't enough virtual address space available, -ENOMEM
if there isn't enough physical memory available; 0
otherwise. int delete_device_node | ( | int | nHandle | ) |
Remove a device node from the /dev/ directory.
nHandle | A device-node handle returned by a previous call to create_device_node() |
status_t delete_semaphore | ( | sem_id | hSema | ) |
Delete a kernel semaphore.
hSema | Semaphore handle returned by a previous call to create_semaphore() |
void disable_device | ( | int | nDeviceID | ) |
Disable one PCI device driver.
nDeviceID | Device id of the driver passed by device_init(). |
void disable_device_on_bus | ( | int | nDeviceID, |
const char * | pzBus | ||
) |
Disable one device driver.
nDeviceID | Device id of the driver passed by device_init(). |
pzBus | Busmanager name. |
void enable_all_devices | ( | void | ) |
Enable all device drivers.
void enable_devices_on_bus | ( | const char * | pzBus | ) |
Enable all device drivers for devices on a specific bus.
int freadlink | ( | int | nFile, |
char * | pzBuffer, | ||
size_t | nBufSize | ||
) |
Read the content of an previously opened symlink.
The semantics is the same as for readlink() except that it take and already opened symlink rather than a path-name.
Normally when passing a symlink path to open() it will automatically open the file/dir that the link points to and not the link itself. To stop open() from traversing the links you can add the O_NOTRAVERSE flag to the open-mode. open() will then return a file-handle representing the link itself rather than the file the link points at.
nFile | File descriptor representing the symlink to read. |
pzBuffer | Pointer to a buffer of at least nBufSize bytes that will receive the content of the symlink. The buffer will not be NUL terminated but the number of bytes added to the buffer will be returned by freadlink(). |
nBufSize | Size of pzBuffer. |
nFile
is not a valid file descriptor or is not open for readingnFile
is not a symlinknFile
does not support symbolic links.void free_real | ( | void * | pAddress | ) |
Frees memory in the real memory region.
pAddress | a pointer to the allocated memory. |
int free_tld | ( | int | nHandle | ) |
Releases a TLD slot previously allocated with alloc_tld().
nHandle | The TLD slot to release. |
0
is returned. On error a negative error code is returned.EINVAL
Invalid TLD handle. status_t get_area_info | ( | area_id | hArea, |
AreaInfo_s * | psInfo | ||
) |
Returns an AreaInfo_s
for the specified area.
hArea | a handle to the area for which to return info. |
psInfo | a pointer to the AreaInfo_s in which to store the results. |
-EINVAL
if the area handle is invalid or the area doesn't belong to this process; 0
otherwise. status_t get_area_physical_address | ( | area_id | hArea, |
uintptr_t * | pnAddress | ||
) |
Returns the starting physical memory address for the specified area.
hArea | a handle to the area. |
pnAddress | a pointer to the variable where the starting physical address for hArea will be copied. |
-EINVAL
if hArea is invalid; 0
otherwise. void* get_device_data | ( | int | nHandle | ) |
Returns the private device driver data of one device.
nHandle | the handle of the device. |
status_t get_device_info | ( | DeviceInfo_s * | psInfo, |
int | nIndex | ||
) |
Returns a DeviceInfo_s
structure for a registered device.
psInfo | a pointer to the DeviceInfo_s structure to fill. |
nIndex | the index of the device. |
0
if successful. void* get_tld_addr | ( | int | nHandle | ) |
Gives the address on the stack of the TLD.
nHandle | The TLD to calculate the address for. Deprecated & marked for removal. |
int insert_resource | ( | Resource_s * | psParent, |
Resource_s * | psNew | ||
) |
Insert resource into the resource tree.
This function works similar to request_resource(), when no resource conflict happens. If a conflict happens, and the conflicting resources fit entirely in the psNew resource range, resource psNew becomes new parent of the conflicting resources. Otherwise it becomes child of the conflicting resource.
psParent | resource tree root |
psNew | pointer to the new resource to be inserted |
Resource_s* ioport_root_resource | ( | void | ) |
Return pointer to the toplevel resource tree for I/O ports.
All drivers which register I/O port, register them directly in this tree.
status_t lock_semaphore | ( | sem_id | hSema, |
uint32 | nFlags, | ||
bigtime_t | nTimeOut | ||
) |
Lock a semaphore.
hSema | Semaphore handle to lock. |
nFlags |
|
nTimeOut | Maximum number of micro seconds to wait for the semaphore to be released. If the timeout is 0 lock_semaphore_ex() will never return, and if it is INFINITE_TIMEOUT it will block until the semaphore can be acquired or a signel is caught. |
status_t lock_semaphore_ex | ( | sem_id | hSema, |
int | nCount, | ||
uint32 | nFlags, | ||
bigtime_t | nTimeOut | ||
) |
Acquire a semaphore.
If the timeout is larger than 0 and the nesting counter becomes negative the calling thread will be blocked. The thread will then stay blocked until one of the following conditions are met:
If the timeout is 0 lock_semaphore_ex() will never block, but instead returns immediatly with ETIME if the semaphore can not be acquired. If the timeout is INFINITE_TIMEOUT the thread will be blocked until it can be successfully acquired or a signal is caught.
hSema | Semaphore handle to lock. |
nCount | Positive value that should be subtracted from the current nesting counter. |
nFlags |
|
nTimeOut | Maximum number of micro seconds to wait for the semaphore to be released. If the timeout is 0 lock_semaphore_ex() will never return, and if it is INFINITE_TIMEOUT it will block until the semaphore can be acquired or a signel is caught. |
status_t memcpy_from_user | ( | void * | pDst, |
const void * | pSrc, | ||
size_t | nSize | ||
) |
Copies a region of memory from user space into kernel space.
pDst | the starting address of the destination region. |
pSrc | the starting address of the source region. |
nSize | the number of bytes to copy. |
0
otherwise. status_t memcpy_to_user | ( | void * | pDst, |
const void * | pSrc, | ||
size_t | nSize | ||
) |
Copies a region of memory from kernel space into user space.
pDst | the starting address of the destination region. |
pSrc | the starting address of the source region. |
nSize | the number of bytes to copy. |
0
otherwise. Resource_s* memory_root_resource | ( | void | ) |
Return pointer to the toplevel resource tree for physical memory areas.
All drivers which register memory regions use this tree (e.g. the PCI driver).
status_t register_busmanager | ( | int | nDeviceID, |
const char * | pzName, | ||
busmanager_get_hooks * | pfHooks | ||
) |
Registers a busmanager.
nDeviceID | device id of the driver registering this busmanager |
pzName | the name of the busmanager. |
pfHooks | pointer to the function table of the busmanager |
int register_device | ( | const char * | pzName, |
const char * | pzBus | ||
) |
Registers a device and returns a handle to it.
pzName | the name of the device; will be overwritten after calling claim_device(). |
pzBus | the name of the bus the device is attached to. |
void release_device | ( | int | nHandle | ) |
Releases a device.
nHandle | the handle returned by the register_device() call. |
int release_resource | ( | Resource_s * | psOld | ) |
Removes source from the resource tree.
No memory is freed.
psOld | pointer to the resource descriptor |
status_t remap_area | ( | area_id | hArea, |
void * | pPhysAddress | ||
) |
Remaps the specified area to use a different region of physical memory.
hArea | a handle to the area to remap. |
pPhysAddress | the new start address in physical memory for the region. |
-EINVAL
if the area handle is invalid or if nPhysAddress isn't a multiple of PAGE_SIZE
; 0
otherwise. int rename_device_node | ( | int | nHandle, |
const char * | pzNewPath | ||
) |
Rename and/or move a device node.
nHandle | A device-node handle returned by a previous call to create_device_node() |
pzNewPath | The new device-node path. |
status_t rename_process | ( | int | nProcessID, |
const char * | pzName | ||
) |
Rename a process.
nProcessID | Identity of the process to rename. You can also pass in -1 to rename the calling process. |
pzName | The new process name. Maximum OS_NAME_LENGTH characters long including the 0 termination. On success 0 is returned. On error a negative error code is returned. |
nProcessID
is not -1 and there is not process with that ID.int request_resource | ( | Resource_s * | psRoot, |
Resource_s * | psNew | ||
) |
Register resource in the specified resource tree.
This function checks for resource collisions.
psRoot | pointer to the root of the resource tree |
psNew | pointer to the resource descriptor to be inserted |
status_t reset_semaphore | ( | sem_id | hSema, |
int | nCount | ||
) |
Reset the count on the given semaphore.
hSema | The semaphore to modify. |
nCount | The new count for the semaphore. |
status_t resize_area | ( | area_id | hArea, |
size_t | nNewSize, | ||
bool | bAtomic | ||
) |
Resizes the specified area.
hArea | a handle to the area to resize. |
nNewSize | the new area size in bytes. |
bAtomic | if true , resize_area() will repeatedly shrink the block cache by 64K and try again if an -ENOMEM error is returned by alloc_area_pages() or alloc_area_page_tables(). |
-EINVAL
if the area handle is invalid, -ENOADDRSPC
if there isn't enough virtual address space available, -ENOMEM
if there isn't enough physical memory available; 0
otherwise. void set_device_data | ( | int | nHandle, |
void * | pData | ||
) |
Sets private device driver data of one device.
nHandle | the handle returned by the register_device() call. |
pData | the data. |
status_t sleep_on_sem | ( | sem_id | hSema, |
bigtime_t | nTimeOut | ||
) |
Non conditionally block on a semaphore (wait-queue)
A semaphore (as created with create_semaphore()) can be used as a wait-queue rather than a semaphore/mutex by using sleep_on_sem() and wakeup_sem() instead of lock_semaphore() and unlock_semaphore().
hSema | The wait-queue to sleep on (created with create_semaphore()). |
nTimeOut | Maximum number of microseconds to wait for someone to wake us up before ETIME is returned. |
status_t spinunlock_and_suspend | ( | sem_id | hWaitQueue, |
SpinLock_s * | psLock, | ||
uint32 | nCPUFlags, | ||
bigtime_t | nTimeOut | ||
) |
Release a spinlock and block on a wait-queue in one atomic operation.
This function can only be called from the kernel, or from device drivers. From user-space you should use unlock_and_suspend()
hWaitQueue | Handle to the wait-queue to block on (created earlier with create_semaphore()). |
psLock | Spinlock to release. |
nCPUFlags | The CPU flags to restore before returning. |
nTimeOut | Maximum number of microseconds to wait for someone to wake us up before ETIME is returned. |
status_t strcpy_to_user | ( | char * | pzDst, |
const char * | pzSrc | ||
) |
Copies a string from kernel space into user space.
pzDst | the starting address of the destination region. |
pzSrc | the address of the string to copy. |
0
otherwise. status_t strlen_from_user | ( | const char * | pzString | ) |
Returns the length of the specified string.
pzString | the starting address of the string. |
status_t strncpy_from_user | ( | char * | pzDst, |
const char * | pzSrc, | ||
size_t | nMaxLen | ||
) |
Copies a string from user space into kernel space.
pzDst | the starting address of the destination region. |
pzSrc | the address of the string to copy. |
nMaxLen | the maximum size of the string to copy. |
0
otherwise. status_t strndup_from_user | ( | const char * | pzSrc, |
size_t | nMaxLen, | ||
char ** | ppzDst | ||
) |
Copies a string from user space into a newly allocated kernel region.
pzSrc | the address of the string to copy. |
nMaxLen | the maximum size of the string to copy. |
ppzDst | a pointer to the variable in which to store a pointer to the new string. |
-ENAMETOOLONG
if the length of the string, including the trailing '\0'
, is greater than nMaxLen, -ENOMEM
if there isn't enough free memory for kmalloc(), any error code from verify_mem_area() on failure; 0
otherwise. status_t unlock_and_suspend | ( | sem_id | hWaitQueue, |
sem_id | hSema | ||
) |
Unlock a reqular semaphore and block on a wait-queue.
hWaitQueue | Handle to the wait-queue to block on (created earlier with create_semaphore()) |
hSema | Semaphore to release. |
status_t unlock_semaphore | ( | sem_id | hSema | ) |
Release a semaphore.
status_t unlock_semaphore_ex | ( | sem_id | hSema, |
int | nCount | ||
) |
Release a semaphore.
hSema | The semaphore to release. |
nCount | Number of times to release the semaphore. |
void unregister_device | ( | int | nHandle | ) |
Unregisters a previously registered device.
nHandle | the handle returned by the register_device() call. |
status_t verify_mem_area | ( | const void * | pAddress, |
size_t | nSize, | ||
bool | bWriteAccess | ||
) |
Verifies a region of user memory for kernel access.
pAddress | the start address of the region to lock. |
nSize | the size in bytes of the region to lock. |
bWriteAccess | true to lock the region for write access; false otherwise. |
-EFAULT
if pAddress points to an address in kernel space, doesn't correspond to an area in user space, or if (pAddress + nSize - 1)
extends beyond the end of the area; -ENOMEM
if there isn't enough physical memory available; 0
otherwise. status_t wakeup_sem | ( | sem_id | hSema, |
bool | bAll | ||
) |
Wake up threads blocked on a wait-queue.
Wake up eighter the first thread (the one that first blocked) or all threads blocked on a wait-queue. If "bAll" is true all semaphores blocked on the queue will be released otherwhice only the first thread will be unblocked.
hSema | Wait-queue to release (created with create_semaphore()). |
bAll | true to wake up all threads, false to only wake up the first thread in the queue. |