From: John Hodge Date: Sun, 25 Sep 2011 03:39:39 +0000 (+0800) Subject: Renamed tpl_drv_* to api_drv_* (a more fitting name) X-Git-Tag: rel0.11~68 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=e6795eb552a6be88b7870dae14a958ab391bfae8;p=tpg%2Facess2.git Renamed tpl_drv_* to api_drv_* (a more fitting name) --- diff --git a/.gitignore b/.gitignore index 05ecdad8..c2b64113 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,5 @@ obj-*/ *.bin Makefile.user.cfg +QemuLog.txt +Screenshots/ diff --git a/Kernel/Doxyfile.api b/Kernel/Doxyfile.api index 18c15372..1f406f0e 100644 --- a/Kernel/Doxyfile.api +++ b/Kernel/Doxyfile.api @@ -574,12 +574,13 @@ INPUT = include/apidoc_mainpage.h \ include/iocache.h \ arch/archdoc.h \ include/apidoc/arch_x86.h \ - include/tpl_drv_common.h \ - include/tpl_drv_video.h \ - include/tpl_drv_terminal.h \ - include/tpl_drv_disk.h \ - include/tpl_drv_keyboard.h \ - include/tpl_drv_network.h + include/api_drv_common.h \ + include/api_drv_video.h \ + include/api_drv_terminal.h \ + include/api_drv_disk.h \ + include/api_drv_keyboard.h \ + include/api_drv_joystick.h \ + include/api_drv_network.h # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is @@ -596,7 +597,7 @@ INPUT_ENCODING = UTF-8 # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 -FILE_PATTERNS = tpl_drv_*.h +FILE_PATTERNS = api_drv_*.h #*.c *.h # The RECURSIVE tag can be used to turn specify whether or not subdirectories diff --git a/Kernel/drv/vterm.c b/Kernel/drv/vterm.c index 277d6c52..85ab0e16 100644 --- a/Kernel/drv/vterm.c +++ b/Kernel/drv/vterm.c @@ -5,9 +5,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/Kernel/drvutil.c b/Kernel/drvutil.c index 1bc6b785..e86f9a87 100644 --- a/Kernel/drvutil.c +++ b/Kernel/drvutil.c @@ -4,8 +4,8 @@ */ #define DEBUG 0 #include -#include -#include +#include +#include // === CODE === // --- Video Driver Helpers --- diff --git a/Kernel/include/api_drv_common.h b/Kernel/include/api_drv_common.h new file mode 100644 index 00000000..a8da516c --- /dev/null +++ b/Kernel/include/api_drv_common.h @@ -0,0 +1,136 @@ +/** + * \file api_drv_common.h + * \brief Common Driver Interface Definitions + * \author John Hodge (thePowersGang) + * + * \section Introduction + * There are two ways Acess drivers can communicate with userspace + * applications, both are through the VFS. The first is by exposing a + * device as a file buffer, the second is by sending commands via the + * ioctl() system call. + * All drivers in Acess must at least conform to the specifcation in this + * file (even if it is just implementing eTplDrv_IOCtl.DRV_IOCTL_TYPE and + * returning eTplDrv_Type.DRV_TYPE_NULL, however, doing so is discouraged) + * + * \section ioctls Core IOCtl calls + * As said, the core Acess driver specifcation defines specific IOCtl calls + * that all drivers should implement. The four core IOCtls (defined in + * ::eTplDrv_IOCtl) allow another binary (wether it be a user-mode application + * or another driver) to tell what type of device a driver provides, the + * basic identifcation of the driver (4 character ID and BCD version number) + * and be able to use externally standardised calls that may not have + * standardised call numbers. + * NOTE: All ioctl calls WILL return -1 if the driver ran into an error + * of its own fault while executing the call. If the user was at fault + * (e.g. by passing a bad buffer) the call will return -2. + * + * \section types Driver Types + * When the eTplDrv_IOCtl.DRV_IOCTL_TYPE call is made, the driver should + * return the relevant entry in the ::eTplDrv_Type enumeration that describes + * what sub-specifcation (and hence, what device type) it implements. + * These device types are described in their own files, which are liked + * from their entries in ::eTplDrv_Type. + */ +#ifndef _API_DRV_COMMON_H +#define _API_DR_COMMON_H + +/** + * \enum eTplDrv_IOCtl + * \brief Common IOCtl Calls + */ +enum eTplDrv_IOCtl { + /** + * ioctl(...) + * \brief Get driver type + * \return The relevant entry from ::eTplDrv_Type + */ + DRV_IOCTL_TYPE, + + /** + * ioctl(..., char *dest[32]) + * \brief Get driver identifier string + * \return 0 on no error + * + * This call sets the 32-byte array \a dest to the drivers 31 charater + * identifier. This identifier must be unique to the driver series. + */ + DRV_IOCTL_IDENT, + + /** + * ioctl(...) + * \brief Get driver version number + * \return 24-bit BCD version number (2.2.2) + * + * This call returns the 6-digit (2 major, 2 minor, 2 patch) version + * number of the driver. + */ + DRV_IOCTL_VERSION, + + /** + * ioctl(..., char *name) + * \brief Get a IOCtl call ID from a symbolic name + * \return ID number of the call, or 0 if not found + * + * This call allows user applications to not need to know the ID numbers + * of this driver's IOCtl calls by taking a string and returning the + * IOCtl call number associated with that method name. + */ + DRV_IOCTL_LOOKUP +}; + +/** + * \brief eTplDrv_IOCtl.DRV_IOCTL_LOOKUP names for the core IOCtls + * These are the official lookup names of the core calls + */ +#define DRV_IOCTLNAMES "type", "ident", "version", "lookup" + +/** + * \brief Helper macro for the base IOCtl calls + * \param _type Type number from eTplDrv_Type to return + * \param _ident String of max 32-characters that identifies this driver + * \param _version Driver's 8.8.8 BCD version number + * \param _ioctls Pointer to the IOCtls string array + * \warning If you have DEBUG enabled in the calling file, this function + * will do LEAVE()s before returning, so make sure that the + * IOCtl function is ENTER()ed when using debug with this macro + * + * Usage: (Id is the IOCtl call ID) + * \code + * switch(Id) + * { + * BASE_IOCTLS(DRV_TYPE_MISC, "Ident", 0x100, csaIOCtls) + * // Your IOCtls go here, starting at index 4 + * } + * \endcode + */ +#define BASE_IOCTLS(_type, _ident, _version, _ioctls) \ + case DRV_IOCTL_TYPE: LEAVE('i', (_type)); return (_type);\ + case DRV_IOCTL_IDENT: {\ + int tmp = ModUtil_SetIdent(Data, (_ident));\ + LEAVE('i', tmp); return tmp;\ + }\ + case DRV_IOCTL_VERSION: LEAVE('x', (_version)); return (_version);\ + case DRV_IOCTL_LOOKUP:{\ + int tmp = ModUtil_LookupString( _ioctls, (const char*)Data );\ + LEAVE('i', tmp);\ + return tmp;\ + } + +/** + * \enum eTplDrv_Type + * \brief Driver Types returned by DRV_IOCTL_TYPE + */ +enum eTplDrv_Type { + DRV_TYPE_NULL, //!< NULL Type - Custom Interface + DRV_TYPE_MISC, //!< Miscelanious Compilant - Supports the core calls + DRV_TYPE_TERMINAL, //!< Terminal - see api_drv_terminal.h + DRV_TYPE_VIDEO, //!< Video - see api_drv_video.h + DRV_TYPE_SOUND, //!< Audio + DRV_TYPE_DISK, //!< Disk - see api_drv_disk.h + DRV_TYPE_KEYBOARD, //!< Keyboard - see api_drv_keyboard.h + DRV_TYPE_MOUSE, //!< Mouse + DRV_TYPE_JOYSTICK, //!< Joystick / Gamepad + DRV_TYPE_NETWORK //!< Network Device - see api_drv_network.h +}; + +#endif diff --git a/Kernel/include/api_drv_disk.h b/Kernel/include/api_drv_disk.h new file mode 100644 index 00000000..68e5330d --- /dev/null +++ b/Kernel/include/api_drv_disk.h @@ -0,0 +1,184 @@ +/** + * \file api_drv_disk.h + * \brief Disk Driver Interface Definitions + * \author John Hodge (thePowersGang) + * + * \section Nomeclature + * All addreses are 64-bit counts of bytes from the logical beginning of + * the disk unless explicitly stated. + * + * \section dirs VFS Layout + * Disk drivers have a flexible directory layout. The root directory can + * contain subdirectories, with the only conditions being that all nodes + * must support ::eTplDrv_IOCtl with DRV_IOCTL_TYPE returning DRV_TYPE_DISK. + * And all file nodes representing disk devices (or partitions) and implemeting + * ::eTplDisk_IOCtl fully + * + * \section files Files + * When a read or write occurs on a normal file in the disk driver it will + * read/write the represented device. The accesses need not be aligned to + * the block size, however aligned reads/writes should be handled specially + * to improve speed (this can be aided by using ::DrvUtil_ReadBlock and + * ::DrvUtil_WriteBlock) + */ +#ifndef _API_DRV_DISK_H +#define _API_DRV_DISK_H + +#include + +/** + * \enum eTplDisk_IOCtl + * \brief Common Disk IOCtl Calls + * \extends eTplDrv_IOCtl + */ +enum eTplDisk_IOCtl { + /** + * ioctl(..., void) + * \brief Get the block size + * \return Size of a hardware block for this device + */ + DISK_IOCTL_GETBLOCKSIZE = 4, + + /** + * ioctl(..., tTplDisk_CacheRegion *RegionInfo) + * \brief Sets the cache importantce and protocol for a section of + * memory. + * \param RegionInfo Pointer to a region information structure + * \return Boolean failure + */ + DISK_IOCTL_SETCACHEREGION, + + /** + * ioctl(..., Uint64 *Info[2]) + * \brief Asks the driver to precache a region of disk. + * \param Region 64-bit Address and Size pair describing the area to cache + * \return Number of blocks cached + */ + DISK_IOCTL_PRECACHE, + + /** + * ioclt(..., Uint64 *Region[2]) + * \brief Asks to driver to flush the region back to disk + * \param Region 64-bit Address and Size pair describing the area to flush + * \note If Region[0] == -1 then the entire disk's cache is flushed + * \return Number of blocks flushed (or 0 for entire disk) + */ + DISK_IOCTL_FLUSH +}; + +/** + * \brief Describes the cache parameters of a region on the disk + */ +typedef struct sTplDisk_CacheRegion +{ + Uint64 Base; //!< Base of cache region + Uint64 Length; //!< Size of cache region + /** + * \brief Cache Protocol & Flags + * + * The low 4 bits denot the cache protocol to be used by the + * region (see ::eTplDisk_CacheProtocols for a list). + * The high 4 bits denote flags to apply to the cache (see + * ::eTplDisk_CacheFlags) + */ + Uint8 Flags; + Uint8 Priority; //!< Lower is a higher proritory + /** + * \brief Maximum size of cache, in blocks + * \note If CacheSize is zero, the implemenation defined limit is used + */ + Uint16 CacheSize; +} tTplDisk_CacheRegion; + +/** + * \brief Cache protocols to use + */ +enum eTplDisk_CacheProtocols +{ + /** + * \brief Don't cache the region + */ + + DISK_CACHEPROTO_DONTCACHE, + /** + * \brief Most recently used blocks cached + * \note This is the default action for undefined regions + */ + DISK_CACHEPROTO_RECENTLYUSED, + /** + * \brief Cache the entire region in memory + * + * This is a faster version of setting Length to CacheSize*BlockSize + */ + DISK_CACHEPROTO_FULLCACHE, + + /** + * \brief Cache only on demand + * + * Only cache when the ::DISK_IOCTL_PRECACHE IOCtl is used + */ + DISK_CACHEPROTO_EXPLICIT +}; + +/** + * \brief Flags for the cache + */ +enum eTplDisk_CacheFlags +{ + /** + * \brief Write all changes to the region straight back to media + */ + DISK_CACHEFLAG_WRITETHROUGH = 0x10 +}; + +/** + * \brief IOCtl name strings + */ +#define DRV_DISK_IOCTLNAMES "get_block_size","set_cache_region","set_precache" + +/** + * \name Disk Driver Utilities + * \{ + */ + +/** + * \brief Callback function type used by DrvUtil_ReadBlock and DrvUtil_WriteBlock + * \param Address Zero based block number to read + * \param Count Number of blocks to read + * \param Buffer Destination for read blocks + * \param Argument Argument provided in ::DrvUtil_ReadBlock and ::DrvUtil_WriteBlock + */ +typedef Uint (*tDrvUtil_Callback)(Uint64 Address, Uint Count, void *Buffer, Uint Argument); + +/** + * \brief Reads a range from a block device using aligned reads + * \param Start Base byte offset + * \param Length Number of bytes to read + * \param Buffer Destination for read data + * \param ReadBlocks Callback function to read a sequence of blocks + * \param BlockSize Size of an individual block + * \param Argument An argument to pass to \a ReadBlocks + * \return Number of bytes read + */ +extern Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer, + tDrvUtil_Callback ReadBlocks, Uint64 BlockSize, Uint Argument); +/** + * \brief Writes a range to a block device using aligned writes + * \param Start Base byte offset + * \param Length Number of bytes to write + * \param Buffer Destination for read data + * \param ReadBlocks Callback function to read a sequence of blocks + * \param WriteBlocks Callback function to write a sequence of blocks + * \param BlockSize Size of an individual block + * \param Argument An argument to pass to \a ReadBlocks and \a WriteBlocks + * \return Number of bytes written + */ +extern Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, void *Buffer, + tDrvUtil_Callback ReadBlocks, tDrvUtil_Callback WriteBlocks, + Uint64 BlockSize, Uint Argument); + +/** + * \} + */ + +#endif diff --git a/Kernel/include/api_drv_joystick.h b/Kernel/include/api_drv_joystick.h new file mode 100644 index 00000000..9225c5e4 --- /dev/null +++ b/Kernel/include/api_drv_joystick.h @@ -0,0 +1,139 @@ +/** + * \file api_drv_joystick + * \brief Joystick Driver Interface Definitions + * \author John Hodge (thePowersGang) + * + * \section dirs VFS Layout + * Joystick drivers define a single VFS node, that acts as a fixed size file. + * Reads from this file return the current state, writes are ignored. + * + * \section File Structure + * The device file must begin with a valid sJoystick_FileHeader structure. + * The file header is followed by \a NAxies instances of sJoystick_Axis, one + * for each axis. + * This is followed by \a NButtons boolean values (represented using \a Uint8), + * each representing the state of a single button (where 0 is unpressed, + * 0xFF is fully depressed - intermediate values are valid in the case of + * variable-pressure buttons) + */ +#ifndef _API_DRV_JOYSTICK_H +#define _API_DRV_JOYSTICK_H + +#include + +/** + * \enum eTplJoystick_IOCtl + * \brief Common Joystick IOCtl Calls + * \extends eTplDrv_IOCtl + */ +enum eTplJoystick_IOCtl { + /** + * ioctl(..., tJoystick_Callback *Callback) + * \brief Sets the callback + * \note Can be called from kernel mode only + * + * Sets the callback that is called when a event occurs (button or axis + * change). This function pointer must be in kernel mode (although, + * kernel->user or kernel->ring3driver abstraction functions can be used) + * + * Axis events depend on the axis limit, if non-zero, the callback fires + * if the cursor position changes. Otherwise it fires when the axis value + * (cursor accelleration) changes. + */ + JOY_IOCTL_SETCALLBACK = 4, + + /** + * ioctl(..., int *Argument) + * \brief Set the argument passed as the first parameter to the callback + * \note Kernel mode only + */ + JOY_IOCTL_SETCALLBACKARG, + + /** + * ioctl(..., tJoystickNumValue *) + * \brief Set maximum value for sJoystick_Axis.CurState + * \note If \a Value is equal to -1 (all bits set), the value is not changed + */ + JOY_IOCTL_GETSETAXISLIMIT, + + /** + * ioctl(..., tJoystickNumValue *) + * \brief Set the value of sJoystick_Axis.CurState + * \note If \a Value is equal to -1 (all bits set), the value is not changed + */ + JOY_IOCTL_GETSETAXISPOSITION, + + /** + * ioctl(..., tJoystickNumValue *) + * \brief Set axis flags + * \note If \a Value is equal to -1 (all bits set), the value is not changed + * \todo Define flag values + */ + JOY_IOCTL_GETSETAXISFLAGS, + + /** + * ioctl(..., tJoystickNumValue *) + * \brief Set Button Flags + * \note If \a Value is equal to -1 (all bits set), the value is not changed + * \todo Define flag values + */ + JOY_IOCTL_GETSETBUTTONFLAGS, +}; + +#define DRV_JOY_IOCTLNAMES "set_callback", "set_callback_arg", "getset_axis_limit", "getset_axis_position", \ + "getset_axis_flags", "getset_button_flags" + +// === TYPES === +typedef struct sJoystick_NumValue tJoystick_NumValue; +typedef struct sJoystick_FileHeader tJoystick_FileHeader; +typedef struct sJoystick_Axis tJoystick_Axis; + +/** + * \brief Number/Value pair for joystick IOCtls + */ +struct sJoystick_NumValue +{ + int Num; //!< Axis/Button number + int Value; //!< Value (see IOCtl defs for meaning) +}; + +/** + * \brief Callback type for JOY_IOCTL_SETCALLBACK + * \param Ident Ident value passed to JOY_IOCTL_SETCALLBACK + * + */ +typedef void (*tJoystick_Callback)(int Ident, int bIsAxis, int Num, int Delta); + +/** + * \struct sJoystick_FileHeader + */ +struct sJoystick_FileHeader +{ + Uint16 NAxies; //!< Number of Axies + Uint16 NButtons; //!< Number of buttons +}; + +/** + * \brief Axis Definition in file data + * + * Describes the current state of an axis on the joystick. + * \a CursorPos is between zero and the current limit set by the + * JOY_IOCTL_GETSETAXISLIMIT IOCtl, while \a CurValue indicates the + * current position of the joystick axis. This is defined to be between + * \a MinValue and \a MaxValue. + */ +struct sJoystick_Axis +{ + Sint16 MinValue; //!< Minumum value for \a CurValue + Sint16 MaxValue; //!< Maximum value for \a CurValue + Sint16 CurValue; //!< Current value (joystick position) + Uint16 CursorPos; //!< Current state (cursor position) +}; + +#define JOY_INFOSTRUCT(_naxies, _nbuttons) struct { \ + Uint16 NAxies, NButtons;\ + tJoystick_Axis Axies[_naxies];\ + Uint16 Buttons[_nbuttons];\ + } + +#endif diff --git a/Kernel/include/api_drv_keyboard.h b/Kernel/include/api_drv_keyboard.h new file mode 100644 index 00000000..8aa32634 --- /dev/null +++ b/Kernel/include/api_drv_keyboard.h @@ -0,0 +1,119 @@ +/** + * \file api_drv_keyboard.h + * \brief Keyboard Driver Interface Definitions + * \author John Hodge (thePowersGang) + * + * \section dirs VFS Layout + * Keyboard drivers consist of only a single node, which is a normal file + * node with a size of zero. All reads and writes to this node are ignored + * (tVFS_Node.Read and tVFS_Node.Write are NULL) + */ +#ifndef _API_DRV_KEYBOARD_H +#define _API_KEYBOARD_H + +#include + +/** + * \enum eTplKeyboard_IOCtl + * \brief Common Keyboard IOCtl Calls + * \extends eTplDrv_IOCtl + */ +enum eTplKeyboard_IOCtl { + /** + * ioctl(..., int *Rate) + * \brief Get/Set Repeat Rate + * \param Rate New repeat rate (pointer) + * \return Current/New Repeat rate + * + * Gets/Set the repeat rate (actually the time in miliseconds between + * repeats) of a held down key. + * If the rate is set to zero, repeating will be disabled. + */ + KB_IOCTL_REPEATRATE = 4, + + /** + * ioctl(..., int *Delay) + * \brief Get/Set Repeat Delay + * \param Delay New repeat delay (pointer) + * \return Current/New repeat delay + * + * Gets/Set the time in miliseconds before a key starts repeating + * after a key is pressed. + * Setting the delay to a negative number will cause the function to + * return -1 + */ + KB_IOCTL_REPEATDELAY, + + + /** + * ioctl(..., tKeybardCallback *Callback) + * \brief Sets the callback + * \note Can be called from kernel mode only + * + * Sets the function to be called when a key event occurs (press, release + * or repeat). This function pointer must be in kernel mode (although, + * kernel->user or kernel->ring3driver abstraction functions can be used) + */ + KB_IOCTL_SETCALLBACK +}; + +#define DRV_KEYBAORD_IOCTLNAMES "getset_repeat_rate", "getset_repeat_delay", "set_callback" + +/** + * \brief Callback type for KB_IOCTL_SETCALLBACK + * \param Key Unicode character code for the pressed key (with bit 31 + * set if the key is released) + */ +typedef void (*tKeybardCallback)(Uint32 Key); + +/** + * \brief Symbolic key codes + * + * These key codes represent non-pritable characters and are placed above + * the Unicode character space. + * If the using driver recieves a key code with the 31st bit set, it means + * that that key has been released. + */ +enum eTplKeyboard_KeyCodes { + KEY_ESC = 0x1B, //!< Escape Character + + KEY_NP_MASK = 0x40000000, //! Mask for non-printable characters + + /** + * \name Special Keys + * \brief These keys are usually used on their own + * \{ + */ + KEY_CAPSLOCK, + KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, + KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, + KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, + KEY_NUMLOCK, KEY_SCROLLLOCK, + KEY_HOME, KEY_END, KEY_INS, KEY_DEL, + KEY_PAUSE, KEY_BREAK, + KEY_PGUP, KEY_PGDOWN, + KEY_KPENTER, KEY_KPSLASH, KEY_KPMINUS, KEY_KPPLUS, KEY_KPSTAR, + KEY_KPHOME, KEY_KPUP, KEY_KPPGUP, KEY_KPLEFT, KEY_KP5, KEY_KPRIGHT, + KEY_KPEND, KEY_KPDOWN, KEY_KPPGDN, KEY_KPINS, KEY_KPDEL, + KEY_WIN, KEY_MENU, + /** + * \} + */ + + // Modifiers + /** + * \name Modifiers + * \brief These keye usually alter the character stream sent to the user + * \{ + */ + KEY_MODIFIERS = 0x60000000, + KEY_LCTRL, KEY_RCTRL, + KEY_LALT, KEY_RALT, + KEY_LSHIFT, KEY_RSHIFT, + /** + * \} + */ +}; + + +#endif diff --git a/Kernel/include/api_drv_network.h b/Kernel/include/api_drv_network.h new file mode 100644 index 00000000..6cb8c349 --- /dev/null +++ b/Kernel/include/api_drv_network.h @@ -0,0 +1,56 @@ +/** + * \file api_drv_network.h + * \brief Network Interface Driver Interface Definitions + * + * \section dirs VFS Layout + * All network drivers must have the following basic VFS structure + * The root of the driver will only contain files that are named from zero + * upwards that represent the present network adapters that this driver + * controls. All VFS nodes must implement ::eTplDrv_IOCtl with + * DRV_IOCTL_TYPE returning DRV_TYPE_NETWORK. + * The adapter nodes must also implement ::eTplNetwork_IOCtl fully + * (unless it is noted in the ::eTplNetwork_IOCtl documentation that a + * call is optional) + * + * \section files Adapter Files + * \subsection Reading + * When an adapter file is read from, the driver will block the reading + * thread until a packet arrives (if there is not already an unhandled + * packet in the queue) this will then be read into the destination buffer. + * If the packet does not fit in the buffer, the end of it is discarded. + * Likewise, if the packet does not completely fill the buffer, the call + * will still read to the buffer and then return the size of the packet. + * \subsection Writing + * When an adapter is written to, the data written is encoded as a packet + * and sent, if the data is not the correct size to be sent (if the packet + * is too small, or if it is too large) -1 should be returned and the packet + * will not be sent. + */ +#ifndef _API_DRV_NETWORK_H +#define _API_DRV_NETWORK_H + +#include + +/** + * \enum eTplNetwork_IOCtl + * \brief Common Network IOCtl Calls + * \extends eTplDrv_IOCtl + */ +enum eTplNetwork_IOCtl { + /** + * ioctl(..., Uint8 *MAC[6]) + * \brief Get the MAC address of the interface + * \return 1 on success, 0 if the file is the root, -1 on error + * + * Copies the six byte Media Access Control (MAC) address of the + * adapter to the \a MAC array. + */ + NET_IOCTL_GETMAC = 4 +}; + +/** + * \brief IOCtl name strings for use with eTplDrv_IOCtl.DRV_IOCTL_LOOKUP + */ +#define DRV_NETWORK_IOCTLNAMES "get_mac_addr" + +#endif diff --git a/Kernel/include/api_drv_terminal.h b/Kernel/include/api_drv_terminal.h new file mode 100644 index 00000000..7e53bbc3 --- /dev/null +++ b/Kernel/include/api_drv_terminal.h @@ -0,0 +1,157 @@ +/** + * \file api_drv_terminal.h + * \brief Terminal Driver Interface Definitions +*/ +#ifndef _API_DRV_TERMINAL_H +#define _API_DRV_TERMINAL_H + +#include + +/** + * \brief Common Terminal IOCtl Calls + * \extends eTplDrv_IOCtl + */ +enum eTplTerminal_IOCtl { + /** + * ioctl(..., int *mode) + * \brief Get/Set the current video mode type + * \param mode Pointer to an integer with the new mode number (or NULL) + * If \a mode is non-NULL the current terminal mode is changed/updated + * to the mode indicated by \a *mode + * \note See ::eTplTerminal_Modes + * \return Current/new terminal mode + */ + TERM_IOCTL_MODETYPE = 4, + + /** + * ioctl(..., int *width) + * \brief Get/set the display width + * \param width Pointer to an integer containing the new width (or NULL) + * \return Current/new width + * + * If \a width is non-NULL the current width is updated (but is not + * applied until ::TERM_IOCTL_MODETYPE is called with \a mode non-NULL. + */ + TERM_IOCTL_WIDTH, + + /** + * ioctl(..., int *height) + * \brief Get/set the display height + * \param height Pointer to an integer containing the new height + * \return Current height + * + * If \a height is non-NULL the current height is updated (but is not + * applied until ::TERM_IOCTL_MODETYPE is called with a non-NULL \a mode. + */ + TERM_IOCTL_HEIGHT, + + /** + * ioctl(..., tTerm_IOCtl_Mode *info) + * \brief Queries the current driver about it's native modes + * \param info A pointer to a ::tTerm_IOCtl_Mode with \a ID set to + * the mode index (or NULL) + * \return Number of modes + * + * If \a info is NULL, the number of avaliable vative display modes + * is returned. These display modes will have sequential ID numbers + * from zero up to this value. + * + * \note The id field of \a info is not for use with ::TERM_IOCTL_MODETYPE + * This field is just for indexing the mode to get its information. + */ + TERM_IOCTL_QUERYMODE, + + /** + * ioctl(...) + * \brief Forces the current terminal to be shown + */ + TERM_IOCTL_FORCESHOW, + + /** + * ioctl(...) + * \brief Returns the current text cursor position + * \return Cursor position (as X+Y*Width) + */ + TERM_IOCTL_GETCURSOR +}; + +/** + * \brief Virtual Terminal Mode + * Describes a VTerm mode to the caller of ::TERM_IOCTL_QUERYMODE + */ +typedef struct sTerm_IOCtl_Mode +{ + short ID; //!< Zero Based index of mode + short DriverID; //!< Driver's ID number (from ::tVideo_IOCtl_Mode) + Uint16 Height; //!< Height + Uint16 Width; //!< Width + Uint8 Depth; //!< Bits per cell + struct { + unsigned bText: 1; //!< Text Mode marker + unsigned unused: 7; + }; +} tTerm_IOCtl_Mode; + +/** + * \brief Terminal Modes + */ +enum eTplTerminal_Modes { + /** + * \brief UTF-8 Text Mode + * Any writes to the terminal file are treated as UTF-8 encoded + * strings and reads will also return UTF-8 strings. + */ + TERM_MODE_TEXT, + + /** + * \brief 32bpp Framebuffer + * Writes to the terminal file will write to the framebuffer. + * Reads will return UTF-32 characters + */ + TERM_MODE_FB, + + /** + * \brief 32bpp 2D Accellerated mode + * Writes to the terminal file will be read as a command stream + * defined in ::eTplTerminal_2D_Commands + */ + TERM_MODE_2DACCEL, + + /** + * \brief OpenGL 2D/3D + * Writes to the terminal file will send 3D commands + * Reads will return UTF-32 characters + * \note May or may not stay in the spec + */ + TERM_MODE_3D, + + /** + * \brief Number of terminal modes + */ + NUM_TERM_MODES +}; + +/** + * \brief 2D Command IDs + * \todo Complete this structure + * + * Command IDs for when the terminal type is eTplTerminal_Modes.TERM_MODE_2DACCEL + */ +enum eTplTerminal_2D_Commands +{ + /** + * \brief No Operation - Used for padding + */ + TERM_2DCMD_NOP, + + /** + * (Uint16 X, Y, W, H, Uint32 Data[]) + * \brief Blits a bitmap to the display + * \param X,Y Coordinates of Top-Left corner + * \param W,H Dimensions + * \param Data 32-bpp pixel data + */ + TERM_2DCMD_PUSH +}; + +#endif diff --git a/Kernel/include/api_drv_video.h b/Kernel/include/api_drv_video.h new file mode 100644 index 00000000..a4eb46c0 --- /dev/null +++ b/Kernel/include/api_drv_video.h @@ -0,0 +1,340 @@ +/** + * \file api_drv_video.h + * \brief Video Driver Interface Definitions + * \note For AcessOS Version 1 + * + * Video drivers extend the common driver interface api_drv_common.h + * and must support _at least_ the IOCtl numbers defined in this file + * to be compatable with Acess. + * + * \section IOCtls + * As said, a compatable driver must implement these calls correctly, + * but they may choose not to allow direct user access to the framebuffer. + * + * \section Screen Contents + * Writes to the driver's file while in component colour modes + * must correspond to a change of the contents of the screen. The framebuffer + * must start at offset 0 in the file. + * Reading from the screen must either return zero, or read from the + * framebuffer. + * + * \section Mode Support + * All video drivers must support at least one text mode (Mode #0) + * For each graphics mode the driver exposes, there must be a corresponding + * text mode with the same resolution, this mode will be used when the + * user switches to a text Virtual Terminal while in graphics mode. + */ +#ifndef _API_DRV_VIDEO_H +#define _API_DRV_VIDEO_H + +#include + +/** + * \enum eTplVideo_IOCtl + * \brief Common Video IOCtl Calls + * \extends eTplDrv_IOCtl + */ +enum eTplVideo_IOCtl { + /** + * ioctl(..., int *mode) + * \brief Get/Set Mode + * \return Current mode ID or -1 on error + * + * If \a mode is non-NULL, the current video mode is set to \a *mode. + * This updated ID is then returned to the user. + */ + VIDEO_IOCTL_GETSETMODE = 4, + + /** + * ioctl(..., tVideo_IOCtl_Mode *info) + * \brief Find a matching mode + * \return 1 if a mode was found, 0 otherwise + * + * Using avaliable modes matching the \a bpp and \a flags fields + * set the \a id field to the mode id of the mode with the closest + * \a width and \a height. + */ + VIDEO_IOCTL_FINDMODE, + + /** + * ioctl(..., tVideo_IOCtl_Mode *info) + * \brief Get mode info + * \return 1 if the mode exists, 0 otherwise + * + * Set \a info's fields to the mode specified by the \a id field. + */ + VIDEO_IOCTL_MODEINFO, + + /** + * ioctl(..., int *NewFormat) + * \brief Switches between Text, Framebuffer and 3D modes + * \param NewFormat Pointer to the new format code (see eTplVideo_BufFormats) + * \return Original format + * + * Enabes and disables the video text mode, changing the behavior of + * writes to the device file. + */ + VIDEO_IOCTL_SETBUFFORMAT, + + /** + * ioctl(..., tVideo_IOCtl_Pos *pos) + * \brief Sets the cursor position + * \return Boolean success + * + * Set the text mode cursor position (if it is supported) + * If the \a pos is set to (-1,-1) the cursor is hidden, otherwise + * \a pos MUST be within the current screen size (as given by the + * current mode's tVideo_IOCtl_Mode.width and tVideo_IOCtl_Mode.height + * fields). + */ + VIDEO_IOCTL_SETCURSOR, + + /** + * ioctl(..., tVideo_IOCtl_Bitmap *Image) + * \brief Sets the cursor image + * \return Boolean success + * + * Sets the graphics mode cursor image + */ + VIDEO_IOCTL_SETCURSORBITMAP +}; +#define DRV_VIDEO_IOCTLNAMES "getset_mode", "find+mode", "mode_info", "set_buf_format", "set_cursor", "set_cursor_bitmap" + +/** + * \brief Mode Structure used in IOCtl Calls + * + * Defines a video mode supported by (or requested of) this driver (depending + * on what ioctl call is used) + */ +typedef struct sVideo_IOCtl_Mode +{ + short id; //!< Mode ID + Uint16 width; //!< Width + Uint16 height; //!< Height + Uint8 bpp; //!< Bits per Unit (Character or Pixel, depending on \a flags) + Uint8 flags; //!< Mode Flags +} tVideo_IOCtl_Mode; + +/** + * \brief Buffer Format Codes + */ +enum eTplVideo_BufFormats +{ + /** + * \brief Text Mode + * + * The device file presents itself as an array of ::tVT_Char + * each describing a character cell on the screen. + * These cells are each \a giVT_CharWidth pixels wide and + * \a giVT_CharHeight high. + */ + VIDEO_BUFFMT_TEXT, + /** + * \brief Framebuffer Mode + * + * The device file presents as an array of 32-bpp pixels describing + * the entire screen. The format of a single pixel is in xRGB format + * (top 8 bits ignored, next 8 bits red, next 8 bits green and + * the bottom 8 bits blue) + */ + VIDEO_BUFFMT_FRAMEBUFFER, + /** + * \brief 2D Accelerated Mode + * + * The device file acts as a character device, accepting a stream of + * commands described in eTplVideo_2DCommands when written to. + */ + VIDEO_BUFFMT_2DSTREAM, + /** + * \brief 3D Accelerated Mode + * + * The device file acts as a character device, accepting a stream of + * commands described in eTplVideo_3DCommands when written to. + */ + VIDEO_BUFFMT_3DSTREAM +}; + +/** + * \brief 2D Accellerated Video Commands + * + * Commands passed in the command stream for ::VIDEO_BUFFMT_2DSTREAM + */ +enum eTplVideo_2DCommands +{ + /** + * \brief No Operation + */ + VIDEO_2DOP_NOP, + /** + * \brief Fill a region + * \param X Uint16 - Leftmost pixels of the region + * \param Y Uint16 - Topmost pixels of the region + * \param W Uint16 - Width of the region + * \param H Uint16 - Height of the region + * \param Colour Uint32 - Value to fill with + */ + VIDEO_2DOP_FILL, + /** + * \brief Copy a region from one part of the framebuffer to another + * \param DestX Uint16 - Leftmost pixels of the destination + * \param DestY Uint16 - Topmost pixels of the destination + * \param SrcX Uint16 - Leftmost pixels of the source + * \param SrcY Uint16 - Topmost pixels of the source + * \param Width Uint16 - Width of the region + * \param Height Uint16 - Height of the region + */ + VIDEO_2DOP_BLIT, + + + /** + * \brief Copy a region from video memory to the framebuffer + */ + VIDEO_2DOP_BLITBUF, + + /** + * \brief Copy and scale a region from video memory to the framebuffer + */ + VIDEO_2DOP_BLITSCALEBUF, + + NUM_VIDEO_2DOPS +}; + +/** + * \brief Describes a position in the video framebuffer + */ +typedef struct sVideo_IOCtl_Pos +{ + Sint16 x; //!< X Coordinate + Sint16 y; //!< Y Coordinate +} tVideo_IOCtl_Pos; + +/** + * \brief Bitmap object (out of band image) + */ +typedef struct sVideo_IOCtl_Bitmap +{ + Sint16 W; //!< Width of image + Sint16 H; //!< Height of image + Sint16 XOfs; //!< X Offset of center + Sint16 YOfs; //!< Y Offset of center + Uint32 Data[]; //!< Image data (ARGB array) +} tVideo_IOCtl_Bitmap; + +/** + * \brief Virtual Terminal Representation of a character + */ +typedef struct sVT_Char +{ + Uint32 Ch; //!< UTF-32 Character + union { + struct { + Uint16 BGCol; //!< 12-bit Foreground Colour + Uint16 FGCol; //!< 12-bit Background Colour + }; + Uint32 Colour; //!< Compound colour for ease of access + }; +} tVT_Char; + +/** + * \name Basic builtin colour definitions + * \{ + */ +#define VT_COL_BLACK 0x0000 +#define VT_COL_GREY 0x0888 +#define VT_COL_LTGREY 0x0CCC +#define VT_COL_WHITE 0x0FFF +/** + * \} + */ + +//! \brief Defines the width of a rendered character +extern int giVT_CharWidth; +//! \brief Defines the height of a rendered character +extern int giVT_CharHeight; +/** + * \brief Driver helper that renders a character to a buffer + * \param Codepoint Unicode character to render + * \param Buffer Buffer to render to + * \param Depth Bit depth of the destination buffer + * \param Pitch Number of bytes per line + * \param BGC 32-bit Background Colour + * \param FGC 32-bit Foreground Colour + * + * This function is provided to help video drivers to support a simple + * text mode by keeping the character rendering abstracted from the driver, + * easing the driver development and reducing code duplication. + */ +extern void VT_Font_Render(Uint32 Codepoint, void *Buffer, int Depth, int Pitch, Uint32 BGC, Uint32 FGC); +/** + * \fn Uint32 VT_Colour12to24(Uint16 Col12) + * \brief Converts a colour from 12bpp to 24bpp + * \param Col12 12-bpp input colour + * \return Expanded 32-bpp (24-bit colour) version of \a Col12 + */ +extern Uint32 VT_Colour12to24(Uint16 Col12); +/** + * \brief Converts a colour from 12bpp to 14bpp + * \param Col12 12-bpp input colour + * \return 15 bits per pixel value + */ +extern Uint16 VT_Colour12to15(Uint16 Col12); +/** + * \brief Converts a colour from 12bpp to 32bpp + * \param Col12 12-bpp input colour + * \param Depth Desired bit depth + * \return \a Depth bit number, denoting Col12 + * + * Expands the source colour into a \a Depth bits per pixel representation. + * The colours are expanded with preference to Green, Blue and Red in that order + * (so, green gets the first spare pixel, blue gets the next, and red never gets + * the spare). \n + * The final bit of each component is used to fill the lower bits of the output. + */ +extern Uint32 VT_Colour12toN(Uint16 Col12, int Depth); + +/** + * \brief Handlers for eTplVideo_2DCommands + */ +typedef struct sDrvUtil_Video_2DHandlers +{ + /** + * \brief No Operation, Ignored + * \see VIDEO_2DOP_NOP + */ + void *Nop; + /** + * \brief Fill a buffer region + * \param X Lefthand edge + * \param Y Top edge + * \param W Width + * \param H Height + * \param Colour Colour to fill with + * \see VIDEO_2DOP_FILL + */ + void (*Fill)(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour); + /** + * \brief Fill a buffer region + * \param DestX Lefthand edge of destination + * \param DestY Top edge of destination + * \param SrcX Lefthand edge of source + * \param SrcY Top edge of source + * \param W Width + * \param H Height + * \see VIDEO_2DOP_BLIT + */ + void (*Blit)(void *Ent, Uint16 DestX, Uint16 DestY, Uint16 SrcX, Uint16 SrcY, Uint16 W, Uint16 H); +} tDrvUtil_Video_2DHandlers; + +/** + * \brief Handle a 2D operation stream for a driver + * \param Ent Value to pass to handlers + * \param Buffer Stream buffer + * \param Length Length of stream + * \param Handlers Handlers to use for the stream + * \param SizeofHandlers Size of \a tDrvUtil_Video_2DHandlers according + * to the driver. Used as version control and error avoidence. + */ +extern Uint64 DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length, + tDrvUtil_Video_2DHandlers *Handlers, int SizeofHandlers); + +#endif diff --git a/Kernel/include/apidoc_mainpage.h b/Kernel/include/apidoc_mainpage.h index ca6a5da7..0060bafa 100644 --- a/Kernel/include/apidoc_mainpage.h +++ b/Kernel/include/apidoc_mainpage.h @@ -46,7 +46,7 @@ * capabilities for the the user. * * The device driver interfaces are all based on the core specifcation - * in tpl_drv_common.h (Common Device Driver definitions). + * in api_drv_common.h (Common Device Driver definitions). * The following subsections define the various specific types of driver * interfaces. These definitions only define the bare minimum of what the * driver must implement, if the driver author so wants to, they can add @@ -58,7 +58,7 @@ * identify itself as a miscelanious device by returning DRV_TYPE_MISC * from \ref DRV_IOCTL_TYPE. * A misc device must at least implement the IOCtl calls defined in the - * \ref tpl_drv_common.h "Common Device Driver definitions", allowing it + * \ref api_drv_common.h "Common Device Driver definitions", allowing it * to be identified easily by the user and for interfacing programs to * utilise the DRV_IOCTL_LOOKUP call. * @@ -67,7 +67,7 @@ * which is not yet fully standardised, so should be ignored). * The driver will contain only one VFS node, that exposes the video * framebuffer (this may not be the true framebuffer, to allow for double-buffering) - * to the user. See the full documentation in tpl_drv_video.h for the + * to the user. See the full documentation in api_drv_video.h for the * complete specifcation. * * \subsection drv_disk Disk/Storage Devices @@ -78,10 +78,10 @@ * The functions DrvUtil_ReadBlock and DrvUtil_WriteBlock are provided * to storage drivers to assist in handling non-alinged reads and writes. * - * \see tpl_drv_common.h Common Spec. - * \see tpl_drv_video.h Video Device Spec. - * \see tpl_drv_keyboard.h Keyboard Device Spec. - * \see tpl_drv_disk.h Disk/Storage Device Spec. - * \see tpl_drv_network.h Network Device Spec. - * \see tpl_drv_terminal.h Virtual Terminal Spec. + * \see api_drv_common.h Common Spec. + * \see api_drv_video.h Video Device Spec. + * \see api_drv_keyboard.h Keyboard Device Spec. + * \see api_drv_disk.h Disk/Storage Device Spec. + * \see api_drv_network.h Network Device Spec. + * \see api_drv_terminal.h Virtual Terminal Spec. */ diff --git a/Kernel/include/tpl_drv_common.h b/Kernel/include/tpl_drv_common.h deleted file mode 100644 index ebc9130d..00000000 --- a/Kernel/include/tpl_drv_common.h +++ /dev/null @@ -1,136 +0,0 @@ -/** - * \file tpl_drv_common.h - * \brief Common Driver Interface Definitions - * \author John Hodge (thePowersGang) - * - * \section Introduction - * There are two ways Acess drivers can communicate with userspace - * applications, both are through the VFS. The first is by exposing a - * device as a file buffer, the second is by sending commands via the - * ioctl() system call. - * All drivers in Acess must at least conform to the specifcation in this - * file (even if it is just implementing eTplDrv_IOCtl.DRV_IOCTL_TYPE and - * returning eTplDrv_Type.DRV_TYPE_NULL, however, doing so is discouraged) - * - * \section ioctls Core IOCtl calls - * As said, the core Acess driver specifcation defines specific IOCtl calls - * that all drivers should implement. The four core IOCtls (defined in - * ::eTplDrv_IOCtl) allow another binary (wether it be a user-mode application - * or another driver) to tell what type of device a driver provides, the - * basic identifcation of the driver (4 character ID and BCD version number) - * and be able to use externally standardised calls that may not have - * standardised call numbers. - * NOTE: All ioctl calls WILL return -1 if the driver ran into an error - * of its own fault while executing the call. If the user was at fault - * (e.g. by passing a bad buffer) the call will return -2. - * - * \section types Driver Types - * When the eTplDrv_IOCtl.DRV_IOCTL_TYPE call is made, the driver should - * return the relevant entry in the ::eTplDrv_Type enumeration that describes - * what sub-specifcation (and hence, what device type) it implements. - * These device types are described in their own files, which are liked - * from their entries in ::eTplDrv_Type. - */ -#ifndef _TPL_COMMON_H -#define _TPL_COMMON_H - -/** - * \enum eTplDrv_IOCtl - * \brief Common IOCtl Calls - */ -enum eTplDrv_IOCtl { - /** - * ioctl(...) - * \brief Get driver type - * \return The relevant entry from ::eTplDrv_Type - */ - DRV_IOCTL_TYPE, - - /** - * ioctl(..., char *dest[32]) - * \brief Get driver identifier string - * \return 0 on no error - * - * This call sets the 32-byte array \a dest to the drivers 31 charater - * identifier. This identifier must be unique to the driver series. - */ - DRV_IOCTL_IDENT, - - /** - * ioctl(...) - * \brief Get driver version number - * \return 24-bit BCD version number (2.2.2) - * - * This call returns the 6-digit (2 major, 2 minor, 2 patch) version - * number of the driver. - */ - DRV_IOCTL_VERSION, - - /** - * ioctl(..., char *name) - * \brief Get a IOCtl call ID from a symbolic name - * \return ID number of the call, or 0 if not found - * - * This call allows user applications to not need to know the ID numbers - * of this driver's IOCtl calls by taking a string and returning the - * IOCtl call number associated with that method name. - */ - DRV_IOCTL_LOOKUP -}; - -/** - * \brief eTplDrv_IOCtl.DRV_IOCTL_LOOKUP names for the core IOCtls - * These are the official lookup names of the core calls - */ -#define DRV_IOCTLNAMES "type", "ident", "version", "lookup" - -/** - * \brief Helper macro for the base IOCtl calls - * \param _type Type number from eTplDrv_Type to return - * \param _ident String of max 32-characters that identifies this driver - * \param _version Driver's 8.8.8 BCD version number - * \param _ioctls Pointer to the IOCtls string array - * \warning If you have DEBUG enabled in the calling file, this function - * will do LEAVE()s before returning, so make sure that the - * IOCtl function is ENTER()ed when using debug with this macro - * - * Usage: (Id is the IOCtl call ID) - * \code - * switch(Id) - * { - * BASE_IOCTLS(DRV_TYPE_MISC, "Ident", 0x100, csaIOCtls) - * // Your IOCtls go here, starting at index 4 - * } - * \endcode - */ -#define BASE_IOCTLS(_type, _ident, _version, _ioctls) \ - case DRV_IOCTL_TYPE: LEAVE('i', (_type)); return (_type);\ - case DRV_IOCTL_IDENT: {\ - int tmp = ModUtil_SetIdent(Data, (_ident));\ - LEAVE('i', tmp); return tmp;\ - }\ - case DRV_IOCTL_VERSION: LEAVE('x', (_version)); return (_version);\ - case DRV_IOCTL_LOOKUP:{\ - int tmp = ModUtil_LookupString( _ioctls, (const char*)Data );\ - LEAVE('i', tmp);\ - return tmp;\ - } - -/** - * \enum eTplDrv_Type - * \brief Driver Types returned by DRV_IOCTL_TYPE - */ -enum eTplDrv_Type { - DRV_TYPE_NULL, //!< NULL Type - Custom Interface - DRV_TYPE_MISC, //!< Miscelanious Compilant - Supports the core calls - DRV_TYPE_TERMINAL, //!< Terminal - see tpl_drv_terminal.h - DRV_TYPE_VIDEO, //!< Video - see tpl_drv_video.h - DRV_TYPE_SOUND, //!< Audio - DRV_TYPE_DISK, //!< Disk - see tpl_drv_disk.h - DRV_TYPE_KEYBOARD, //!< Keyboard - see tpl_drv_keyboard.h - DRV_TYPE_MOUSE, //!< Mouse - DRV_TYPE_JOYSTICK, //!< Joystick / Gamepad - DRV_TYPE_NETWORK //!< Network Device - see tpl_drv_network.h -}; - -#endif diff --git a/Kernel/include/tpl_drv_disk.h b/Kernel/include/tpl_drv_disk.h deleted file mode 100644 index 47efb049..00000000 --- a/Kernel/include/tpl_drv_disk.h +++ /dev/null @@ -1,184 +0,0 @@ -/** - * \file tpl_drv_disk.h - * \brief Disk Driver Interface Definitions - * \author John Hodge (thePowersGang) - * - * \section Nomeclature - * All addreses are 64-bit counts of bytes from the logical beginning of - * the disk unless explicitly stated. - * - * \section dirs VFS Layout - * Disk drivers have a flexible directory layout. The root directory can - * contain subdirectories, with the only conditions being that all nodes - * must support ::eTplDrv_IOCtl with DRV_IOCTL_TYPE returning DRV_TYPE_DISK. - * And all file nodes representing disk devices (or partitions) and implemeting - * ::eTplDisk_IOCtl fully - * - * \section files Files - * When a read or write occurs on a normal file in the disk driver it will - * read/write the represented device. The accesses need not be aligned to - * the block size, however aligned reads/writes should be handled specially - * to improve speed (this can be aided by using ::DrvUtil_ReadBlock and - * ::DrvUtil_WriteBlock) - */ -#ifndef _TPL_DRV_DISK_H -#define _TPL_DRV_DISK_H - -#include - -/** - * \enum eTplDisk_IOCtl - * \brief Common Disk IOCtl Calls - * \extends eTplDrv_IOCtl - */ -enum eTplDisk_IOCtl { - /** - * ioctl(..., void) - * \brief Get the block size - * \return Size of a hardware block for this device - */ - DISK_IOCTL_GETBLOCKSIZE = 4, - - /** - * ioctl(..., tTplDisk_CacheRegion *RegionInfo) - * \brief Sets the cache importantce and protocol for a section of - * memory. - * \param RegionInfo Pointer to a region information structure - * \return Boolean failure - */ - DISK_IOCTL_SETCACHEREGION, - - /** - * ioctl(..., Uint64 *Info[2]) - * \brief Asks the driver to precache a region of disk. - * \param Region 64-bit Address and Size pair describing the area to cache - * \return Number of blocks cached - */ - DISK_IOCTL_PRECACHE, - - /** - * ioclt(..., Uint64 *Region[2]) - * \brief Asks to driver to flush the region back to disk - * \param Region 64-bit Address and Size pair describing the area to flush - * \note If Region[0] == -1 then the entire disk's cache is flushed - * \return Number of blocks flushed (or 0 for entire disk) - */ - DISK_IOCTL_FLUSH -}; - -/** - * \brief Describes the cache parameters of a region on the disk - */ -typedef struct sTplDisk_CacheRegion -{ - Uint64 Base; //!< Base of cache region - Uint64 Length; //!< Size of cache region - /** - * \brief Cache Protocol & Flags - * - * The low 4 bits denot the cache protocol to be used by the - * region (see ::eTplDisk_CacheProtocols for a list). - * The high 4 bits denote flags to apply to the cache (see - * ::eTplDisk_CacheFlags) - */ - Uint8 Flags; - Uint8 Priority; //!< Lower is a higher proritory - /** - * \brief Maximum size of cache, in blocks - * \note If CacheSize is zero, the implemenation defined limit is used - */ - Uint16 CacheSize; -} tTplDisk_CacheRegion; - -/** - * \brief Cache protocols to use - */ -enum eTplDisk_CacheProtocols -{ - /** - * \brief Don't cache the region - */ - - DISK_CACHEPROTO_DONTCACHE, - /** - * \brief Most recently used blocks cached - * \note This is the default action for undefined regions - */ - DISK_CACHEPROTO_RECENTLYUSED, - /** - * \brief Cache the entire region in memory - * - * This is a faster version of setting Length to CacheSize*BlockSize - */ - DISK_CACHEPROTO_FULLCACHE, - - /** - * \brief Cache only on demand - * - * Only cache when the ::DISK_IOCTL_PRECACHE IOCtl is used - */ - DISK_CACHEPROTO_EXPLICIT -}; - -/** - * \brief Flags for the cache - */ -enum eTplDisk_CacheFlags -{ - /** - * \brief Write all changes to the region straight back to media - */ - DISK_CACHEFLAG_WRITETHROUGH = 0x10 -}; - -/** - * \brief IOCtl name strings - */ -#define DRV_DISK_IOCTLNAMES "get_block_size","set_cache_region","set_precache" - -/** - * \name Disk Driver Utilities - * \{ - */ - -/** - * \brief Callback function type used by DrvUtil_ReadBlock and DrvUtil_WriteBlock - * \param Address Zero based block number to read - * \param Count Number of blocks to read - * \param Buffer Destination for read blocks - * \param Argument Argument provided in ::DrvUtil_ReadBlock and ::DrvUtil_WriteBlock - */ -typedef Uint (*tDrvUtil_Callback)(Uint64 Address, Uint Count, void *Buffer, Uint Argument); - -/** - * \brief Reads a range from a block device using aligned reads - * \param Start Base byte offset - * \param Length Number of bytes to read - * \param Buffer Destination for read data - * \param ReadBlocks Callback function to read a sequence of blocks - * \param BlockSize Size of an individual block - * \param Argument An argument to pass to \a ReadBlocks - * \return Number of bytes read - */ -extern Uint64 DrvUtil_ReadBlock(Uint64 Start, Uint64 Length, void *Buffer, - tDrvUtil_Callback ReadBlocks, Uint64 BlockSize, Uint Argument); -/** - * \brief Writes a range to a block device using aligned writes - * \param Start Base byte offset - * \param Length Number of bytes to write - * \param Buffer Destination for read data - * \param ReadBlocks Callback function to read a sequence of blocks - * \param WriteBlocks Callback function to write a sequence of blocks - * \param BlockSize Size of an individual block - * \param Argument An argument to pass to \a ReadBlocks and \a WriteBlocks - * \return Number of bytes written - */ -extern Uint64 DrvUtil_WriteBlock(Uint64 Start, Uint64 Length, void *Buffer, - tDrvUtil_Callback ReadBlocks, tDrvUtil_Callback WriteBlocks, - Uint64 BlockSize, Uint Argument); - -/** - * \} - */ - -#endif diff --git a/Kernel/include/tpl_drv_joystick.h b/Kernel/include/tpl_drv_joystick.h deleted file mode 100644 index 2f4249b8..00000000 --- a/Kernel/include/tpl_drv_joystick.h +++ /dev/null @@ -1,139 +0,0 @@ -/** - * \file tpl_drv_joystick - * \brief Joystick Driver Interface Definitions - * \author John Hodge (thePowersGang) - * - * \section dirs VFS Layout - * Joystick drivers define a single VFS node, that acts as a fixed size file. - * Reads from this file return the current state, writes are ignored. - * - * \section File Structure - * The device file must begin with a valid sJoystick_FileHeader structure. - * The file header is followed by \a NAxies instances of sJoystick_Axis, one - * for each axis. - * This is followed by \a NButtons boolean values (represented using \a Uint8), - * each representing the state of a single button (where 0 is unpressed, - * 0xFF is fully depressed - intermediate values are valid in the case of - * variable-pressure buttons) - */ -#ifndef _TPL_JOYSTICK_H -#define _TPL_JOYSTICK_H - -#include - -/** - * \enum eTplJoystick_IOCtl - * \brief Common Joystick IOCtl Calls - * \extends eTplDrv_IOCtl - */ -enum eTplJoystick_IOCtl { - /** - * ioctl(..., tJoystick_Callback *Callback) - * \brief Sets the callback - * \note Can be called from kernel mode only - * - * Sets the callback that is called when a event occurs (button or axis - * change). This function pointer must be in kernel mode (although, - * kernel->user or kernel->ring3driver abstraction functions can be used) - * - * Axis events depend on the axis limit, if non-zero, the callback fires - * if the cursor position changes. Otherwise it fires when the axis value - * (cursor accelleration) changes. - */ - JOY_IOCTL_SETCALLBACK = 4, - - /** - * ioctl(..., int *Argument) - * \brief Set the argument passed as the first parameter to the callback - * \note Kernel mode only - */ - JOY_IOCTL_SETCALLBACKARG, - - /** - * ioctl(..., tJoystickNumValue *) - * \brief Set maximum value for sJoystick_Axis.CurState - * \note If \a Value is equal to -1 (all bits set), the value is not changed - */ - JOY_IOCTL_GETSETAXISLIMIT, - - /** - * ioctl(..., tJoystickNumValue *) - * \brief Set the value of sJoystick_Axis.CurState - * \note If \a Value is equal to -1 (all bits set), the value is not changed - */ - JOY_IOCTL_GETSETAXISPOSITION, - - /** - * ioctl(..., tJoystickNumValue *) - * \brief Set axis flags - * \note If \a Value is equal to -1 (all bits set), the value is not changed - * \todo Define flag values - */ - JOY_IOCTL_GETSETAXISFLAGS, - - /** - * ioctl(..., tJoystickNumValue *) - * \brief Set Button Flags - * \note If \a Value is equal to -1 (all bits set), the value is not changed - * \todo Define flag values - */ - JOY_IOCTL_GETSETBUTTONFLAGS, -}; - -#define DRV_JOY_IOCTLNAMES "set_callback", "set_callback_arg", "getset_axis_limit", "getset_axis_position", \ - "getset_axis_flags", "getset_button_flags" - -// === TYPES === -typedef struct sJoystick_NumValue tJoystick_NumValue; -typedef struct sJoystick_FileHeader tJoystick_FileHeader; -typedef struct sJoystick_Axis tJoystick_Axis; - -/** - * \brief Number/Value pair for joystick IOCtls - */ -struct sJoystick_NumValue -{ - int Num; //!< Axis/Button number - int Value; //!< Value (see IOCtl defs for meaning) -}; - -/** - * \brief Callback type for JOY_IOCTL_SETCALLBACK - * \param Ident Ident value passed to JOY_IOCTL_SETCALLBACK - * - */ -typedef void (*tJoystick_Callback)(int Ident, int bIsAxis, int Num, int Delta); - -/** - * \struct sJoystick_FileHeader - */ -struct sJoystick_FileHeader -{ - Uint16 NAxies; //!< Number of Axies - Uint16 NButtons; //!< Number of buttons -}; - -/** - * \brief Axis Definition in file data - * - * Describes the current state of an axis on the joystick. - * \a CursorPos is between zero and the current limit set by the - * JOY_IOCTL_GETSETAXISLIMIT IOCtl, while \a CurValue indicates the - * current position of the joystick axis. This is defined to be between - * \a MinValue and \a MaxValue. - */ -struct sJoystick_Axis -{ - Sint16 MinValue; //!< Minumum value for \a CurValue - Sint16 MaxValue; //!< Maximum value for \a CurValue - Sint16 CurValue; //!< Current value (joystick position) - Uint16 CursorPos; //!< Current state (cursor position) -}; - -#define JOY_INFOSTRUCT(_naxies, _nbuttons) struct { \ - Uint16 NAxies, NButtons;\ - tJoystick_Axis Axies[_naxies];\ - Uint16 Buttons[_nbuttons];\ - } - -#endif diff --git a/Kernel/include/tpl_drv_keyboard.h b/Kernel/include/tpl_drv_keyboard.h deleted file mode 100644 index c93c147e..00000000 --- a/Kernel/include/tpl_drv_keyboard.h +++ /dev/null @@ -1,119 +0,0 @@ -/** - * \file tpl_drv_keyboard.h - * \brief Keyboard Driver Interface Definitions - * \author John Hodge (thePowersGang) - * - * \section dirs VFS Layout - * Keyboard drivers consist of only a single node, which is a normal file - * node with a size of zero. All reads and writes to this node are ignored - * (tVFS_Node.Read and tVFS_Node.Write are NULL) - */ -#ifndef _TPL_KEYBOARD_H -#define _TPL_KEYBOARD_H - -#include - -/** - * \enum eTplKeyboard_IOCtl - * \brief Common Keyboard IOCtl Calls - * \extends eTplDrv_IOCtl - */ -enum eTplKeyboard_IOCtl { - /** - * ioctl(..., int *Rate) - * \brief Get/Set Repeat Rate - * \param Rate New repeat rate (pointer) - * \return Current/New Repeat rate - * - * Gets/Set the repeat rate (actually the time in miliseconds between - * repeats) of a held down key. - * If the rate is set to zero, repeating will be disabled. - */ - KB_IOCTL_REPEATRATE = 4, - - /** - * ioctl(..., int *Delay) - * \brief Get/Set Repeat Delay - * \param Delay New repeat delay (pointer) - * \return Current/New repeat delay - * - * Gets/Set the time in miliseconds before a key starts repeating - * after a key is pressed. - * Setting the delay to a negative number will cause the function to - * return -1 - */ - KB_IOCTL_REPEATDELAY, - - - /** - * ioctl(..., tKeybardCallback *Callback) - * \brief Sets the callback - * \note Can be called from kernel mode only - * - * Sets the function to be called when a key event occurs (press, release - * or repeat). This function pointer must be in kernel mode (although, - * kernel->user or kernel->ring3driver abstraction functions can be used) - */ - KB_IOCTL_SETCALLBACK -}; - -#define DRV_KEYBAORD_IOCTLNAMES "getset_repeat_rate", "getset_repeat_delay", "set_callback" - -/** - * \brief Callback type for KB_IOCTL_SETCALLBACK - * \param Key Unicode character code for the pressed key (with bit 31 - * set if the key is released) - */ -typedef void (*tKeybardCallback)(Uint32 Key); - -/** - * \brief Symbolic key codes - * - * These key codes represent non-pritable characters and are placed above - * the Unicode character space. - * If the using driver recieves a key code with the 31st bit set, it means - * that that key has been released. - */ -enum eTplKeyboard_KeyCodes { - KEY_ESC = 0x1B, //!< Escape Character - - KEY_NP_MASK = 0x40000000, //! Mask for non-printable characters - - /** - * \name Special Keys - * \brief These keys are usually used on their own - * \{ - */ - KEY_CAPSLOCK, - KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, - KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, - KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, - KEY_NUMLOCK, KEY_SCROLLLOCK, - KEY_HOME, KEY_END, KEY_INS, KEY_DEL, - KEY_PAUSE, KEY_BREAK, - KEY_PGUP, KEY_PGDOWN, - KEY_KPENTER, KEY_KPSLASH, KEY_KPMINUS, KEY_KPPLUS, KEY_KPSTAR, - KEY_KPHOME, KEY_KPUP, KEY_KPPGUP, KEY_KPLEFT, KEY_KP5, KEY_KPRIGHT, - KEY_KPEND, KEY_KPDOWN, KEY_KPPGDN, KEY_KPINS, KEY_KPDEL, - KEY_WIN, KEY_MENU, - /** - * \} - */ - - // Modifiers - /** - * \name Modifiers - * \brief These keye usually alter the character stream sent to the user - * \{ - */ - KEY_MODIFIERS = 0x60000000, - KEY_LCTRL, KEY_RCTRL, - KEY_LALT, KEY_RALT, - KEY_LSHIFT, KEY_RSHIFT, - /** - * \} - */ -}; - - -#endif diff --git a/Kernel/include/tpl_drv_network.h b/Kernel/include/tpl_drv_network.h deleted file mode 100644 index 6b7493ac..00000000 --- a/Kernel/include/tpl_drv_network.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - * \file tpl_drv_network.h - * \brief Network Interface Driver Interface Definitions - * - * \section dirs VFS Layout - * All network drivers must have the following basic VFS structure - * The root of the driver will only contain files that are named from zero - * upwards that represent the present network adapters that this driver - * controls. All VFS nodes must implement ::eTplDrv_IOCtl with - * DRV_IOCTL_TYPE returning DRV_TYPE_NETWORK. - * The adapter nodes must also implement ::eTplNetwork_IOCtl fully - * (unless it is noted in the ::eTplNetwork_IOCtl documentation that a - * call is optional) - * - * \section files Adapter Files - * \subsection Reading - * When an adapter file is read from, the driver will block the reading - * thread until a packet arrives (if there is not already an unhandled - * packet in the queue) this will then be read into the destination buffer. - * If the packet does not fit in the buffer, the end of it is discarded. - * Likewise, if the packet does not completely fill the buffer, the call - * will still read to the buffer and then return the size of the packet. - * \subsection Writing - * When an adapter is written to, the data written is encoded as a packet - * and sent, if the data is not the correct size to be sent (if the packet - * is too small, or if it is too large) -1 should be returned and the packet - * will not be sent. - */ -#ifndef _TPL_NETWORK_H -#define _TPL_NETWORK_H - -#include - -/** - * \enum eTplNetwork_IOCtl - * \brief Common Network IOCtl Calls - * \extends eTplDrv_IOCtl - */ -enum eTplNetwork_IOCtl { - /** - * ioctl(..., Uint8 *MAC[6]) - * \brief Get the MAC address of the interface - * \return 1 on success, 0 if the file is the root, -1 on error - * - * Copies the six byte Media Access Control (MAC) address of the - * adapter to the \a MAC array. - */ - NET_IOCTL_GETMAC = 4 -}; - -/** - * \brief IOCtl name strings for use with eTplDrv_IOCtl.DRV_IOCTL_LOOKUP - */ -#define DRV_NETWORK_IOCTLNAMES "get_mac_addr" - -#endif diff --git a/Kernel/include/tpl_drv_terminal.h b/Kernel/include/tpl_drv_terminal.h deleted file mode 100644 index b32b83d5..00000000 --- a/Kernel/include/tpl_drv_terminal.h +++ /dev/null @@ -1,157 +0,0 @@ -/** - * \file tpl_drv_terminal.h - * \brief Terminal Driver Interface Definitions -*/ -#ifndef _TPL_TERMINAL_H -#define _TPL_TERMINAL_H - -#include - -/** - * \brief Common Terminal IOCtl Calls - * \extends eTplDrv_IOCtl - */ -enum eTplTerminal_IOCtl { - /** - * ioctl(..., int *mode) - * \brief Get/Set the current video mode type - * \param mode Pointer to an integer with the new mode number (or NULL) - * If \a mode is non-NULL the current terminal mode is changed/updated - * to the mode indicated by \a *mode - * \note See ::eTplTerminal_Modes - * \return Current/new terminal mode - */ - TERM_IOCTL_MODETYPE = 4, - - /** - * ioctl(..., int *width) - * \brief Get/set the display width - * \param width Pointer to an integer containing the new width (or NULL) - * \return Current/new width - * - * If \a width is non-NULL the current width is updated (but is not - * applied until ::TERM_IOCTL_MODETYPE is called with \a mode non-NULL. - */ - TERM_IOCTL_WIDTH, - - /** - * ioctl(..., int *height) - * \brief Get/set the display height - * \param height Pointer to an integer containing the new height - * \return Current height - * - * If \a height is non-NULL the current height is updated (but is not - * applied until ::TERM_IOCTL_MODETYPE is called with a non-NULL \a mode. - */ - TERM_IOCTL_HEIGHT, - - /** - * ioctl(..., tTerm_IOCtl_Mode *info) - * \brief Queries the current driver about it's native modes - * \param info A pointer to a ::tTerm_IOCtl_Mode with \a ID set to - * the mode index (or NULL) - * \return Number of modes - * - * If \a info is NULL, the number of avaliable vative display modes - * is returned. These display modes will have sequential ID numbers - * from zero up to this value. - * - * \note The id field of \a info is not for use with ::TERM_IOCTL_MODETYPE - * This field is just for indexing the mode to get its information. - */ - TERM_IOCTL_QUERYMODE, - - /** - * ioctl(...) - * \brief Forces the current terminal to be shown - */ - TERM_IOCTL_FORCESHOW, - - /** - * ioctl(...) - * \brief Returns the current text cursor position - * \return Cursor position (as X+Y*Width) - */ - TERM_IOCTL_GETCURSOR -}; - -/** - * \brief Virtual Terminal Mode - * Describes a VTerm mode to the caller of ::TERM_IOCTL_QUERYMODE - */ -typedef struct sTerm_IOCtl_Mode -{ - short ID; //!< Zero Based index of mode - short DriverID; //!< Driver's ID number (from ::tVideo_IOCtl_Mode) - Uint16 Height; //!< Height - Uint16 Width; //!< Width - Uint8 Depth; //!< Bits per cell - struct { - unsigned bText: 1; //!< Text Mode marker - unsigned unused: 7; - }; -} tTerm_IOCtl_Mode; - -/** - * \brief Terminal Modes - */ -enum eTplTerminal_Modes { - /** - * \brief UTF-8 Text Mode - * Any writes to the terminal file are treated as UTF-8 encoded - * strings and reads will also return UTF-8 strings. - */ - TERM_MODE_TEXT, - - /** - * \brief 32bpp Framebuffer - * Writes to the terminal file will write to the framebuffer. - * Reads will return UTF-32 characters - */ - TERM_MODE_FB, - - /** - * \brief 32bpp 2D Accellerated mode - * Writes to the terminal file will be read as a command stream - * defined in ::eTplTerminal_2D_Commands - */ - TERM_MODE_2DACCEL, - - /** - * \brief OpenGL 2D/3D - * Writes to the terminal file will send 3D commands - * Reads will return UTF-32 characters - * \note May or may not stay in the spec - */ - TERM_MODE_3D, - - /** - * \brief Number of terminal modes - */ - NUM_TERM_MODES -}; - -/** - * \brief 2D Command IDs - * \todo Complete this structure - * - * Command IDs for when the terminal type is eTplTerminal_Modes.TERM_MODE_2DACCEL - */ -enum eTplTerminal_2D_Commands -{ - /** - * \brief No Operation - Used for padding - */ - TERM_2DCMD_NOP, - - /** - * (Uint16 X, Y, W, H, Uint32 Data[]) - * \brief Blits a bitmap to the display - * \param X,Y Coordinates of Top-Left corner - * \param W,H Dimensions - * \param Data 32-bpp pixel data - */ - TERM_2DCMD_PUSH -}; - -#endif diff --git a/Kernel/include/tpl_drv_video.h b/Kernel/include/tpl_drv_video.h deleted file mode 100644 index f518e74a..00000000 --- a/Kernel/include/tpl_drv_video.h +++ /dev/null @@ -1,340 +0,0 @@ -/** - * \file tpl_drv_video.h - * \brief Video Driver Interface Definitions - * \note For AcessOS Version 1 - * - * Video drivers extend the common driver interface tpl_drv_common.h - * and must support _at least_ the IOCtl numbers defined in this file - * to be compatable with Acess. - * - * \section IOCtls - * As said, a compatable driver must implement these calls correctly, - * but they may choose not to allow direct user access to the framebuffer. - * - * \section Screen Contents - * Writes to the driver's file while in component colour modes - * must correspond to a change of the contents of the screen. The framebuffer - * must start at offset 0 in the file. - * Reading from the screen must either return zero, or read from the - * framebuffer. - * - * \section Mode Support - * All video drivers must support at least one text mode (Mode #0) - * For each graphics mode the driver exposes, there must be a corresponding - * text mode with the same resolution, this mode will be used when the - * user switches to a text Virtual Terminal while in graphics mode. - */ -#ifndef _TPL_VIDEO_H -#define _TPL_VIDEO_H - -#include - -/** - * \enum eTplVideo_IOCtl - * \brief Common Video IOCtl Calls - * \extends eTplDrv_IOCtl - */ -enum eTplVideo_IOCtl { - /** - * ioctl(..., int *mode) - * \brief Get/Set Mode - * \return Current mode ID or -1 on error - * - * If \a mode is non-NULL, the current video mode is set to \a *mode. - * This updated ID is then returned to the user. - */ - VIDEO_IOCTL_GETSETMODE = 4, - - /** - * ioctl(..., tVideo_IOCtl_Mode *info) - * \brief Find a matching mode - * \return 1 if a mode was found, 0 otherwise - * - * Using avaliable modes matching the \a bpp and \a flags fields - * set the \a id field to the mode id of the mode with the closest - * \a width and \a height. - */ - VIDEO_IOCTL_FINDMODE, - - /** - * ioctl(..., tVideo_IOCtl_Mode *info) - * \brief Get mode info - * \return 1 if the mode exists, 0 otherwise - * - * Set \a info's fields to the mode specified by the \a id field. - */ - VIDEO_IOCTL_MODEINFO, - - /** - * ioctl(..., int *NewFormat) - * \brief Switches between Text, Framebuffer and 3D modes - * \param NewFormat Pointer to the new format code (see eTplVideo_BufFormats) - * \return Original format - * - * Enabes and disables the video text mode, changing the behavior of - * writes to the device file. - */ - VIDEO_IOCTL_SETBUFFORMAT, - - /** - * ioctl(..., tVideo_IOCtl_Pos *pos) - * \brief Sets the cursor position - * \return Boolean success - * - * Set the text mode cursor position (if it is supported) - * If the \a pos is set to (-1,-1) the cursor is hidden, otherwise - * \a pos MUST be within the current screen size (as given by the - * current mode's tVideo_IOCtl_Mode.width and tVideo_IOCtl_Mode.height - * fields). - */ - VIDEO_IOCTL_SETCURSOR, - - /** - * ioctl(..., tVideo_IOCtl_Bitmap *Image) - * \brief Sets the cursor image - * \return Boolean success - * - * Sets the graphics mode cursor image - */ - VIDEO_IOCTL_SETCURSORBITMAP -}; -#define DRV_VIDEO_IOCTLNAMES "getset_mode", "find+mode", "mode_info", "set_buf_format", "set_cursor", "set_cursor_bitmap" - -/** - * \brief Mode Structure used in IOCtl Calls - * - * Defines a video mode supported by (or requested of) this driver (depending - * on what ioctl call is used) - */ -typedef struct sVideo_IOCtl_Mode -{ - short id; //!< Mode ID - Uint16 width; //!< Width - Uint16 height; //!< Height - Uint8 bpp; //!< Bits per Unit (Character or Pixel, depending on \a flags) - Uint8 flags; //!< Mode Flags -} tVideo_IOCtl_Mode; - -/** - * \brief Buffer Format Codes - */ -enum eTplVideo_BufFormats -{ - /** - * \brief Text Mode - * - * The device file presents itself as an array of ::tVT_Char - * each describing a character cell on the screen. - * These cells are each \a giVT_CharWidth pixels wide and - * \a giVT_CharHeight high. - */ - VIDEO_BUFFMT_TEXT, - /** - * \brief Framebuffer Mode - * - * The device file presents as an array of 32-bpp pixels describing - * the entire screen. The format of a single pixel is in xRGB format - * (top 8 bits ignored, next 8 bits red, next 8 bits green and - * the bottom 8 bits blue) - */ - VIDEO_BUFFMT_FRAMEBUFFER, - /** - * \brief 2D Accelerated Mode - * - * The device file acts as a character device, accepting a stream of - * commands described in eTplVideo_2DCommands when written to. - */ - VIDEO_BUFFMT_2DSTREAM, - /** - * \brief 3D Accelerated Mode - * - * The device file acts as a character device, accepting a stream of - * commands described in eTplVideo_3DCommands when written to. - */ - VIDEO_BUFFMT_3DSTREAM -}; - -/** - * \brief 2D Accellerated Video Commands - * - * Commands passed in the command stream for ::VIDEO_BUFFMT_2DSTREAM - */ -enum eTplVideo_2DCommands -{ - /** - * \brief No Operation - */ - VIDEO_2DOP_NOP, - /** - * \brief Fill a region - * \param X Uint16 - Leftmost pixels of the region - * \param Y Uint16 - Topmost pixels of the region - * \param W Uint16 - Width of the region - * \param H Uint16 - Height of the region - * \param Colour Uint32 - Value to fill with - */ - VIDEO_2DOP_FILL, - /** - * \brief Copy a region from one part of the framebuffer to another - * \param DestX Uint16 - Leftmost pixels of the destination - * \param DestY Uint16 - Topmost pixels of the destination - * \param SrcX Uint16 - Leftmost pixels of the source - * \param SrcY Uint16 - Topmost pixels of the source - * \param Width Uint16 - Width of the region - * \param Height Uint16 - Height of the region - */ - VIDEO_2DOP_BLIT, - - - /** - * \brief Copy a region from video memory to the framebuffer - */ - VIDEO_2DOP_BLITBUF, - - /** - * \brief Copy and scale a region from video memory to the framebuffer - */ - VIDEO_2DOP_BLITSCALEBUF, - - NUM_VIDEO_2DOPS -}; - -/** - * \brief Describes a position in the video framebuffer - */ -typedef struct sVideo_IOCtl_Pos -{ - Sint16 x; //!< X Coordinate - Sint16 y; //!< Y Coordinate -} tVideo_IOCtl_Pos; - -/** - * \brief Bitmap object (out of band image) - */ -typedef struct sVideo_IOCtl_Bitmap -{ - Sint16 W; //!< Width of image - Sint16 H; //!< Height of image - Sint16 XOfs; //!< X Offset of center - Sint16 YOfs; //!< Y Offset of center - Uint32 Data[]; //!< Image data (ARGB array) -} tVideo_IOCtl_Bitmap; - -/** - * \brief Virtual Terminal Representation of a character - */ -typedef struct sVT_Char -{ - Uint32 Ch; //!< UTF-32 Character - union { - struct { - Uint16 BGCol; //!< 12-bit Foreground Colour - Uint16 FGCol; //!< 12-bit Background Colour - }; - Uint32 Colour; //!< Compound colour for ease of access - }; -} tVT_Char; - -/** - * \name Basic builtin colour definitions - * \{ - */ -#define VT_COL_BLACK 0x0000 -#define VT_COL_GREY 0x0888 -#define VT_COL_LTGREY 0x0CCC -#define VT_COL_WHITE 0x0FFF -/** - * \} - */ - -//! \brief Defines the width of a rendered character -extern int giVT_CharWidth; -//! \brief Defines the height of a rendered character -extern int giVT_CharHeight; -/** - * \brief Driver helper that renders a character to a buffer - * \param Codepoint Unicode character to render - * \param Buffer Buffer to render to - * \param Depth Bit depth of the destination buffer - * \param Pitch Number of bytes per line - * \param BGC 32-bit Background Colour - * \param FGC 32-bit Foreground Colour - * - * This function is provided to help video drivers to support a simple - * text mode by keeping the character rendering abstracted from the driver, - * easing the driver development and reducing code duplication. - */ -extern void VT_Font_Render(Uint32 Codepoint, void *Buffer, int Depth, int Pitch, Uint32 BGC, Uint32 FGC); -/** - * \fn Uint32 VT_Colour12to24(Uint16 Col12) - * \brief Converts a colour from 12bpp to 24bpp - * \param Col12 12-bpp input colour - * \return Expanded 32-bpp (24-bit colour) version of \a Col12 - */ -extern Uint32 VT_Colour12to24(Uint16 Col12); -/** - * \brief Converts a colour from 12bpp to 14bpp - * \param Col12 12-bpp input colour - * \return 15 bits per pixel value - */ -extern Uint16 VT_Colour12to15(Uint16 Col12); -/** - * \brief Converts a colour from 12bpp to 32bpp - * \param Col12 12-bpp input colour - * \param Depth Desired bit depth - * \return \a Depth bit number, denoting Col12 - * - * Expands the source colour into a \a Depth bits per pixel representation. - * The colours are expanded with preference to Green, Blue and Red in that order - * (so, green gets the first spare pixel, blue gets the next, and red never gets - * the spare). \n - * The final bit of each component is used to fill the lower bits of the output. - */ -extern Uint32 VT_Colour12toN(Uint16 Col12, int Depth); - -/** - * \brief Handlers for eTplVideo_2DCommands - */ -typedef struct sDrvUtil_Video_2DHandlers -{ - /** - * \brief No Operation, Ignored - * \see VIDEO_2DOP_NOP - */ - void *Nop; - /** - * \brief Fill a buffer region - * \param X Lefthand edge - * \param Y Top edge - * \param W Width - * \param H Height - * \param Colour Colour to fill with - * \see VIDEO_2DOP_FILL - */ - void (*Fill)(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour); - /** - * \brief Fill a buffer region - * \param DestX Lefthand edge of destination - * \param DestY Top edge of destination - * \param SrcX Lefthand edge of source - * \param SrcY Top edge of source - * \param W Width - * \param H Height - * \see VIDEO_2DOP_BLIT - */ - void (*Blit)(void *Ent, Uint16 DestX, Uint16 DestY, Uint16 SrcX, Uint16 SrcY, Uint16 W, Uint16 H); -} tDrvUtil_Video_2DHandlers; - -/** - * \brief Handle a 2D operation stream for a driver - * \param Ent Value to pass to handlers - * \param Buffer Stream buffer - * \param Length Length of stream - * \param Handlers Handlers to use for the stream - * \param SizeofHandlers Size of \a tDrvUtil_Video_2DHandlers according - * to the driver. Used as version control and error avoidence. - */ -extern Uint64 DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length, - tDrvUtil_Video_2DHandlers *Handlers, int SizeofHandlers); - -#endif diff --git a/Modules/Display/BochsGA/bochsvbe.c b/Modules/Display/BochsGA/bochsvbe.c index df4072b3..5508e3f4 100644 --- a/Modules/Display/BochsGA/bochsvbe.c +++ b/Modules/Display/BochsGA/bochsvbe.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #define INT diff --git a/Modules/Display/VESA/main.c b/Modules/Display/VESA/main.c index 848351a0..c18891f4 100644 --- a/Modules/Display/VESA/main.c +++ b/Modules/Display/VESA/main.c @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include diff --git a/Modules/IPStack/interface.c b/Modules/IPStack/interface.c index 74f0cf83..e08d6505 100644 --- a/Modules/IPStack/interface.c +++ b/Modules/IPStack/interface.c @@ -6,8 +6,8 @@ #define VERSION VER2(0,10) #include "ipstack.h" #include "link.h" -#include -#include +#include +#include // === CONSTANTS === //! Default timeout value, 30 seconds diff --git a/Modules/IPStack/routing.c b/Modules/IPStack/routing.c index 63793027..9e298a0e 100644 --- a/Modules/IPStack/routing.c +++ b/Modules/IPStack/routing.c @@ -5,7 +5,7 @@ #define DEBUG 0 #define VERSION VER2(0,10) #include -#include +#include #include "ipstack.h" #include "link.h" diff --git a/Modules/IPStack/sctp.c b/Modules/IPStack/sctp.c index a09b153d..d130933f 100644 --- a/Modules/IPStack/sctp.c +++ b/Modules/IPStack/sctp.c @@ -3,7 +3,7 @@ * - SCTP (Stream Control Transmission Protocol) Handling */ #include "ipstack.h" -#include +#include #include "sctp.h" #define SCTP_ALLOC_BASE 0xC000 diff --git a/Modules/IPStack/udp.c b/Modules/IPStack/udp.c index 9e54701f..c75aab0c 100644 --- a/Modules/IPStack/udp.c +++ b/Modules/IPStack/udp.c @@ -3,7 +3,7 @@ * - UDP Handling */ #include "ipstack.h" -#include +#include #include "udp.h" #define UDP_ALLOC_BASE 0xC000 diff --git a/Modules/Input/PS2KbMouse/kb.c b/Modules/Input/PS2KbMouse/kb.c index d8ef32ee..db0ee220 100644 --- a/Modules/Input/PS2KbMouse/kb.c +++ b/Modules/Input/PS2KbMouse/kb.c @@ -5,8 +5,8 @@ #include #include #include -#include -#include +#include +#include #include "kb_kbdus.h" // === CONSTANTS === diff --git a/Modules/Input/PS2KbMouse/ps2mouse.c b/Modules/Input/PS2KbMouse/ps2mouse.c index f67c8b15..cb26efe5 100644 --- a/Modules/Input/PS2KbMouse/ps2mouse.c +++ b/Modules/Input/PS2KbMouse/ps2mouse.c @@ -6,8 +6,8 @@ #include #include #include -#include -#include +#include +#include static inline int MIN(int a, int b) { return (a < b) ? a : b; } static inline int MAX(int a, int b) { return (a > b) ? a : b; } diff --git a/Modules/Network/NE2000/ne2000.c b/Modules/Network/NE2000/ne2000.c index cb760d66..eb3673f2 100644 --- a/Modules/Network/NE2000/ne2000.c +++ b/Modules/Network/NE2000/ne2000.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include // === CONSTANTS === diff --git a/Modules/Network/PCnet-FASTIII/pcnet-fast3.c b/Modules/Network/PCnet-FASTIII/pcnet-fast3.c index ebb40114..bb4f83a8 100644 --- a/Modules/Network/PCnet-FASTIII/pcnet-fast3.c +++ b/Modules/Network/PCnet-FASTIII/pcnet-fast3.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include // === CONSTANTS === diff --git a/Modules/Network/RTL8139/rtl8139.c b/Modules/Network/RTL8139/rtl8139.c index 707b2eb1..bb479554 100644 --- a/Modules/Network/RTL8139/rtl8139.c +++ b/Modules/Network/RTL8139/rtl8139.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include // === CONSTANTS === diff --git a/Modules/Sound/SoundBlaster16/main.c b/Modules/Sound/SoundBlaster16/main.c index 52883999..f2d056c6 100644 --- a/Modules/Sound/SoundBlaster16/main.c +++ b/Modules/Sound/SoundBlaster16/main.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #define INT diff --git a/Modules/Storage/ATA/main.c b/Modules/Storage/ATA/main.c index 7f8964d2..11498da9 100644 --- a/Modules/Storage/ATA/main.c +++ b/Modules/Storage/ATA/main.c @@ -8,8 +8,8 @@ #include #include #include -#include -#include +#include +#include #include "common.h" // === MACROS === diff --git a/Modules/Storage/FDD/fdd.c b/Modules/Storage/FDD/fdd.c index 42150a95..a7b20f7d 100644 --- a/Modules/Storage/FDD/fdd.c +++ b/Modules/Storage/FDD/fdd.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include diff --git a/Modules/x86/VGAText/vga.c b/Modules/x86/VGAText/vga.c index 1ae1ece6..d958956b 100644 --- a/Modules/x86/VGAText/vga.c +++ b/Modules/x86/VGAText/vga.c @@ -4,7 +4,7 @@ #define DEBUG 0 #include #include -#include +#include #include // === CONSTANTS ===