-BUILD_NUM = 1407
+BUILD_NUM = 1408
// Get message
if(Buffer != GETMSG_IGNORE)
+ {
+ if( !CheckMem( Buffer, cur->Messages->Length ) )
+ {
+ *Err = -EINVAL;
+ RELEASE( &cur->IsLocked );
+ return -1;
+ }
memcpy(Buffer, cur->Messages->Data, cur->Messages->Length);
+ }
ret = cur->Messages->Length;
// Remove from list
// -- Check for messages
case SYS_GETMSG:
CHECK_NUM_NULLOK(Regs->Arg1, sizeof(Uint));
- //NOTE: Uncertain due to length being unknown
- // (Proc_GetMessage should check itself)
- CHECK_NUM_NULLOK(Regs->Arg2, sizeof(Uint)*4);
+ if( Regs->Arg2 && Regs->Arg2 != -1 && !MM_IsUser(Regs->Arg2) )
+ {
+ err = -EINVAL; ret = -1; break;
+ }
// *Source, *Data
ret = Proc_GetMessage(&err, (Uint*)Regs->Arg1, (void*)Regs->Arg2);
break;
--- /dev/null
+# Project: Acess GUI Window Manager
+
+-include ../../Makefile.cfg
+
+CPPFLAGS += -I../include
+
+DIR = Apps/AxWin/1.0
+BIN = ../AxWinWM
+OBJ = main.o helpers.o commandline.o video.o messages.o
+
+-include ../../Makefile.tpl
--- /dev/null
+/*
+ * Acess GUI (AxWin) Version 2
+ * By John Hodge (thePowersGang)
+ */
+#include "common.h"
+#include <string.h>
+
+// === PROTOTYPES ===
+void ShowUsage(char *ProgName);
+void ShowHelp(char *ProgName);
+
+// === CODE ===
+void ParseCommandline(int argc, char *argv[])
+{
+ int i;
+ char *arg;
+
+ for( i = 1; i < argc; i++ )
+ {
+ arg = argv[i];
+ if(arg[0] == '-')
+ {
+ if( arg[1] == '-' )
+ {
+ if( strcmp(&arg[2], "help") == 0 ) {
+ ShowHelp(argv[0]);
+ exit(EXIT_SUCCESS);
+ }
+ else {
+ ShowUsage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+ }
+ else
+ {
+ while( *++arg )
+ {
+ switch(*arg)
+ {
+ case 'h':
+ case '?':
+ ShowHelp(argv[0]);
+ exit(EXIT_SUCCESS);
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+void ShowUsage(char *ProgName)
+{
+ fprintf(stderr, "Usage: %s [-h|--help]\n", ProgName);
+}
+
+void ShowHelp(char *ProgName)
+{
+ ShowUsage(ProgName);
+ fprintf(stderr, "\n");
+ fprintf(stderr, "\t--help\tShow this message\n");
+}
--- /dev/null
+/*
+ * Acess GUI (AxWin) Version 2
+ * By John Hodge (thePowersGang)
+ */
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+
+extern char *gsTerminalDevice;
+extern char *gsMouseDevice;
+
+extern int giScreenWidth;
+extern int giScreenHeight;
+extern uint32_t *gpScreenBuffer;
+
+extern int giTerminalFD;
+extern int giMouseFD;
+
+// === Functions ===
+extern void memset32(void *ptr, uint32_t val, size_t count);
+
+#endif
--- /dev/null
+/*
+ * Acess GUI (AxWin) Version 2
+ * By John Hodge (thePowersGang)
+ */
+#include "common.h"
+
+// === CODE ===
+void memset32(void *ptr, uint32_t val, size_t count)
+{
+ __asm__ __volatile__ ("rep stosl" : : "D"(ptr),"a"(val),"c"(count));
+}
--- /dev/null
+/*
+ * Acess GUI (AxWin) Version 2
+ * By John Hodge (thePowersGang)
+ */
+#include "common.h"
+#include <acess/sys.h>
+
+// === IMPORTS ===
+extern void ParseCommandline(int argc, char *argv[]);
+extern void Video_Setup();
+
+// === GLOBALS ===
+char *gsTerminalDevice = NULL;
+char *gsMouseDevice = NULL;
+
+ int giScreenWidth = 640;
+ int giScreenHeight = 480;
+uint32_t *gpScreenBuffer = NULL;
+
+ int giTerminalFD = -1;
+ int giMouseFD = -1;
+
+
+// === CODE ===
+/**
+ * \brief Program Entrypoint
+ */
+int main(int argc, char *argv[])
+{
+ ParseCommandline(argc, argv);
+
+ if( gsTerminalDevice == NULL ) {
+ gsTerminalDevice = "/Devices/VTerm/7";
+ }
+
+ Video_Setup();
+
+ // Main Loop
+ for(;;)
+ {
+ yield();
+ }
+ return 0;
+}
--- /dev/null
+/*
+ * Acess GUI (AxWin) Version 2
+ * By John Hodge (thePowersGang)
+ */
+#include "common.h"
+#include <acess/sys.h>
+#include <axwin/messages.h>
+
+#define STATICBUF_SIZE 64
+
+// === TYPES ===
+typedef void tMessages_Handle_Callback(int, size_t,void*);
+
+// === PROTOTYPES ===
+void Messages_PollIPC();
+void Messages_RespondIPC(int ID, size_t Length, void *Data);
+void Messages_Handle(tAxWin_Message *Msg, tMessages_Handle_Callback *Respond, int ID);
+
+// === GLOBALS ===
+
+// === CODE ===
+void Messages_PollIPC()
+{
+ int len;
+ int tid = 0;
+ char staticBuf[STATICBUF_SIZE];
+ tAxWin_Message *msg;
+
+ // Wait for a message
+ while( (len = SysGetMessage(&tid, NULL)) )
+ yield();
+
+ // Allocate the space for it
+ if( len <= STATICBUF_SIZE )
+ msg = (void*)staticBuf;
+ else {
+ msg = malloc( len );
+ if(!msg) {
+ fprintf(
+ stderr,
+ "ERROR - Unable to allocate message buffer, ignoring message from %i\n",
+ tid);
+ SysGetMessage(NULL, GETMSG_IGNORE);
+ return ;
+ }
+ }
+
+ // Get message data
+ SysGetMessage(NULL, msg);
+
+ Messages_Handle(msg, Messages_RespondIPC, tid);
+}
+
+void Messages_RespondIPC(int ID, size_t Length, void *Data)
+{
+ SysSendMessage(ID, Length, Data);
+}
+
+void Messages_Handle(tAxWin_Message *Msg, tMessages_Handle_Callback *Respond, int ID)
+{
+ switch(Msg->ID)
+ {
+ case MSG_REQ_PING:
+ Msg->ID = MSG_RSP_PONG;
+ Respond(ID, sizeof(Msg->ID), Msg);
+ break;
+ default:
+ fprintf(stderr, "WARNING: Unknown message %i from %i (%p)\n",
+ Msg->ID, ID, Respond);
+ break;
+ }
+}
+
--- /dev/null
+/*
+ * Acess GUI (AxWin) Version 2
+ * By John Hodge (thePowersGang)
+ */
+#include "common.h"
+#include <acess/sys.h>
+#include <acess/devices/terminal.h>
+
+// === PROTOTYPES ===
+void Video_Setup();
+void Video_Update();
+
+// === GLOBALS ===
+
+// === CODE ===
+void Video_Setup()
+{
+ int tmpInt;
+
+ // Open terminal
+ giTerminalFD = open(gsTerminalDevice, OPENFLAG_READ|OPENFLAG_WRITE);
+ if( giTerminalFD == -1 )
+ {
+ fprintf(stderr, "ERROR: Unable to open '%s' (%i)\n", gsTerminalDevice, _errno);
+ exit(-1);
+ }
+
+ // Set width
+ tmpInt = giScreenWidth;
+ tmpInt = ioctl( giTerminalFD, TERM_IOCTL_WIDTH, &tmpInt );
+ if(tmpInt != giScreenWidth)
+ {
+ fprintf(stderr, "Warning: Selected width (%i) is invalid, clipped to %i\n",
+ giScreenWidth, tmpInt);
+ giScreenWidth = tmpInt;
+ }
+
+ // Set height
+ tmpInt = giScreenHeight;
+ tmpInt = ioctl( giTerminalFD, TERM_IOCTL_HEIGHT, &tmpInt );
+ if(tmpInt != giScreenHeight)
+ {
+ fprintf(stderr, "Warning: Selected height (%i) is invalid, clipped to %i\n",
+ giScreenHeight, tmpInt);
+ giScreenHeight = tmpInt;
+ }
+
+ // Set mode to video
+ tmpInt = TERM_MODE_FB;
+ ioctl( giTerminalFD, TERM_IOCTL_MODETYPE, &tmpInt );
+
+ // Force VT8 to be shown
+ ioctl( giTerminalFD, TERM_IOCTL_FORCESHOW, NULL );
+
+ // Create local framebuffer (back buffer)
+ gpScreenBuffer = malloc( giScreenWidth*giScreenHeight*4 );
+ memset32( gpScreenBuffer, 0x8888FF, giScreenWidth*giScreenHeight );
+ Video_Update();
+}
+
+void Video_Update()
+{
+ seek(giTerminalFD, 0, SEEK_SET);
+ write(giTerminalFD, giScreenWidth*giScreenHeight*4, gpScreenBuffer);
+}
--- /dev/null
+/**
+ * \file messages.h
+ * \author John Hodge (thePowersGang)
+ * \brief AxWin Control Messages and structures
+ */
+#ifndef _AXWIN_MESSAGES_H
+#define _AXWIN_MESSAGES_H
+
+typedef struct sAxWin_Message tAxWin_Message;
+
+/**
+ * \brief Message IDs
+ */
+enum eAxWin_Messages
+{
+ // Server Requests
+ MSG_SREQ_PING,
+ // - Windows
+ MSG_SREQ_NEWWINDOW,
+ MSG_SREQ_GETFLAGS, MSG_SREQ_SETFLAGS,
+ MSG_SREQ_GETRECT, MSG_SREQ_SETRECT,
+ // - Drawing
+ MSG_SREQ_SETCOL,
+ MSG_SREQ_PSET,
+ MSG_SREQ_LINE, MSG_SREQ_CURVE,
+ MSG_SREQ_RECT, MSG_SREQ_FILLRECT,
+ MSG_SREQ_RIMG, MSG_SREQ_SIMG, // Register/Set Image
+ MSG_SREQ_SETFONT, MSG_SREQ_PUTTEXT,
+
+ // Server Responses
+ MSG_SRSP_PONG,
+ MSG_SRSP_IMG, // Returns the image ID
+
+ NUM_MSG
+};
+
+/**
+ * \brief New Window Request structure
+ */
+struct sAxWin_Req_NewWindow
+{
+
+};
+
+/**
+ * \brief Overarching Message Structure
+ * \note sizeof(tAxWin_Message) is never valid
+ */
+struct sAxWin_Message
+{
+ uint16_t ID;
+ uint16_t Size; //!< Size in DWORDS
+};
+
+#endif