RPV Event driven kernel
Loading...
Searching...
No Matches
Mandatory APIs called by the Kernel

Kernel can run on any binary system platfrom and compile using target platform toolchain e.g. any gcc variant alike. There are APIs require implementation within the concrete target platform project. There are several compile instance profiles available each defines the number of APIs need in implementation. More...

Collaboration diagram for Mandatory APIs called by the Kernel:

Modules

 Kernel lite profile
 Kernel lite variant. Includes a core with basic commands.
 
 Kernel full profile
 Kernel full variant. Includes a core and all currently available subsystems.
 

Files

file  console.h
 Console interface used by the Kernel Shell.
 
file  disk.h
 Disk low level I/O interface called by file I/O subsystem.
 
file  fat.h
 File system middleware interface called by file I/O subsystem.
 
file  prompt.h
 System prompt constructor interface used by the Kernel Shell.
 

Functions

void con_ln (void)
 Moves cursor to the next line.
 
void con_tab (void)
 Inserts a horizontal tab.
 
void con_clear (void)
 Clears the console display.
 
void con_char (const char code)
 Writes a single character to the console.
 
void con_string (const char *str)
 Writes a null-terminated string to the console.
 
void con_xy (size_t cx, size_t cy)
 Sets the cursor position.
 
size_t con_getx (void)
 Retrieves the current cursor X position.
 
size_t con_gety (void)
 Retrieves the current cursor Y position.
 
void set_con (void)
 Initializes the console subsystem.
 
void disk_io (void)
 Initializes the disk I/O module be a part of a file I/O subsystem.
 
size_t get_disks (void)
 Returns the number of detected disks.
 
void get_disk (size_t did, disk_t *disk)
 Retrieves disk descriptor by identifier.
 
void get_diskInfo (size_t did, char *dsk_info, size_t dsk_infoLen)
 Retrieves human-readable disk information string.
 
uint8_t flush_disk (size_t did)
 Flushes pending write operations to disk.
 
uint8_t read_disk (void *buffer, size_t did, size_t blck, size_t blocks)
 Reads blocks from disk.
 
uint8_t write_disk (void const *buffer, size_t did, size_t blck, size_t blocks)
 Writes blocks to disk.
 
void fat_getcwd (char *cwd)
 Retrieves current working directory path.
 
bool fat_exists (char const *path)
 Checks whether a file or directory exists.
 
bool fat_chdir (char const *cwd)
 Changes current working directory.
 
bool fat_mkdir (char const *path)
 Creates a new directory.
 
bool fat_unlink (char const *path)
 Removes a file or directory.
 
bool fat_mount (char const *path)
 Mounts a FAT filesystem.
 
bool fat_unmount (char const *path)
 Unmounts a FAT filesystem.
 
bool fat_stat (char const *path, filinfo_t *fno)
 Retrieves file or directory metadata.
 
fat_error_code_t fat_getcode (void)
 Returns last FAT error code.
 
void fat_fclose (int fd)
 Closes an open file descriptor.
 
int fat_fopen (char const *path, file_access_t mode)
 Opens a file.
 
size_t fat_fsize (int fd)
 Returns file size.
 
size_t fat_fread (int fd, void *buffer, size_t nread)
 Reads data from file.
 
size_t fat_fwrite (int fd, void const *buffer, size_t nwrite)
 Writes data to file.
 
void fat_ls (char const *path, void const *ls_ctx, void(*nxt_file)(void const *ls_ctx, filinfo_t const *fi))
 Lists directory contents.
 
void _shell_prompt (char *prompt, const size_t p_len)
 Generates or retrieves the current shell prompt string.
 

Variables

size_t MAX_X
 Maximum horizontal coordinate of the console.
 
size_t MAX_Y
 Maximum vertical coordinate of the console.
 

Detailed Description

Kernel can run on any binary system platfrom and compile using target platform toolchain e.g. any gcc variant alike. There are APIs require implementation within the concrete target platform project. There are several compile instance profiles available each defines the number of APIs need in implementation.

Function Documentation

◆ _shell_prompt()

void _shell_prompt ( char *  prompt,
const size_t  p_len 
)

Generates or retrieves the current shell prompt string.

Parameters
[out]promptOutput buffer receiving the prompt string.
[in]p_lenLength of the output buffer in bytes.
Precondition
  • prompt must not be NULL.
  • p_len > 0.
Postcondition
  • prompt contains a null-terminated string on success.
  • The string is truncated if the buffer is insufficient.

Writes the current shell prompt into the provided buffer. The prompt format is implementation-defined and may include contextual information such as:

  • Current working directory
  • User name
  • System state indicators

The function guarantees null-termination provided p_len > 0.

Side Effects:
  • None expected (read-only state access).
Warning
The caller is responsible for providing a sufficiently large buffer to avoid truncation.

◆ con_char()

void con_char ( const char  code)

Writes a single character to the console.

Parameters
[in]codeCharacter to display.

Writes the specified character at the current cursor position and advances the cursor according to implementation rules.

Note
Control characters may be handled specially.
Side Effects:
  • Modifies display buffer.
  • Updates cursor position.

◆ con_clear()

void con_clear ( void  )

Clears the console display.

Clears the entire screen buffer and resets the cursor to the origin position (0,0).

Postcondition
  • Screen buffer is cleared.
  • Cursor position is (0,0).
Note
When concrete console module doesnt support screen buffer clear (e.g. tty) it can be empty implemented. e.g. void con_clear() { }
Side Effects:
Modifies the entire display buffer.

◆ con_getx()

size_t con_getx ( void  )

Retrieves the current cursor X position.

Returns
Current horizontal cursor position.

Returns a value in the range [0, MAX_X - 1].

◆ con_gety()

size_t con_gety ( void  )

Retrieves the current cursor Y position.

Returns
Current vertical cursor position.

Returns a value in the range [0, MAX_Y - 1].

◆ con_ln()

void con_ln ( void  )

Moves cursor to the next line.

Advances the cursor to the beginning of the next line. Scrolling behavior is implementation-defined if the cursor is currently on the last line.

Postcondition
Cursor X position is reset to 0.
Side Effects:
May trigger screen scrolling.

◆ con_string()

void con_string ( const char *  str)

Writes a null-terminated string to the console.

Parameters
[in]strPointer to null-terminated character string.
Precondition
str must not be NULL.

Writes characters sequentially starting at the current cursor position. Cursor advancement and wrapping behavior are implementation-defined.

Side Effects:
  • Modifies display buffer.
  • Updates cursor position.

◆ con_tab()

void con_tab ( void  )

Inserts a horizontal tab.

Advances the cursor to the next tab stop. Tab width is implementation-defined.

Side Effects:
Modifies cursor position.

◆ con_xy()

void con_xy ( size_t  cx,
size_t  cy 
)

Sets the cursor position.

Parameters
[in]cxHorizontal position (column index).
[in]cyVertical position (row index).
Precondition
  • cx < MAX_X
  • cy < MAX_Y

Moves the cursor to the specified coordinates. Behavior is undefined if parameters exceed console bounds unless explicitly handled by implementation.

Note
When console doesnt support coordinates navigation (e.g. tty) it can be empty implemented e.g. void con_xy(size_t x, size_t y) { }
Side Effects:
Modifies internal cursor state.

◆ disk_io()

void disk_io ( void  )

Initializes the disk I/O module be a part of a file I/O subsystem.

Performs hardware detection, driver initialization, and prepares internal file I/O subsystem disk tables.

Must be called before invoking other disk API functions.

Postcondition
Disk I/O is ready for operations.
Side Effects:
  • May access hardware.
  • Initializes internal static state.

◆ fat_chdir()

bool fat_chdir ( char const *  cwd)

Changes current working directory.

Parameters
[in]cwdTarget directory path.
Return values
trueDirectory change successful.
falseFailure (see fat_getcode()).

◆ fat_exists()

bool fat_exists ( char const *  path)

Checks whether a file or directory exists.

Parameters
[in]pathPath to file or directory.
Returns
true if object exists. false otherwise.

◆ fat_fclose()

void fat_fclose ( int  fd)

Closes an open file descriptor.

Parameters
[in]fdFile descriptor.

◆ fat_fopen()

int fat_fopen ( char const *  path,
file_access_t  mode 
)

Opens a file.

Parameters
[in]pathFile path.
[in]modeFile access mode flags.
Returns
Non-negative file descriptor on success. Negative value on failure (see fat_getcode()).

◆ fat_fread()

size_t fat_fread ( int  fd,
void *  buffer,
size_t  nread 
)

Reads data from file.

Parameters
[in]fdFile descriptor.
[out]bufferDestination buffer.
[in]nreadNumber of bytes to read.
Returns
Number of bytes actually read.
Precondition
buffer must not be NULL.

◆ fat_fsize()

size_t fat_fsize ( int  fd)

Returns file size.

Parameters
[in]fdFile descriptor.
Returns
File size in bytes.

◆ fat_fwrite()

size_t fat_fwrite ( int  fd,
void const *  buffer,
size_t  nwrite 
)

Writes data to file.

Parameters
[in]fdFile descriptor.
[in]bufferSource buffer.
[in]nwriteNumber of bytes to write.
Returns
Number of bytes actually written.

◆ fat_getcode()

fat_error_code_t fat_getcode ( void  )

Returns last FAT error code.

Returns
Most recent fat_error_code_t value.

◆ fat_getcwd()

void fat_getcwd ( char *  cwd)

Retrieves current working directory path.

Parameters
[out]cwdOutput buffer for path string.
Precondition
cwd must not be NULL.
Note
Buffer size must be sufficient for full path.

◆ fat_ls()

void fat_ls ( char const *  path,
void const *  ls_ctx,
void(*)(void const *ls_ctx, filinfo_t const *fi)  nxt_file 
)

Lists directory contents.

Parameters
[in]pathDirectory path.
[in]ls_ctxUser-defined data context pointer.
[in]nxt_fileCallback invoked for each directory entry.

Iterates through directory entries and invokes the callback for each discovered file passing user defined data context object pointer

Precondition
  • nxt_file must not be NULL.
Warning
Callback must not modify filesystem state otherwise a behaviour is undefined.

◆ fat_mkdir()

bool fat_mkdir ( char const *  path)

Creates a new directory.

Parameters
[in]pathDirectory path.
Return values
trueDirectory created successfully.
falseFailure (see fat_getcode()).

◆ fat_mount()

bool fat_mount ( char const *  path)

Mounts a FAT filesystem.

Parameters
[in]pathMount source (device path).
Return values
trueMount successful.
falseMount failed (see fat_getcode()).
Postcondition
Filesystem is ready for access on success.

◆ fat_stat()

bool fat_stat ( char const *  path,
filinfo_t fno 
)

Retrieves file or directory metadata.

Parameters
[in]pathTarget path.
[out]fnoOutput file information structure.
Return values
trueInformation retrieved successfully.
falseFailure (see fat_getcode()).

◆ fat_unlink()

bool fat_unlink ( char const *  path)

Removes a file or directory.

Parameters
[in]pathTarget path.
Return values
trueRemoval successful.
falseFailure (see fat_getcode()).

◆ fat_unmount()

bool fat_unmount ( char const *  path)

Unmounts a FAT filesystem.

Parameters
[in]pathMount source.
Return values
trueUnmount successful.
falseUnmount failed (see fat_getcode()).

◆ flush_disk()

uint8_t flush_disk ( size_t  did)

Flushes pending write operations to disk.

Parameters
[in]didDisk identifier.
Returns
Disk I/O status code.
Return values
DISK_IO_OKFlush successful.
DISK_INVALIDInvalid disk identifier parameter
DISK_NOT_READYDisk not initialized.
DISK_IO_ERRHardware error occurred.
Side Effects:
May trigger physical media write.

◆ get_disk()

void get_disk ( size_t  did,
disk_t disk 
)

Retrieves disk descriptor by identifier.

Parameters
[in]didDisk identifier.
[out]diskPointer to disk descriptor structure.
Precondition
  • disk must not be NULL.
  • did must refer to a valid disk.
Postcondition
disk structure is populated on success.
Warning
Behavior is undefined if disk is NULL.

◆ get_diskInfo()

void get_diskInfo ( size_t  did,
char *  dsk_info,
size_t  dsk_infoLen 
)

Retrieves human-readable disk information string.

Parameters
[in]didDisk identifier.
[out]dsk_infoOutput buffer for disk information string.
[in]dsk_infoLenLength of output buffer in bytes.
Precondition
  • dsk_info must not be NULL.
  • dsk_infoLen > 0.

Writes a null-terminated string describing the disk. Output is truncated if buffer is insufficient.

Side Effects:
Modifies dsk_info buffer.

◆ get_disks()

size_t get_disks ( void  )

Returns the number of detected disks.

Returns
Number of available disk devices.
Return values
0No disks detected or module not initialized.

◆ read_disk()

uint8_t read_disk ( void *  buffer,
size_t  did,
size_t  blck,
size_t  blocks 
)

Reads blocks from disk.

Parameters
[out]bufferDestination buffer.
[in]didDisk identifier.
[in]blckStarting block index.
[in]blocksNumber of blocks to read.
Returns
Disk I/O status code.
Return values
DISK_IO_OKRead successful.
DISK_INVALIDInvalid parameters.
DISK_NOT_READYDisk not initialized.
DISK_IO_ERRHardware read failure.
Precondition
  • buffer must not be NULL.
  • blocks > 0.
  • blck + blocks must not exceed disk capacity.
Side Effects:
Modifies contents of buffer.

◆ set_con()

void set_con ( void  )

Initializes the console subsystem.

Performs required hardware or buffer initialization and prepares the console for output operations.

Must be called before using any other console function.

Postcondition
  • Console is ready for output.
  • MAX_X and MAX_Y are initialized.
Side Effects:
  • Initializes internal state.
  • May access hardware registers or memory-mapped I/O.

◆ write_disk()

uint8_t write_disk ( void const *  buffer,
size_t  did,
size_t  blck,
size_t  blocks 
)

Writes blocks to disk.

Parameters
[in]bufferSource buffer.
[in]didDisk identifier.
[in]blckStarting block index.
[in]blocksNumber of blocks to write.
Returns
Disk I/O status code.
Return values
DISK_IO_OKWrite successful.
DISK_WRITE_PROTECTMedia is write-protected.
DISK_INVALIDInvalid parameters.
DISK_NOT_READYDisk not initialized or media not ready
DISK_IO_ERRHardware write failure.
Precondition
  • buffer must not be NULL.
  • blocks > 0.
  • blck + blocks must not exceed disk capacity.
Side Effects:
  • Modifies disk media.
  • May trigger physical write operation.
Warning
Data integrity is not guaranteed unless flush_disk() is called after write operations when required.

Variable Documentation

◆ MAX_X

size_t MAX_X
extern

Maximum horizontal coordinate of the console.

Represents the maximum valid X coordinate (column index). Valid cursor X positions range from 0 to (MAX_X - 1).

Note
Value is implementation-defined and must be initialized during console subsystem / module implementation. Must be initialized. When concrete console module doesnt support X coordinate navigation (e.g. tty) it must be initialized as zero

◆ MAX_Y

size_t MAX_Y
extern

Maximum vertical coordinate of the console.

Represents the maximum valid Y coordinate (row index). Valid cursor Y positions range from 0 to (MAX_Y - 1).

Note
Value is implementation-defined and must be initialized during console subsystem / module implementation. Must be initialized When concrete console module doesnt support Y coordinate navigation (e.g. tty) it must be initialized as zero