From: John Hodge Date: Sat, 24 Apr 2010 14:17:02 +0000 (+0800) Subject: Big rewrite of AxWin to get it to compile and run X-Git-Tag: rel0.06~214 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=d55488f17f9fbd25d9126853720e2fd78bd8540f;p=tpg%2Facess2.git Big rewrite of AxWin to get it to compile and run --- diff --git a/Kernel/Makefile.BuildNum b/Kernel/Makefile.BuildNum index b6f09c45..38055e55 100644 --- a/Kernel/Makefile.BuildNum +++ b/Kernel/Makefile.BuildNum @@ -1 +1 @@ -BUILD_NUM = 2045 +BUILD_NUM = 2056 diff --git a/Usermode/Applications/axwin2_src/Shell_src/main.c b/Usermode/Applications/axwin2_src/Shell_src/main.c index b357dea5..7c903cec 100644 --- a/Usermode/Applications/axwin2_src/Shell_src/main.c +++ b/Usermode/Applications/axwin2_src/Shell_src/main.c @@ -1,5 +1,5 @@ /* - * Acess2 GUI Shell + * Acess2 GUI Test App * - By John Hodge (thePowersGang) */ #include @@ -13,9 +13,11 @@ tAxWin_Handle ghMenubarWindow; // === CODE === int main(int argc, char *argv[]) -{ +{ + AxWin_Register("Terminal"); + // Create Window - ghMenubarWindow = AxWin_CreateWindow(0, 0, -1, -1, WINFLAG_NOBORDER, Menubar_HandleMessage); + //ghMenubarWindow = AxWin_CreateWindow(0, 0, -1, -1, WINFLAG_NOBORDER, Menubar_HandleMessage); AxWin_MessageLoop(); diff --git a/Usermode/Applications/axwin2_src/WM/Makefile b/Usermode/Applications/axwin2_src/WM/Makefile index 7fa10003..61206120 100644 --- a/Usermode/Applications/axwin2_src/WM/Makefile +++ b/Usermode/Applications/axwin2_src/WM/Makefile @@ -4,8 +4,9 @@ CPPFLAGS += -I../include -DIR = Apps/AxWin/1.0 -BIN = ../AxWinWM -OBJ = main.o helpers.o commandline.o video.o messages.o +DIR := Apps/AxWin/1.0 +BIN := ../AxWinWM +OBJ := main.o helpers.o commandline.o video.o +OBJ += messages.o interface.o -include ../../Makefile.tpl diff --git a/Usermode/Applications/axwin2_src/WM/common.h b/Usermode/Applications/axwin2_src/WM/common.h index 13379fa1..7ec792ab 100644 --- a/Usermode/Applications/axwin2_src/WM/common.h +++ b/Usermode/Applications/axwin2_src/WM/common.h @@ -24,5 +24,7 @@ extern int giMouseFD; // === Functions === extern void memset32(void *ptr, uint32_t val, size_t count); +extern void Video_FillRect(short X, short Y, short W, short H, uint32_t Color); +extern void Video_Update(void); #endif diff --git a/Usermode/Applications/axwin2_src/WM/interface.c b/Usermode/Applications/axwin2_src/WM/interface.c new file mode 100644 index 00000000..36e0124e --- /dev/null +++ b/Usermode/Applications/axwin2_src/WM/interface.c @@ -0,0 +1,16 @@ +/* + * Acess GUI (AxWin) Version 2 + * By John Hodge (thePowersGang) + */ +#include "common.h" + +// === CODE === +void Interface_Render(void) +{ + Video_FillRect( + 0, 0, + giScreenWidth/16, giScreenHeight, + 0xDDDDDD); + + Video_Update(); +} diff --git a/Usermode/Applications/axwin2_src/WM/main.c b/Usermode/Applications/axwin2_src/WM/main.c index 7d26b399..1a68acb2 100644 --- a/Usermode/Applications/axwin2_src/WM/main.c +++ b/Usermode/Applications/axwin2_src/WM/main.c @@ -7,7 +7,8 @@ // === IMPORTS === extern void ParseCommandline(int argc, char *argv[]); -extern void Video_Setup(); +extern void Video_Setup(void); +extern void Messages_PollIPC(void); // === GLOBALS === char *gsTerminalDevice = NULL; @@ -34,6 +35,7 @@ int main(int argc, char *argv[]) } Video_Setup(); + Interface_Render(); // Main Loop for(;;) diff --git a/Usermode/Applications/axwin2_src/WM/messages.c b/Usermode/Applications/axwin2_src/WM/messages.c index 0147e5ff..01bd07c4 100644 --- a/Usermode/Applications/axwin2_src/WM/messages.c +++ b/Usermode/Applications/axwin2_src/WM/messages.c @@ -62,7 +62,11 @@ void Messages_Handle(tAxWin_Message *Msg, tMessages_Handle_Callback *Respond, in { case MSG_SREQ_PING: Msg->ID = MSG_SRSP_PONG; - Respond(ID, sizeof(Msg->ID), Msg); + Msg->Size = 2; + Msg->SRsp_Pong.Major = 0; + Msg->SRsp_Pong.Minor = 1; + Msg->SRsp_Pong.Build = -1; + Messages_RespondIPC(ID, sizeof(Msg->ID), Msg); break; default: fprintf(stderr, "WARNING: Unknown message %i from %i (%p)\n", Msg->ID, ID, Respond); diff --git a/Usermode/Applications/axwin2_src/WM/video.c b/Usermode/Applications/axwin2_src/WM/video.c index 00dbe16c..fb082085 100644 --- a/Usermode/Applications/axwin2_src/WM/video.c +++ b/Usermode/Applications/axwin2_src/WM/video.c @@ -7,13 +7,14 @@ #include // === PROTOTYPES === -void Video_Setup(); -void Video_Update(); +void Video_Setup(void); +void Video_Update(void); +void Video_FillRect(short X, short Y, short W, short H, uint32_t Color); // === GLOBALS === // === CODE === -void Video_Setup() +void Video_Setup(void) { int tmpInt; @@ -58,8 +59,20 @@ void Video_Setup() Video_Update(); } -void Video_Update() +void Video_Update(void) { - seek(giTerminalFD, 0, SEEK_SET); + //seek(giTerminalFD, 0, SEEK_SET); + seek(giTerminalFD, 0, 1); write(giTerminalFD, giScreenWidth*giScreenHeight*4, gpScreenBuffer); } + +void Video_FillRect(short X, short Y, short W, short H, uint32_t Color) +{ + uint32_t *buf = gpScreenBuffer + Y*giScreenWidth + X; + + while( H -- ) + { + memset32( buf, Color, W ); + buf += giScreenWidth; + } +} diff --git a/Usermode/Libraries/libaxwin2.so_src/Makefile b/Usermode/Libraries/libaxwin2.so_src/Makefile index 55291404..2ce02e44 100644 --- a/Usermode/Libraries/libaxwin2.so_src/Makefile +++ b/Usermode/Libraries/libaxwin2.so_src/Makefile @@ -7,7 +7,7 @@ CPPFLAGS += CFLAGS += -Wall LDFLAGS += -lc -soname libaxwin2.so -OBJ = main.o messages.o windows.o +OBJ = main.o messages.o BIN = ../libaxwin2.so include ../Makefile.tpl diff --git a/Usermode/Libraries/libaxwin2.so_src/common.h b/Usermode/Libraries/libaxwin2.so_src/common.h index 28d28390..f0a7ea15 100644 --- a/Usermode/Libraries/libaxwin2.so_src/common.h +++ b/Usermode/Libraries/libaxwin2.so_src/common.h @@ -22,5 +22,6 @@ enum eAxWin_Modes // === Variables === extern int giAxWin_Mode; +extern int giAxWin_PID; #endif diff --git a/Usermode/Libraries/libaxwin2.so_src/main.c b/Usermode/Libraries/libaxwin2.so_src/main.c index 1a12561b..1dfcf9b2 100644 --- a/Usermode/Libraries/libaxwin2.so_src/main.c +++ b/Usermode/Libraries/libaxwin2.so_src/main.c @@ -7,12 +7,74 @@ * main.c - Library Initialisation */ #include "common.h" +#include // === GLOBALS === int giAxWin_Mode = 0; + int giAxWin_PID = 0; // === CODE === int SoMain() { return 0; } + +int AxWin_Register(const char *Name) +{ + tAxWin_Message req; + tAxWin_Message *msg; + tAxWin_RetMsg *ret; + int len = strlen(Name); + + req.ID = MSG_SREQ_REGISTER; + req.Size = 1 + (len+1)/4; + strcpy(req.Data, Name); + + AxWin_SendMessage(&req); + + for(;;) + { + msg = AxWin_WaitForMessage(); + + if(msg->ID == MSG_SREQ_ADDTAB) + { + ret = (void*) &msg->Data[0]; + if( ret->ReqID == MSG_SREQ_REGISTER ) + break; + } + + AxWin_HandleMessage(msg); + free(msg); + } + + return !!ret->Bool; +} + +tAxWin_Handle AxWin_AddTab(const char *Title) +{ + tAxWin_Message req; + tAxWin_Message *msg; + tAxWin_RetMsg *ret; + int len = strlen(Title); + + req.ID = MSG_SREQ_ADDTAB; + req.Size = 1 + (len+1)/4; + strcpy(req.Data, Title); + + for(;;) + { + msg = AxWin_WaitForMessage(); + + if(msg->ID == MSG_SRSP_RETURN) + { + ret = (void*) &msg->Data[0]; + if( ret->ReqID == MSG_SREQ_ADDTAB ) + break; + } + + AxWin_HandleMessage(msg); + free(msg); + } + + return (tAxWin_Handle) ret->Handle; +} diff --git a/Usermode/Libraries/libaxwin2.so_src/messages.c b/Usermode/Libraries/libaxwin2.so_src/messages.c index d0fc5dac..7b43bda8 100644 --- a/Usermode/Libraries/libaxwin2.so_src/messages.c +++ b/Usermode/Libraries/libaxwin2.so_src/messages.c @@ -13,7 +13,22 @@ tAxWin_Message *AxWin_WaitForMessage(); int AxWin_HandleMessage(tAxWin_Message *Message); +// === === + // === CODE === +int AxWin_SendMessage(tAxWin_Message *Message) +{ + switch(giAxWin_Mode) + { + case AXWIN_MODE_IPC: + SysSendMessage(giAxWin_PID, Message->Size*4, Message); + break; + default: + break; + } + return 0; +} + /** * \brief Loop forever, checking and waiting for messages */ diff --git a/Usermode/Libraries/libaxwin2.so_src/windows.c b/Usermode/Libraries/libaxwin2.so_src/windows.c index a37bfbbe..efb418b9 100644 --- a/Usermode/Libraries/libaxwin2.so_src/windows.c +++ b/Usermode/Libraries/libaxwin2.so_src/windows.c @@ -13,11 +13,11 @@ struct sAxWin_Window { struct sAxWin_Window *Next; uint32_t WmHandle; - tAxWin_MessageCallback Callback; + tAxWin_MessageCallback *Callback; }; // === PROTOTYPES === -tAxWin_Handle AxWin_CreateWindow( +tAxWin_Window *AxWin_CreateWindow( int16_t X, int16_t Y, int16_t W, int16_t H, uint32_t Flags, tAxWin_MessageCallback *Callback ); @@ -27,7 +27,7 @@ tAxWin_Handle AxWin_CreateWindow( tAxWin_Window *gProcessWindows; // === CODE === -tAxWin_Handle AxWin_CreateWindow( +tAxWin_Window *AxWin_CreateWindow( int16_t X, int16_t Y, int16_t W, int16_t H, uint32_t Flags, tAxWin_MessageCallback *Callback) diff --git a/Usermode/include/acess/sys.h b/Usermode/include/acess/sys.h index c3c216f5..df15569a 100644 --- a/Usermode/include/acess/sys.h +++ b/Usermode/include/acess/sys.h @@ -1,10 +1,11 @@ /* * Acess2 System Interface Header */ -#ifndef _SYS_SYS_H_ -#define _SYS_SYS_H_ +#ifndef _ACESS_SYS_H_ +#define _ACESS_SYS_H_ #include +#include // === CONSTANTS === #ifndef NULL @@ -27,8 +28,6 @@ #define FILEFLAG_SYMLINK 0x20 // === TYPES === -typedef uint pid_t; - struct s_sysACL { union { struct { @@ -73,6 +72,7 @@ extern int clone(int flags, void *stack); extern int execve(char *path, char **argv, char **envp); extern int gettid(); extern int getpid(); +extern int _SysSetFaultHandler(int (*Handler)(int)); // --- Permissions --- extern int getuid(); @@ -87,7 +87,7 @@ extern int reopen(int fd, const char *path, int flags); extern void close(int fd); extern uint read(int fd, uint length, void *buffer); extern uint write(int fd, uint length, void *buffer); -extern int seek(int fd, uint64_t offset, int whence); +extern int seek(int fd, int64_t offset, int whence); extern uint64_t tell(int fd); extern int ioctl(int fd, int id, void *data); extern int finfo(int fd, t_sysFInfo *info, int maxacls); diff --git a/Usermode/include/axwin/axwin.h b/Usermode/include/axwin/axwin.h index ee160b80..cacf1d83 100644 --- a/Usermode/include/axwin/axwin.h +++ b/Usermode/include/axwin/axwin.h @@ -7,11 +7,14 @@ #define _AXWIN_AXWIN_H // === Core Types === -typedef unsigned int tAxWin_Handle; +typedef void *tAxWin_Handle; // === Messaging === #include "messages.h" extern int AxWin_MessageLoop(); +extern int AxWin_SendMessage(tAxWin_Message *Message); +extern tAxWin_Message *AxWin_WaitForMessage(void); +extern int AxWin_HandleMessage(tAxWin_Message *Message); // === Window Control === /** @@ -30,7 +33,7 @@ typedef int tAxWin_MessageCallback(tAxWin_Message *); /** * \} */ -extern tAxWin_Window AxWin_CreateWindow( +extern tAxWin_Window *AxWin_CreateWindow( int16_t X, int16_t Y, int16_t W, int16_t H, uint32_t Flags, tAxWin_MessageCallback *Callback); diff --git a/Usermode/include/axwin/messages.h b/Usermode/include/axwin/messages.h index b27583ef..8a14223f 100644 --- a/Usermode/include/axwin/messages.h +++ b/Usermode/include/axwin/messages.h @@ -9,6 +9,13 @@ #include typedef struct sAxWin_Message tAxWin_Message; +typedef struct sAxWin_RetMsg tAxWin_RetMsg; + +// Higherarchy: +// - HANDLE +// + ELEMENT +// > DIALOG +// > TAB /** * \brief Message IDs @@ -20,11 +27,11 @@ enum eAxWin_Messages // - Windows MSG_SREQ_REGISTER, // bool (char[] Name) - Registers this PID with the Window Manager - MSG_SREQ_ADDTAB, // ELEMENT (char[] Name) - Adds a tab to the window + MSG_SREQ_ADDTAB, // TAB (char[] Name) - Adds a tab to the window MSG_SREQ_DELTAB, // void (TAB Tab) - Closes a tab - MSG_SREQ_NEWDIALOG, // ELEMENT (ELEMENT Parent, char[] Name) - Creates a dialog - MSG_SREQ_DELDIALOG, // void (ELEMENT Dialog) - Closes a dialog + MSG_SREQ_NEWDIALOG, // DIALOG (TAB Parent, char[] Name) - Creates a dialog + MSG_SREQ_DELDIALOG, // void (DIALOG Dialog) - Closes a dialog MSG_SREQ_SETNAME, // void (ELEMENT Element, char[] Name) MSG_SREQ_GETNAME, // char[] (ELEMENT Element) @@ -98,14 +105,18 @@ struct sAxWin_Message { uint16_t ID; uint16_t Size; //!< Size in DWORDS + char Data[]; +}; + +struct sAxWin_RetMsg +{ + uint16_t ReqID; + uint16_t Rsvd; union { - struct sAxWin_SReq_Ping SReq_Pong; - struct sAxWin_SReq_NewWindow SReq_NewWindow; - - // Server Responses - struct sAxWin_SRsp_Pong SRsp_Pong; - struct sAxWin_SRsp_NewWindow SRsp_Window; + uint8_t Bool; + uint32_t Handle; + int Integer; }; }; diff --git a/Usermode/include/sys/sys.h b/Usermode/include/sys/sys.h index e7858dd9..119bb6ab 100644 --- a/Usermode/include/sys/sys.h +++ b/Usermode/include/sys/sys.h @@ -1,6 +1,8 @@ /* Syscall Definitions */ +#ifndef _SYS_SYS_H_ +#define _SYS_SYS_H_ #include @@ -25,7 +27,7 @@ extern int close(int fp); extern int read(int fp, int len, void *buf); extern int write(int fp, int len, void *buf); extern int tell(int fp); -extern void seek(int fp, int dist, int flag); +extern void seek(int fp, int64_t dist, int flag); extern int fstat(int fp, t_fstat *st); extern int ioctl(int fp, int call, void *arg); extern int readdir(int fp, char *file); @@ -37,4 +39,6 @@ extern int sendmsg(int dest, unsigned int *Data); extern int pollmsg(int *src, unsigned int *Data); extern int getmsg(int *src, unsigned int *Data); -extern int _SysSetFaultHandler(int (*Handler)(int)); +#endif + +#endif diff --git a/Usermode/include/sys/types.h b/Usermode/include/sys/types.h index 03ee846b..2fad39fc 100644 --- a/Usermode/include/sys/types.h +++ b/Usermode/include/sys/types.h @@ -1,6 +1,8 @@ - +/* + */ #ifndef _SYS_TYPES_H #define _SYS_TYPES_H +#include typedef struct { int st_dev; //dev_t @@ -25,4 +27,9 @@ typedef struct { #define S_IFSOCK 0140000 /* socket */ #define S_IFIFO 0010000 /* fifo */ + +typedef uint32_t pid_t; +typedef uint32_t tid_t; +typedef int64_t time_t; + #endif