User:Pinged/TR18037

From OSDev.wiki
Jump to navigation Jump to search
This page is a work in progress.
This page may thus be incomplete. Its content may be changed in the near future.

What is TR18037?

TR18037 is a set of extensions to the C standard library to make low level programming, including OSDev, easier. The features it adds include:

  • iohw.h - standard functions for port-io
  • stdfix.h - builtin fixed point types
  • Named address spaces
  • Named register storage classes

iohw.h

This header defines standard functions and types for port-io, these include:

typedef /* ioindex type */ ioindex_t;
typedef /* ioreg type */ ioreg;

/* Read from a port */
unsigned iord (ioreg port);
unsigned long iordl (ioreg port);
unsigned iordbuf (ioreg port, ioindex_t idx);
unsigned long iordbufl (ioreg port, ioindex_t idx);

/* Write to a port */
void iowr (ioreg port, unsigned val);
void iowrl (ioreg port, unsigned long val);
void iowrbuf (ioreg port, ioindex_t idx, unsigned val);
void iowrbufl (ioreg dev, ioindex_t idx, unsigned long val);


/* These functions are pretty much useless to x86 programmers, but those for ARM
   and other architectures might find them useful.
 */

/* Do a bitwise and on a port */
void ioand (ioreg port, unsigned val);
void ioandl (ioreg port, unsigned long val);
void ioandbuf (ioreg port, ioindex_t idx, unsigned val);
void ioandbufl (ioreg port, ioindex_t idx, unsigned long val);

/* Do a bitwise or on a port */
void ioor (ioreg port, unsigned val);
void ioorl (ioreg port, unsigned long val);
void ioorbuf (ioreg port, ioindex_t idx, unsigned val);
void ioorbufl (ioreg port, ioindex_t idx, unsigned long val);

/* Do a bitwise xor on a port */
void ioxor (ioreg port, unsigned val);
void ioxorl (ioreg port, unsigned long val);
void ioxorbuf (ioreg port, ioindex_t idx, unsigned val);
void ioxorbufl (ioreg port, ioindex_t idx, unsigned long val);

/* These functions are kind of useless to anyone in kernel space (ring 0) but could
   be useful for anybody writing a user mode hardware driver in a microkernel.
 */

/* Allow access to a group of IO ports */
void iogroup_acquire (/* iogroup specifier */ group);
/* Disable access to a group of IO ports */
void iogroup_release (/* iogroup specifier */ group);
/* Map group a to group b */
void iogroup_map (/* iogroup specifier */ a, /* iogroup specifier */ b);

stdfix.h

TODO

Named address spaces

TODO

Named register storage class

TODO