WKern
Loading...
Searching...
No Matches
kio.h File Reference
#include <types/nums.h>

Go to the source code of this file.

Functions

void Kprintf (const char *fmt,...)
 Formatted output to the screen.
void Kputchar (char c)
 Outputs a single character to the screen at the current cursor position.
void Kcfp ()
 Clears the screen by filling the video memory with spaces.
void KputcharBackspace ()
 Handles backspace keypress by moving the cursor back and clearing the character.
void KprintHex (u32 num)
 Prints a 32-bit unsigned integer in hexadecimal format prefixed with "0x".
char Kgetkey ()
 Gets the next character from the keyboard buffer (blocking).
unsigned char ScancodeToAscii (unsigned char scancode)
void Kgetstr (char *str, int length)
 Reads a line of input from the keyboard (blocking).
void Kflush ()
 Flushes the keyboard controller input buffer.
void Outb (u16 port, u8 value)
 Write a byte to the specified I/O port.
u8 Inb (u16 port)
 Read a byte from the specified I/O port.
void Outw (u16 port, u16 value)
 Write a 16-bit word to the specified I/O port.
u16 Inw (u16 port)
 Read a 16-bit word from the specified I/O port.
void Cli ()
 Disable CPU interrupts (clear interrupt flag).
void Sti ()
 Enable CPU interrupts (set interrupt flag).
void Outl (u16 port, u32 val)
 Write a 32-bit value to the specified I/O port.
u32 Inl (u16 port)
 Read a 32-bit value from the specified I/O port.

Function Documentation

◆ Cli()

void Cli ( )
inline

Disable CPU interrupts (clear interrupt flag).

This is often used before critical sections to prevent preemption by interrupt handlers.

Definition at line 96 of file asm.c.

◆ Inb()

u8 Inb ( u16 port)
inline

Read a byte from the specified I/O port.

Parameters
portI/O port to read from
Returns
Byte value read

Definition at line 40 of file asm.c.

◆ Inl()

u32 Inl ( u16 port)
inline

Read a 32-bit value from the specified I/O port.

Parameters
portI/O port to read from
Returns
32-bit value read

Definition at line 84 of file asm.c.

◆ Inw()

u16 Inw ( u16 port)
inline

Read a 16-bit word from the specified I/O port.

Parameters
portI/O port to read from
Returns
16-bit value read

Definition at line 62 of file asm.c.

◆ Kcfp()

void Kcfp ( )

Clears the screen by filling the video memory with spaces.

Resets cursor position to the top-left corner (0,0).

Definition at line 28 of file printer.c.

◆ Kflush()

void Kflush ( )

Flushes the keyboard controller input buffer.

Reads and discards all unread bytes in the controller’s 0x60 port.

Definition at line 219 of file keyin.c.

◆ Kgetkey()

char Kgetkey ( )

Gets the next character from the keyboard buffer (blocking).

Returns
The next ASCII character from the input buffer.

Definition at line 169 of file keyin.c.

◆ Kgetstr()

void Kgetstr ( char * str,
int length )

Reads a line of input from the keyboard (blocking).

Handles basic line editing (Enter, Backspace, Delete).

Parameters
strDestination buffer
lengthMaximum buffer length (including null terminator)

Definition at line 186 of file keyin.c.

◆ Kprintf()

void Kprintf ( const char * fmt,
... )

Formatted output to the screen.

Supports format specifiers:

  • c : character
  • s : string
  • d : signed decimal integer
  • x : unsigned hexadecimal integer
  • %% : literal percent sign
Parameters
fmtFormat string
...Variable arguments corresponding to format specifiers

Definition at line 152 of file printer.c.

◆ KprintHex()

void KprintHex ( u32 num)

Prints a 32-bit unsigned integer in hexadecimal format prefixed with "0x".

Example output: 0xDEADBEEF

Parameters
numThe number to print

Definition at line 92 of file printer.c.

◆ Kputchar()

void Kputchar ( char c)

Outputs a single character to the screen at the current cursor position.

Supports newline ('
') to move cursor to the next line. Advances cursor position and scrolls screen if necessary.

Parameters
cCharacter to output

Definition at line 46 of file printer.c.

◆ KputcharBackspace()

void KputcharBackspace ( )

Handles backspace keypress by moving the cursor back and clearing the character.

Definition at line 71 of file printer.c.

◆ Outb()

void Outb ( u16 port,
u8 val )
inline

Write a byte to the specified I/O port.

Parameters
portI/O port to write to
valByte value to write

Definition at line 30 of file asm.c.

◆ Outl()

void Outl ( u16 port,
u32 val )
inline

Write a 32-bit value to the specified I/O port.

Parameters
portI/O port to write to
val32-bit value to write

Definition at line 74 of file asm.c.

◆ Outw()

void Outw ( u16 port,
u16 val )
inline

Write a 16-bit word to the specified I/O port.

Parameters
portI/O port to write to
val16-bit value to write

Definition at line 52 of file asm.c.

◆ ScancodeToAscii()

unsigned char ScancodeToAscii ( unsigned char scancode)

◆ Sti()

void Sti ( )
inline

Enable CPU interrupts (set interrupt flag).

This is used after a critical section to re-enable interrupts. NOPs are added for minor instruction delay.

Definition at line 104 of file asm.c.