KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Data Structures | Macros | Typedefs | Functions
dbgio.h File Reference

Debug I/O. More...

#include <kos/cdefs.h>
#include <arch/types.h>

Go to the source code of this file.

Data Structures

struct  dbgio_handler
 Debug I/O Interface. More...
 

Macros

#define DBGIO_MODE_POLLED   0
 Polled I/O mode. More...
 
#define DBGIO_MODE_IRQ   1
 IRQ-based I/O mode. More...
 

Typedefs

typedef struct dbgio_handler dbgio_handler_t
 Debug I/O Interface. More...
 

Functions

int dbgio_dev_select (const char *name)
 Select a new dbgio interface by name. More...
 
const char * dbgio_dev_get ()
 Fetch the name of the currently selected dbgio interface. More...
 
int dbgio_init ()
 Initialize the dbgio console. More...
 
int dbgio_set_irq_usage (int mode)
 Set IRQ usage. More...
 
int dbgio_read ()
 Read one character from the console. More...
 
int dbgio_write (int c)
 Write one character to the console. More...
 
int dbgio_flush ()
 Flush any queued output. More...
 
int dbgio_write_buffer (const uint8 *data, int len)
 Write an entire buffer of data to the console. More...
 
int dbgio_read_buffer (uint8 *data, int len)
 Read an entire buffer of data from the console. More...
 
int dbgio_write_buffer_xlat (const uint8 *data, int len)
 Write an entire buffer of data to the console (potentially with newline transformations). More...
 
int dbgio_write_str (const char *str)
 Write a NUL-terminated string to the console. More...
 
void dbgio_disable ()
 Disable debug I/O globally. More...
 
void dbgio_enable ()
 Enable debug I/O globally. More...
 
int dbgio_printf (const char *fmt,...) __printflike(1
 Built-in debug I/O printf function. More...
 

Detailed Description

Debug I/O.

This file contains the Debug I/O system, which abstracts things so that various types of debugging tools can be used by programs in KOS. Included among these tools is the dcload console (dcload-serial, dcload-ip, and fs_dclsocket), a raw serial console, and a framebuffer based console.

Author
Dan Potter

Macro Definition Documentation

#define DBGIO_MODE_IRQ   1

IRQ-based I/O mode.

See also
dbgio_set_irq_usage()
#define DBGIO_MODE_POLLED   0

Polled I/O mode.

See also
dbgio_set_irq_usage()

Typedef Documentation

Debug I/O Interface.

This struct represents a single dbgio interface. This should represent a generic pollable console interface. We will store an ordered list of these statically linked into the program and fall back from one to the next until one returns true for detected(). Note that the last device in this chain is the null console, which will always return true.

Function Documentation

const char* dbgio_dev_get ( )

Fetch the name of the currently selected dbgio interface.

Returns
The name of the current dbgio interface (or NULL if no device is selected)
int dbgio_dev_select ( const char *  name)

Select a new dbgio interface by name.

This function manually selects a new dbgio interface by name. This function will allow you to select a device, even if it is not detected.

Parameters
nameThe dbgio interface to select
Return values
0On success
-1On error
Error Conditions:
ENODEV - The specified device could not be initialized
void dbgio_disable ( )

Disable debug I/O globally.

void dbgio_enable ( )

Enable debug I/O globally.

int dbgio_flush ( )

Flush any queued output.

Return values
0On success
-1On error (errno should be set as appropriate)
int dbgio_init ( )

Initialize the dbgio console.

This function is called internally, and shouldn't need to be called by any user programs.

Return values
0On success
-1On error
Error Conditions:
ENODEV - No devices could be detected/initialized
int dbgio_printf ( const char *  fmt,
  ... 
)

Built-in debug I/O printf function.

Parameters
fmtA printf() style format string
...Format arguments
Returns
The number of bytes written, or <0 on error (errno should be set as appropriate)
int dbgio_read ( )

Read one character from the console.

Return values
0On success
-1On error (errno should be set as appropriate)
int dbgio_read_buffer ( uint8 data,
int  len 
)

Read an entire buffer of data from the console.

Parameters
dataThe buffer to read into
lenThe length of the buffer
Returns
Number of characters read on success, or -1 on failure (errno should be set as appropriate)
int dbgio_set_irq_usage ( int  mode)

Set IRQ usage.

The dbgio system defaults to polled usage. Some devices may not support IRQ mode at all.

Parameters
modeThe mode to use
Return values
0On success
-1On error (errno should be set as appropriate)
int dbgio_write ( int  c)

Write one character to the console.

Parameters
cThe character to write
Return values
1On success (number of characters written)
-1On error (errno should be set as appropriate)
Note
Interfaces may require a call to flush() before the output is actually flushed to the console.
int dbgio_write_buffer ( const uint8 data,
int  len 
)

Write an entire buffer of data to the console.

Parameters
dataThe buffer to write
lenThe length of the buffer
Returns
Number of characters written on success, or -1 on failure (errno should be set as appropriate)
int dbgio_write_buffer_xlat ( const uint8 data,
int  len 
)

Write an entire buffer of data to the console (potentially with newline transformations).

Parameters
dataThe buffer to write
lenThe length of the buffer
Returns
Number of characters written on success, or -1 on failure (errno should be set as appropriate)
int dbgio_write_str ( const char *  str)

Write a NUL-terminated string to the console.

Parameters
strThe string to write
Returns
Number of characters written on success, or -1 on failure (errno should be set as appropriate)