From a8a3752a92b026370ae4e6bd1a72d70c03309533 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 23 Apr 2010 22:05:53 +0800 Subject: [PATCH] Halfway through deciding where to put the error handlers, I've settled on libc - TODO: Make a clean way of getting access to ld-acess's functions/data at runtime - Also drafting up the 2D accelerated video interface --- Kernel/Makefile.BuildNum | 2 +- Kernel/include/tpl_drv_video.h | 29 +++++++++++++++++++ Modules/Display/VESA/main.c | 2 ++ Usermode/Libraries/ld-acess.so_src/common.h | 14 +++++++++ .../Libraries/ld-acess.so_src/helpers.asm | 9 ++++++ Usermode/Libraries/ld-acess.so_src/loadlib.c | 24 +++++++++------ Usermode/Libraries/ld-acess.so_src/main.c | 3 -- Usermode/Libraries/libc.so_src/stub.c | 25 ++++++++++++++-- Usermode/include/sys/sys.h | 2 +- 9 files changed, 93 insertions(+), 17 deletions(-) diff --git a/Kernel/Makefile.BuildNum b/Kernel/Makefile.BuildNum index 6b06f1ca..fa5303e5 100644 --- a/Kernel/Makefile.BuildNum +++ b/Kernel/Makefile.BuildNum @@ -1 +1 @@ -BUILD_NUM = 2035 +BUILD_NUM = 2036 diff --git a/Kernel/include/tpl_drv_video.h b/Kernel/include/tpl_drv_video.h index ebbe98fa..ce575bb7 100644 --- a/Kernel/include/tpl_drv_video.h +++ b/Kernel/include/tpl_drv_video.h @@ -125,8 +125,37 @@ typedef struct sVideo_IOCtl_Mode */ 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 }; diff --git a/Modules/Display/VESA/main.c b/Modules/Display/VESA/main.c index c2217e4c..85bcb3b5 100644 --- a/Modules/Display/VESA/main.c +++ b/Modules/Display/VESA/main.c @@ -238,6 +238,8 @@ Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) } if( Offset + Length > heightInChars*widthInChars ) { + Log_Debug("VESA", "%i + %i > %i*%i (%i)", + (int)Offset, (int)Length, heightInChars, widthInChars, heightInChars*widthInChars); Length = heightInChars*widthInChars - Offset; Log_Notice("VESA", "Clipping write size to %i characters", (int)Length); } diff --git a/Usermode/Libraries/ld-acess.so_src/common.h b/Usermode/Libraries/ld-acess.so_src/common.h index bc2efbdc..81913d50 100644 --- a/Usermode/Libraries/ld-acess.so_src/common.h +++ b/Usermode/Libraries/ld-acess.so_src/common.h @@ -11,6 +11,11 @@ #include +// === CONSTANTS === +#define MAX_LOADED_LIBRARIES 64 +#define MAX_STRINGS_BYTES 4096 +#define SYSTEM_LIB_DIR "/Acess/Libs/" + // === Types === typedef unsigned int Uint; typedef unsigned char Uint8; @@ -19,6 +24,14 @@ typedef unsigned long Uint32; typedef signed char Sint8; typedef signed short Sint16; typedef signed long Sint32; + +typedef struct { + Uint Base; + char *Name; +} tLoadedLib; + +// === GLOBALS === +extern tLoadedLib gLoadedLibraries[MAX_LOADED_LIBRARIES]; // === Main === extern int DoRelocate( Uint base, char **envp, char *Filename ); @@ -42,6 +55,7 @@ extern void SysDebug(char *fmt, ...); //!< Now implemented in main.c extern void SysDebugV(char *fmt, ...); extern Uint SysLoadBin(char *path, Uint *entry); extern Uint SysUnloadBin(Uint Base); +extern void SysSetFaultHandler(int (*Hanlder)(int)); extern int open(char *filename, int flags); extern void close(int fd); diff --git a/Usermode/Libraries/ld-acess.so_src/helpers.asm b/Usermode/Libraries/ld-acess.so_src/helpers.asm index 3797333e..49b9bd8a 100644 --- a/Usermode/Libraries/ld-acess.so_src/helpers.asm +++ b/Usermode/Libraries/ld-acess.so_src/helpers.asm @@ -9,6 +9,7 @@ [global _SysExit] [global _SysLoadBin] [global _SysUnloadBin] +[global _SysSetFaultHandler] [global _open] [global _close] @@ -77,3 +78,11 @@ _close: int 0xAC pop ebx ret + +_SysSetFaultHandler: + push ebx + mov eax, SYS_SETFAULTHANDLER + mov ebx, [esp+0x8] ; File Descriptor + int 0xAC + pop ebx + ret diff --git a/Usermode/Libraries/ld-acess.so_src/loadlib.c b/Usermode/Libraries/ld-acess.so_src/loadlib.c index 5cfa26e8..e0b3b254 100644 --- a/Usermode/Libraries/ld-acess.so_src/loadlib.c +++ b/Usermode/Libraries/ld-acess.so_src/loadlib.c @@ -12,20 +12,20 @@ # define DEBUGS(v...) #endif -// === CONSTANTS === -#define MAX_LOADED_LIBRARIES 64 -#define MAX_STRINGS_BYTES 4096 -#define SYSTEM_LIB_DIR "/Acess/Libs/" - // === PROTOTYPES === Uint IsFileLoaded(char *file); int GetSymbolFromBase(Uint base, char *name, Uint *ret); -// === GLOABLS === -struct { - Uint Base; +// === CONSTANTS === +const struct { + Uint Value; char *Name; -} gLoadedLibraries[MAX_LOADED_LIBRARIES]; +} caLocalExports[] = { + {gLoadedLibraries, "gLoadedLibraries"} +}; + +// === GLOABLS === +tLoadedLib gLoadedLibraries[MAX_LOADED_LIBRARIES]; char gsLoadedStrings[MAX_STRINGS_BYTES]; char *gsNextAvailString = gsLoadedStrings; //tLoadLib *gpLoadedLibraries = NULL; @@ -200,6 +200,12 @@ Uint GetSymbol(char *name) { int i; Uint ret; + for(i=0;i