From 35deed8c7c86493b4025a73777fb6d8fe0b818ab Mon Sep 17 00:00:00 2001
From: Eduard Burtescu <eddy_me08@yahoo.com>
Date: Mon, 6 Sep 2010 10:49:58 +0300
Subject: [PATCH] That's about everything related to the bug...
---
src/modules/system/TUI/Console.cc | 6 -
src/modules/system/TUI/Console.h | 3 -
src/modules/system/TUI/TuiSyscallManager.cc | 169 +--------------------------
src/modules/system/TUI/TuiSyscallManager.h | 37 ++----
src/modules/system/TUI/tuiSyscallNumbers.h | 32 +----
src/subsys/native/include/input/Input.h | 8 +-
src/subsys/native/user/input/Input.cc | 22 ++++-
src/subsys/pedigree-c/pedigree-syscalls.cc | 25 ++++-
src/subsys/pedigree-c/pedigree-syscalls.h | 2 +-
src/subsys/posix/system-syscalls.cc | 25 +----
src/user/applications/TUI/Font.cc | 32 +++---
src/user/applications/TUI/Png.cc | 28 ++---
src/user/applications/TUI/Terminal.cc | 14 +-
src/user/applications/TUI/environment.cc | 92 +--------------
src/user/applications/TUI/environment.h | 9 --
src/user/applications/TUI/main.cc | 48 +++-----
16 files changed, 121 insertions(+), 431 deletions(-)
diff --git a/src/modules/system/TUI/Console.cc b/src/modules/system/TUI/Console.cc
index 5bec562..bee4ffc 100644
--- a/src/modules/system/TUI/Console.cc
+++ b/src/modules/system/TUI/Console.cc
@@ -100,7 +100,6 @@ size_t UserConsole::nextRequest(size_t responseToLast, char *buffer, size_t *sz,
// and it was just freed by us if it was async).
m_pReq = 0;
}
-
m_RequestQueueMutex.release();
// Sleep on the queue length semaphore - wake when there's something to do.
@@ -171,11 +170,6 @@ size_t UserConsole::nextRequest(size_t responseToLast, char *buffer, size_t *sz,
delete [] reinterpret_cast<uint8_t*>(m_pReq->p4);
}
}
- else if (command == TUI_CHAR_RECV || command == TUI_MODE_CHANGED)
- {
- memcpy(buffer, reinterpret_cast<uint8_t*>(&m_pReq->p3), 8);
- *sz = 8;
- }
return command;
}
diff --git a/src/modules/system/TUI/Console.h b/src/modules/system/TUI/Console.h
index c0f32eb..b786ccc 100644
--- a/src/modules/system/TUI/Console.h
+++ b/src/modules/system/TUI/Console.h
@@ -18,9 +18,6 @@
#include <console/Console.h>
-#define TUI_MODE_CHANGED 98
-#define TUI_CHAR_RECV 99
-
class UserConsole : public RequestQueue
{
public:
diff --git a/src/modules/system/TUI/TuiSyscallManager.cc b/src/modules/system/TUI/TuiSyscallManager.cc
index 657a9ac..a981251 100644
--- a/src/modules/system/TUI/TuiSyscallManager.cc
+++ b/src/modules/system/TUI/TuiSyscallManager.cc
@@ -35,83 +35,9 @@ UserConsole *g_UserConsole = 0;
size_t g_UserConsoleId = 0;
TuiSyscallManager g_TuiSyscallManager;
-extern Display *g_pDisplay;
-extern Display::ScreenMode g_ScreenMode;
-
-/// \todo Key presses should go to the TUI immediately, rather than going onto
-/// the request queue and waiting for it to complete a write to the
-/// screen. At the moment things like CTRL-C are not handled until after
-/// a write is complete, which is usually alright, but can cause CTRL-C
-/// to appear to simply not work at all.
-void callback(InputManager::InputNotification ¬e)
-{
- if(note.type != InputManager::Key)
- return; // Ignore any non-keyboard input
-
- if (!g_UserConsole)
- {
- WARNING("Key called with no console");
- return;
- }
-
- // Ensure this is sent with highest priority (0).
- g_UserConsole->addAsyncRequest(0, TUI_CHAR_RECV, g_UserConsoleId, note.data.key.key);
- ConsoleManager::instance().getConsoleFile(g_UserConsole)->dataIsReady();
-}
-
-void pedigree_event_return()
-{
- // Return to the old code
- Processor::information().getScheduler().eventHandlerReturned();
-
- FATAL("event_return: should never get here");
-}
-
-void pedigree_input_register_callback(uintptr_t func)
-{
- InputManager::instance().installCallback(InputManager::Key,
- reinterpret_cast<void (*)(InputManager::InputNotification&)>(func),
- Processor::information().getCurrentThread());
-}
-
-extern "C" void tuiModeChangedCallback()
-{
- if (!g_UserConsole)
- {
- WARNING("Mode changed called with no console");
- return;
- }
-
- /// \todo Multiple displays.
- Config::Result *pResult = Config::instance().query("SELECT width,height FROM displays d, 'display-modes' m WHERE m.mode_id=d.mode_id");
- if (!pResult->succeeded() || !pResult->rows())
- {
- FATAL("Uh oh...");
- }
- uint64_t width = static_cast<uint64_t> (pResult->getNum(0, "width"));
- uint64_t height = static_cast<uint64_t> (pResult->getNum(0, "height"));
- uint64_t a = (height<<32)|width;
- NOTICE("width: " << Hex << width << ", height: " << height << ", a: " << a);
- delete pResult;
-
- g_UserConsole->addAsyncRequest(0, TUI_MODE_CHANGED, g_UserConsoleId, a);
-}
-
-TuiSyscallManager::TuiSyscallManager() :
- m_pDisplay(0)
-{
-}
-
-TuiSyscallManager::~TuiSyscallManager()
-{
-}
-
void TuiSyscallManager::initialise()
{
- m_pDisplay = g_pDisplay;
-
SyscallManager::instance().registerSyscallHandler(TUI, this);
- // InputManager::instance().installCallback(InputManager::Key, callback);
}
uintptr_t TuiSyscallManager::call(uintptr_t function, uintptr_t p1, uintptr_t p2, uintptr_t p3, uintptr_t p4, uintptr_t p5)
@@ -133,28 +59,12 @@ uintptr_t TuiSyscallManager::syscall(SyscallState &state)
uintptr_t p5 = state.getSyscallParameter(4);
static uintptr_t currBuff = 0;
+ //NOTICE("TUI SYSCALL ");// << state.getSyscallNumber() << " " << p1 << " " << p2 << " " << p3 << " " << p4 << " " << p5);
switch (state.getSyscallNumber())
{
case TUI_NEXT_REQUEST:
return g_UserConsole->nextRequest(p1, reinterpret_cast<char*>(p2), reinterpret_cast<size_t*>(p3), p4, reinterpret_cast<size_t*>(p5));
- case TUI_LOG:
- {
- // This is the solution to a bug - if the address in p1 traps (because of demand loading),
- // it MUST trap before we get the log spinlock, else other things will
- // want to write to it and deadlock.
- static char buf[1024];
- strncpy(buf, reinterpret_cast<char*>(p1), 1023);
- buf[1023] = '\0';
- NOTICE("TUI: " << buf);
- return 0;
- }
- case TUI_GETFB:
- {
- Display::ScreenMode *sm = reinterpret_cast<Display::ScreenMode*>(p1);
- *sm = g_ScreenMode;
- return 0;
- }
case TUI_REQUEST_PENDING:
{
if (!g_UserConsole)
@@ -200,77 +110,6 @@ uintptr_t TuiSyscallManager::syscall(SyscallState &state)
g_UserConsole = g_Consoles[p1];
break;
}
- case TUI_VID_NEW_BUFFER:
- {
- if (!m_pDisplay) return 0;
- NOTICE("Getting new buffer.");
- return reinterpret_cast<uintptr_t> (m_pDisplay->newBuffer());
- }
- case TUI_VID_SET_BUFFER:
- {
- vid_req_t *pReq = reinterpret_cast<vid_req_t*>(p1);
- if (!m_pDisplay) return 0;
-
- currBuff = p1;
- m_pDisplay->setCurrentBuffer(reinterpret_cast<Display::rgb_t*>(p1));
- break;
- }
- case TUI_VID_UPDATE_BUFFER:
- {
- if (!m_pDisplay) return 0;
- vid_req_t *pReq = reinterpret_cast<vid_req_t*>(p1);
-
- if(currBuff && (reinterpret_cast<uintptr_t>(pReq->buffer) != currBuff))
- {
- WARNING("updateBuffer called on a buffer which is not currently active");
- }
- else
- {
- m_pDisplay->updateBuffer(reinterpret_cast<Display::rgb_t*>(pReq->buffer), pReq->x, pReq->y, pReq->x2,
- pReq->y2);
- }
- break;
- }
- case TUI_VID_KILL_BUFFER:
- {
- if (!m_pDisplay) return 0;
-
- m_pDisplay->killBuffer(reinterpret_cast<Display::rgb_t*>(p1));
- break;
- }
- case TUI_VID_BIT_BLIT:
- {
- if (!m_pDisplay) return 0;
-
- vid_req_t *pReq = reinterpret_cast<vid_req_t*>(p1);
-
- if(currBuff && (reinterpret_cast<uintptr_t>(pReq->buffer) != currBuff))
- {
- WARNING("bitBlit called on a buffer which is not currently active");
- }
- else
- {
- m_pDisplay->bitBlit(reinterpret_cast<Display::rgb_t*>(pReq->buffer), pReq->x, pReq->y, pReq->x2,
- pReq->y2, pReq->w, pReq->h);
- }
- break;
- }
- case TUI_VID_FILL_RECT:
- {
- if (!m_pDisplay) return 0;
-
- vid_req_t *pReq = reinterpret_cast<vid_req_t*>(p1);
-
- m_pDisplay->fillRectangle(reinterpret_cast<Display::rgb_t*>(pReq->buffer), pReq->x, pReq->y, pReq->w,
- pReq->h, *reinterpret_cast<Display::rgb_t*>(pReq->c));
- break;
- }
- case TUI_EVENT_RETURNED:
- pedigree_event_return();
- break;
- case TUI_INPUT_REGISTER_CALLBACK:
- pedigree_input_register_callback(static_cast<uintptr_t>(p1));
- break;
case TUI_STOP_REQUEST_QUEUE:
g_UserConsole->stopCurrentBlock();
break;
@@ -288,8 +127,4 @@ static void destroy()
{
}
-#ifdef X86_COMMON
-MODULE_INFO("TUI", &init, &destroy, "console", "vbe");
-#else
-MODULE_INFO("TUI", &init, &destroy, "console");
-#endif
+MODULE_INFO("TUI", &init, &destroy, "console", "gfx-deps");
diff --git a/src/modules/system/TUI/TuiSyscallManager.h b/src/modules/system/TUI/TuiSyscallManager.h
index 7030ae4..00be858 100644
--- a/src/modules/system/TUI/TuiSyscallManager.h
+++ b/src/modules/system/TUI/TuiSyscallManager.h
@@ -18,38 +18,23 @@
#include <processor/types.h>
#include <processor/SyscallHandler.h>
-#include <processor/PhysicalMemoryManager.h>
-#include <processor/MemoryRegion.h>
-#include <machine/Display.h>
class TuiSyscallManager : public SyscallHandler
{
-public:
- void initialise();
+ public:
+ /// The constructor
+ TuiSyscallManager() {}
+ /// The destructor
+ virtual ~TuiSyscallManager() {}
- /** Calls a syscall. */
- uintptr_t call(uintptr_t function, uintptr_t p1=0, uintptr_t p2=0, uintptr_t p3=0, uintptr_t p4=0, uintptr_t p5=0);
+ /// Initialise the TUI syscall manager
+ void initialise();
- /** Called when a syscall arrives. */
- virtual uintptr_t syscall(SyscallState &state);
+ /// Calls a syscall
+ uintptr_t call(uintptr_t function, uintptr_t p1=0, uintptr_t p2=0, uintptr_t p3=0, uintptr_t p4=0, uintptr_t p5=0);
- /** The constructor */
- TuiSyscallManager();
- /** The destructor */
- virtual ~TuiSyscallManager();
-
- // Called by video drivers to inform us that a mode change has taken place.
- void modeChanged(Display *pDisplay, Display::ScreenMode mode, uintptr_t pFramebuffer, size_t pFbSize);
-
-private:
- /** The copy-constructor
- *\note Not implemented (singleton) */
- TuiSyscallManager(const TuiSyscallManager &);
- /** The copy-constructor
- *\note Not implemented (singleton) */
- TuiSyscallManager &operator = (const TuiSyscallManager &);
-
- Display *m_pDisplay;
+ /// Called when a syscall arrives
+ virtual uintptr_t syscall(SyscallState &state);
};
#endif
diff --git a/src/modules/system/TUI/tuiSyscallNumbers.h b/src/modules/system/TUI/tuiSyscallNumbers.h
index a0ea360..a34b23d 100644
--- a/src/modules/system/TUI/tuiSyscallNumbers.h
+++ b/src/modules/system/TUI/tuiSyscallNumbers.h
@@ -17,31 +17,13 @@
#ifndef SYSCALL_NUMBERS_H
#define SYSCALL_NUMBERS_H
-struct vid_req_t
-{
- struct rgb_t *buffer;
- size_t x, y, x2, y2, w, h;
- struct rgb_t *c;
-};
+#define TUI_NEXT_REQUEST 1
+#define TUI_REQUEST_PENDING 2
+#define TUI_RESPOND_TO_PENDING 3
+#define TUI_STOP_REQUEST_QUEUE 4
-#define TUI_NEXT_REQUEST 1
-#define TUI_LOG 2
-#define TUI_GETFB 3
-#define TUI_REQUEST_PENDING 4
-#define TUI_RESPOND_TO_PENDING 5
-#define TUI_CREATE_CONSOLE 6
-#define TUI_SET_CTTY 7
-#define TUI_SET_CURRENT_CONSOLE 8
-
-#define TUI_VID_NEW_BUFFER 9
-#define TUI_VID_SET_BUFFER 10
-#define TUI_VID_UPDATE_BUFFER 11
-#define TUI_VID_KILL_BUFFER 12
-#define TUI_VID_BIT_BLIT 13
-#define TUI_VID_FILL_RECT 14
-
-#define TUI_EVENT_RETURNED 15
-#define TUI_INPUT_REGISTER_CALLBACK 16
-#define TUI_STOP_REQUEST_QUEUE 17
+#define TUI_CREATE_CONSOLE 5
+#define TUI_SET_CTTY 6
+#define TUI_SET_CURRENT_CONSOLE 7
#endif
diff --git a/src/subsys/native/include/input/Input.h b/src/subsys/native/include/input/Input.h
index 9228ad4..066ecf5 100755
--- a/src/subsys/native/include/input/Input.h
+++ b/src/subsys/native/include/input/Input.h
@@ -13,8 +13,8 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifndef _INPUT_MANAGER_H
-#define _INPUT_MANAGER_H
+#ifndef _INPUT_H
+#define _INPUT_H
#include <types.h>
@@ -26,7 +26,7 @@ namespace Input
const int Joystick = 4;
const int RawKey = 8;
const int Unknown = 255;
-
+
typedef int CallbackType;
/// Structure containing notification to the remote application
@@ -55,7 +55,7 @@ namespace Input
/// HID scancode for the key (most generic type of scancode,
/// and easy to build translation tables for)
uint8_t scancode;
-
+
/// Whether this is a keyUp event or not.
bool keyUp;
} rawkey;
diff --git a/src/subsys/native/user/input/Input.cc b/src/subsys/native/user/input/Input.cc
index e02a794..4e8b653 100755
--- a/src/subsys/native/user/input/Input.cc
+++ b/src/subsys/native/user/input/Input.cc
@@ -15,6 +15,7 @@
*/
#include <input/Input.h>
#include <pedigree-c/pedigree-syscalls.h>
+#include <stdio.h>
using namespace Input;
@@ -42,5 +43,24 @@ void Input::removeCallback(callback_t cb)
void Input::loadKeymapFromFile(const char *path)
{
- /// \todo Implement
+ // Load the file in to a buffer.
+ FILE *pFile = fopen(path, "r");
+ if (!pFile)
+ {
+ fprintf(stderr, "Input::loadKeymapFromFile: Error opening file `%s'.\n", path);
+ return;
+ }
+
+ // Get the length of the file
+ fseek(pFile, 0, SEEK_END);
+ size_t nLength = ftell(pFile);
+ fseek(pFile, 0, SEEK_SET);
+
+ // Read the file
+ uint8_t *pBuffer = new uint8_t [nLength];
+ fread(pBuffer, 1, nLength, pFile);
+ fclose(pFile);
+
+ if(pedigree_load_keymap((char*)pBuffer, nLength))
+ fprintf(stderr, "Input::loadKeymapFromFile: Error loading keymap\n");
}
diff --git a/src/subsys/pedigree-c/pedigree-syscalls.cc b/src/subsys/pedigree-c/pedigree-syscalls.cc
index 854f435..cbbd704 100644
--- a/src/subsys/pedigree-c/pedigree-syscalls.cc
+++ b/src/subsys/pedigree-c/pedigree-syscalls.cc
@@ -23,6 +23,7 @@
#include <syscallError.h>
#include <machine/InputManager.h>
+#include <machine/KeymapManager.h>
#include <graphics/Graphics.h>
#include <graphics/GraphicsService.h>
@@ -209,7 +210,7 @@ void pedigree_module_load(char *_file)
// Map the module in the memory
uintptr_t buffer;
MemoryMappedFile *pMmFile = MemoryMappedFileManager::instance().map(file, buffer);
- KernelElf::instance().loadModule(reinterpret_cast<uint8_t *>(buffer), file->getSize(), true);
+ KernelElf::instance().loadModule(reinterpret_cast<uint8_t*>(buffer), file->getSize(), true);
MemoryMappedFileManager::instance().unmap(pMmFile);
}
@@ -254,6 +255,28 @@ void pedigree_input_remove_callback(void *p)
Processor::information().getCurrentThread());
}
+int pedigree_load_keymap(char *buf, size_t len)
+{
+ // File format: 0 Sparse tree offset
+ // 4 Data tree offset
+ // ... Sparse tree & data tree.
+
+ uint32_t sparseTableOffset = *reinterpret_cast<uint32_t*>(&buf[0]);
+ uint32_t dataTableOffset = *reinterpret_cast<uint32_t*>(&buf[4]);
+ uint32_t sparseTableSize = dataTableOffset - sparseTableOffset;
+ uint32_t dataTableSize = len - dataTableOffset;
+
+ uint8_t *sparseTable = new uint8_t[sparseTableSize];
+ memcpy(sparseTable, &buf[sparseTableOffset], sparseTableSize);
+
+ uint8_t *dataTable = new uint8_t[dataTableSize];
+ memcpy(dataTable, &buf[dataTableOffset], dataTableSize);
+
+ KeymapManager::instance().useKeymap(sparseTable, dataTable);
+
+ return 0;
+}
+
int pedigree_gfx_get_provider(void *p)
{
if(!p)
diff --git a/src/subsys/pedigree-c/pedigree-syscalls.h b/src/subsys/pedigree-c/pedigree-syscalls.h
index 4ef7d0b..f3f7262 100644
--- a/src/subsys/pedigree-c/pedigree-syscalls.h
+++ b/src/subsys/pedigree-c/pedigree-syscalls.h
@@ -66,7 +66,6 @@ void pedigree_config_get_error_message(size_t resultIdx, char *buf, int buflen);
int pedigree_login(int uid, const char *password);
-int pedigree_load_keymap(char *buffer, size_t len);
int pedigree_reboot();
void pedigree_module_load(char *file);
@@ -84,6 +83,7 @@ extern "C" {
void pedigree_input_install_callback(void *p, uint32_t type, uintptr_t param);
void pedigree_input_remove_callback(void *p);
+int pedigree_load_keymap(char *buffer, size_t len);
void pedigree_event_return();
diff --git a/src/subsys/posix/system-syscalls.cc b/src/subsys/posix/system-syscalls.cc
index 9e9c038..0f45710 100644
--- a/src/subsys/posix/system-syscalls.cc
+++ b/src/subsys/posix/system-syscalls.cc
@@ -50,7 +50,6 @@
#include <PosixProcess.h>
#include <users/UserManager.h>
-#include <machine/KeymapManager.h>
//
// Syscalls pertaining to system operations.
//
@@ -101,7 +100,7 @@ static char **load_string_array(Vector<String*> &rArray, uintptr_t arrayLoc, uin
long posix_sbrk(int delta)
{
SC_NOTICE("sbrk(" << delta << ")");
-
+
long ret = reinterpret_cast<long>(
Processor::information().getVirtualAddressSpace().expandHeap (delta, VirtualAddressSpace::Write));
SC_NOTICE(" -> " << ret);
@@ -852,28 +851,6 @@ int posix_getpgrp()
return pProcess->getId(); // Fallback if no ProcessGroup pointer yet
}
-int pedigree_load_keymap(char *buf, size_t len)
-{
- // File format: 0 Sparse tree offset
- // 4 Data tree offset
- // ... Sparse tree & data tree.
-
- uint32_t sparseTableOffset = *reinterpret_cast<uint32_t*>(&buf[0]);
- uint32_t dataTableOffset = *reinterpret_cast<uint32_t*>(&buf[4]);
- uint32_t sparseTableSize = dataTableOffset - sparseTableOffset;
- uint32_t dataTableSize = len - dataTableOffset;
-
- uint8_t *sparseTable = new uint8_t[sparseTableSize];
- memcpy(sparseTable, &buf[sparseTableOffset], sparseTableSize);
-
- uint8_t *dataTable = new uint8_t[dataTableSize];
- memcpy(dataTable, &buf[dataTableOffset], dataTableSize);
-
- KeymapManager::instance().useKeymap(sparseTable, dataTable);
-
- return 0;
-}
-
int posix_syslog(const char *msg, int prio)
{
if(Processor::information().getCurrentThread()->getParent()->getId() <= 1)
diff --git a/src/user/applications/TUI/Font.cc b/src/user/applications/TUI/Font.cc
index 3f887c7..6263ffc 100644
--- a/src/user/applications/TUI/Font.cc
+++ b/src/user/applications/TUI/Font.cc
@@ -16,6 +16,8 @@
#include "Font.h"
+#include <syslog.h>
+
#include <graphics/Graphics.h>
extern PedigreeGraphics::Framebuffer *g_pFramebuffer;
@@ -34,8 +36,7 @@ Font::Font(size_t requestedSize, const char *pFilename, bool bCache, size_t nWid
error = FT_Init_FreeType(&m_Library);
if (error)
{
- sprintf(str, "Freetype init error: %d\n", error);
- log(str);
+ syslog(LOG_ALERT, "Freetype init error: %d", error);
return;
}
m_bLibraryInitialised = true;
@@ -45,22 +46,19 @@ Font::Font(size_t requestedSize, const char *pFilename, bool bCache, size_t nWid
&m_Face);
if (error == FT_Err_Unknown_File_Format)
{
- sprintf(str, "Freetype font format error.\n");
- log(str);
+ syslog(LOG_ALERT, "Freetype font format error");
return;
}
else if (error)
{
- sprintf(str, "Freetype font load error: %d\n", error);
- log(str);
+ syslog(LOG_ALERT, "Freetype font load error: %d", error);
return;
}
- error = FT_Set_Pixel_Sizes(m_Face, 0, requestedSize);
+ error = FT_Set_Pixel_Sizes(m_Face, 0, requestedSize);
if (error)
{
- sprintf(str, "Freetype set pixel size error: %d\n", error);
- log(str);
+ syslog(LOG_ALERT, "Freetype set pixel size error: %d", error);
return;
}
@@ -119,9 +117,9 @@ void Font::drawGlyph(PedigreeGraphics::Framebuffer *pFb, Glyph *pBitmap, int lef
{
if(!g_pFramebuffer)
return;
-
+
pFb->blit(pBitmap->pBlitBuffer, 0, 0, left, top, m_CellWidth, m_CellHeight);
-
+
/*
for (size_t y = top; y < top+m_CellHeight; y++)
{
@@ -138,7 +136,7 @@ Font::Glyph *Font::generateGlyph(uint32_t c, uint32_t f, uint32_t b)
{
Glyph *pGlyph = new Glyph;
pGlyph->buffer = new rgb_t[m_CellWidth*m_CellHeight];
-
+
rgb_t back, front;
back.r = (b & 0xFF0000) >> 16;
back.g = (b & 0xFF00) >> 8;
@@ -155,12 +153,10 @@ Font::Glyph *Font::generateGlyph(uint32_t c, uint32_t f, uint32_t b)
int error = FT_Load_Char(m_Face, c, FT_LOAD_RENDER);
if (error)
{
- char str[64];
- sprintf(str, "Freetype load char error: %d\n", error);
- log(str);
+ syslog(LOG_ALERT, "Freetype load char error: %d", error);
return 0;
}
-
+
for (ssize_t r = 0; r < m_Face->glyph->bitmap.rows; r++)
{
if (r >= static_cast<ssize_t>(m_CellHeight)) break;
@@ -174,9 +170,9 @@ Font::Glyph *Font::generateGlyph(uint32_t c, uint32_t f, uint32_t b)
pGlyph->buffer[idx] = interpolateColour(front, back, m_Face->glyph->bitmap.buffer[gidx]);
}
}
-
+
pGlyph->pBlitBuffer = g_pFramebuffer->createBuffer(pGlyph->buffer, PedigreeGraphics::Bits32_Rgb, m_CellWidth, m_CellHeight);
-
+
return pGlyph;
}
diff --git a/src/user/applications/TUI/Png.cc b/src/user/applications/TUI/Png.cc
index 04e9da6..ecc0a62 100644
--- a/src/user/applications/TUI/Png.cc
+++ b/src/user/applications/TUI/Png.cc
@@ -15,18 +15,18 @@
*/
#include "Png.h"
+
+#include <syslog.h>
#include <unistd.h>
Png::Png(const char *filename) :
m_PngPtr(0), m_InfoPtr(0), m_nWidth(0), m_nHeight(0), m_pRowPointers(0)
{
- char str[64];
-
// Open the file.
FILE *stream = fopen(filename, "rb");
if (!stream)
{
- log("PNG file failed to open.");
+ syslog(LOG_ALERT, "PNG file failed to open");
return;
}
@@ -34,12 +34,12 @@ Png::Png(const char *filename) :
char buf[4];
if (fread(buf, 1, 4, stream) != 4)
{
- log("PNG file failed to read ident.");
+ syslog(LOG_ALERT, "PNG file failed to read ident");
return;
}
if (png_sig_cmp(reinterpret_cast<png_byte*>(buf), 0, 4) != 0)
{
- log("PNG file failed IDENT check.");
+ syslog(LOG_ALERT, "PNG file failed IDENT check");
return;
}
@@ -48,14 +48,14 @@ Png::Png(const char *filename) :
if (m_PngPtr == 0)
{
- log("PNG file failed to initialise");
+ syslog(LOG_ALERT, "PNG file failed to initialise");
return;
}
m_InfoPtr = png_create_info_struct(m_PngPtr);
if (m_InfoPtr == 0)
{
- log("PNG info failed to initialise");
+ syslog(LOG_ALERT, "PNG info failed to initialise");
return;
}
@@ -65,11 +65,11 @@ Png::Png(const char *filename) :
png_set_palette_to_rgb(m_PngPtr);
- png_read_png(m_PngPtr, m_InfoPtr,
+ png_read_png(m_PngPtr, m_InfoPtr,
PNG_TRANSFORM_STRIP_16 | // 16-bit-per-channel down to 8.
PNG_TRANSFORM_STRIP_ALPHA | // No alpha
PNG_TRANSFORM_PACKING , // Unpack 2 and 4 bit samples.
-
+
reinterpret_cast<void*>(0));
m_pRowPointers = reinterpret_cast<uint8_t**>(png_get_rows(m_PngPtr, m_InfoPtr));
@@ -80,18 +80,16 @@ Png::Png(const char *filename) :
if (bit_depth != 8)
{
- log("PNG - invalid bit depth");
+ syslog(LOG_ALERT, "PNG - invalid bit depth");
return;
}
if (color_type != PNG_COLOR_TYPE_RGB)
{
- sprintf(str, "PNG - invalid colour type: %d", color_type);
- log(str);
+ syslog(LOG_ALERT, "PNG - invalid colour type: %d", color_type);
return;
}
- sprintf(str, "PNG loaded %ul %ul\n", m_nWidth, m_nHeight);
- log(str);
+ syslog(LOG_ALERT, "PNG loaded %ul %ul", m_nWidth, m_nHeight);
}
Png::~Png()
@@ -113,7 +111,7 @@ void Png::render(rgb_t *pFb, size_t x, size_t y, size_t width, size_t height)
rgb.g = m_pRowPointers[r][c*3+1];
rgb.b = m_pRowPointers[r][c*3+2];
rgb.a = 255;
-
+
pFb[(r+y)*width + (c+x)] = rgb;
}
}
diff --git a/src/user/applications/TUI/Terminal.cc b/src/user/applications/TUI/Terminal.cc
index 6d06829..6c39ee7 100644
--- a/src/user/applications/TUI/Terminal.cc
+++ b/src/user/applications/TUI/Terminal.cc
@@ -36,7 +36,7 @@ Terminal::Terminal(char *pName, size_t nWidth, size_t nHeight, Header *pHeader,
// Create a new backbuffer.
// m_pBuffer = Syscall::newBuffer();
// if (!m_pBuffer) log("Buffer not created correctly!");
-
+
m_pFramebuffer = g_pFramebuffer->createChild(m_OffsetLeft, m_OffsetTop, nWidth, nHeight);
if((!m_pFramebuffer) || (!m_pFramebuffer->getRawBuffer()))
return;
@@ -76,7 +76,7 @@ Terminal::Terminal(char *pName, size_t nWidth, size_t nHeight, Header *pHeader,
close(2);
Syscall::setCtty(pName);
execl("/applications/login", "/applications/login", 0);
- log("Launching login failed!");
+ syslog(LOG_ALERT, "Launching login failed!");
}
m_Pid = pid;
@@ -91,13 +91,13 @@ void Terminal::renewBuffer(size_t nWidth, size_t nHeight)
{
if(!m_pFramebuffer)
return;
-
+
delete m_pFramebuffer;
-
+
m_pFramebuffer = g_pFramebuffer->createChild(m_OffsetLeft, m_OffsetTop, nWidth, nHeight);
if((!m_pFramebuffer) || (!m_pFramebuffer->getRawBuffer()))
return;
-
+
uint32_t backColourInt = PedigreeGraphics::createRgb(g_MainBackgroundColour.r, g_MainBackgroundColour.g, g_MainBackgroundColour.b);
m_pFramebuffer->rect(0, 0, nWidth, nHeight, backColourInt, PedigreeGraphics::Bits24_Rgb);
@@ -146,7 +146,7 @@ void Terminal::addToQueue(uint64_t key)
else
{
uint32_t utf32 = key&0xFFFFFFFF;
-
+
// Begin Utf-32 -> Utf-8 conversion.
char buf[4];
size_t nbuf = 0;
@@ -292,7 +292,7 @@ void Terminal::setActive(bool b, DirtyRectangle &rect)
{
// Force complete redraw
m_pFramebuffer->redraw(0, 0, m_pFramebuffer->getWidth(), m_pFramebuffer->getHeight(), false);
-
+
// if (b)
// Syscall::setCurrentBuffer(m_pBuffer);
}
diff --git a/src/user/applications/TUI/environment.cc b/src/user/applications/TUI/environment.cc
index aa7a7e9..626303d 100644
--- a/src/user/applications/TUI/environment.cc
+++ b/src/user/applications/TUI/environment.cc
@@ -21,34 +21,6 @@
extern PedigreeGraphics::Framebuffer *g_pFramebuffer;
-#include <stdio.h>
-extern void log();
-void *operator new (size_t size) throw()
-{
- void *ret = malloc(size);
- return ret;
-}
-void *operator new[] (size_t size) throw()
-{
- return malloc(size);
-}
-void *operator new (size_t size, void* memory) throw()
-{
- return memory;
-}
-void *operator new[] (size_t size, void* memory) throw()
-{
- return memory;
-}
-void operator delete (void * p)
-{
- free(p);
-}
-void operator delete[] (void * p)
-{
- free(p);
-}
-
size_t Syscall::nextRequest(size_t responseToLast, char *buffer, size_t *sz, size_t buffersz, size_t *terminalId)
{
size_t ret = syscall5(TUI_NEXT_REQUEST, responseToLast, reinterpret_cast<size_t>(buffer), reinterpret_cast<size_t>(sz), buffersz, reinterpret_cast<size_t>(terminalId));
@@ -57,15 +29,6 @@ size_t Syscall::nextRequest(size_t responseToLast, char *buffer, size_t *sz, siz
return ret;
}
-size_t Syscall::getFb(Display::ScreenMode *pMode)
-{
- return 0;
-
- return syscall1(TUI_GETFB, reinterpret_cast<size_t>(pMode));
- // Memory barrier, "sz" will have changed. Reload.
- asm volatile ("" : : : "memory");
-}
-
void Syscall::requestPending()
{
syscall0(TUI_REQUEST_PENDING);
@@ -91,66 +54,13 @@ void Syscall::setCurrentConsole(size_t tabId)
syscall1(TUI_SET_CURRENT_CONSOLE, tabId);
}
-rgb_t *Syscall::newBuffer()
-{
- return 0; // return reinterpret_cast<rgb_t*> (syscall0(TUI_VID_NEW_BUFFER));
-}
-
-void Syscall::setCurrentBuffer(rgb_t *pBuffer)
-{
- return; // syscall1(TUI_VID_SET_BUFFER, reinterpret_cast<uintptr_t>(pBuffer));
-}
-
void doRedraw(DirtyRectangle &rect)
{
if(rect.getX() == ~0UL && rect.getY() == ~0UL &&
rect.getX2() == ~0UL && rect.getY2() == ~0UL)
return;
-
- g_pFramebuffer->redraw(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight(), true);
-}
-void Syscall::killBuffer(rgb_t *pBuffer)
-{
- return;
-
- syscall1(TUI_VID_KILL_BUFFER, reinterpret_cast<uintptr_t>(pBuffer));
-}
-
-void Syscall::bitBlit(rgb_t *pBuffer, size_t x, size_t y, size_t x2, size_t y2,
- size_t w, size_t h)
-{
- return;
-
- vid_req_t req;
- req.buffer = pBuffer;
- req.x = x;
- req.y = y;
- req.x2 = x2;
- req.y2 = y2;
- req.w = w;
- req.h = h;
-
- asm volatile("" ::: "memory");
-
- syscall1(TUI_VID_BIT_BLIT, reinterpret_cast<uintptr_t>(&req));
-}
-
-void Syscall::fillRect(rgb_t *pBuffer, size_t x, size_t y, size_t w, size_t h, rgb_t c)
-{
- return;
-
- vid_req_t req;
- req.buffer = pBuffer;
- req.x = x;
- req.y = y;
- req.w = w;
- req.h = h;
- req.c = &c;
-
- asm volatile("" ::: "memory");
-
- syscall1(TUI_VID_FILL_RECT, reinterpret_cast<uintptr_t>(&req));
+ g_pFramebuffer->redraw(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight(), true);
}
DirtyRectangle::DirtyRectangle() :
diff --git a/src/user/applications/TUI/environment.h b/src/user/applications/TUI/environment.h
index 0cb9902..50da3ed 100644
--- a/src/user/applications/TUI/environment.h
+++ b/src/user/applications/TUI/environment.h
@@ -96,21 +96,12 @@ private:
namespace Syscall
{
-// void log(char *c); void log(const char *c);
-
size_t nextRequest(size_t responseToLast, char *buffer, size_t *sz, size_t buffersz, size_t *terminalId);
- size_t getFb(Display::ScreenMode *pMode);
void requestPending();
void respondToPending(size_t response, char *buffer, size_t sz);
void createConsole(size_t tabId, char *pName);
void setCtty(char *pName);
void setCurrentConsole(size_t tabId);
- rgb_t *newBuffer();
- void setCurrentBuffer(rgb_t *pBuffer);
- void killBuffer(rgb_t *pBuffer);
- void bitBlit(rgb_t *pBuffer, size_t x, size_t y, size_t x2, size_t y2,
- size_t w, size_t h);
- void fillRect(rgb_t *pBuffer, size_t x, size_t y, size_t w, size_t h, rgb_t c);
}
void doRedraw(DirtyRectangle &rect);
diff --git a/src/user/applications/TUI/main.cc b/src/user/applications/TUI/main.cc
index 0066590..232c15a 100644
--- a/src/user/applications/TUI/main.cc
+++ b/src/user/applications/TUI/main.cc
@@ -48,8 +48,6 @@
#define CONSOLE_GETCOLS 4
#define CONSOLE_DATA_AVAILABLE 5
#define CONSOLE_REFRESH 10
-#define TUI_MODE_CHANGED 98
-#define TUI_CHAR_RECV 99
#define NORMAL_FONT_PATH "/system/fonts/DejaVuSansMono.ttf"
#define BOLD_FONT_PATH "/system/fonts/DejaVuSansMono-Bold.ttf"
@@ -58,16 +56,6 @@
/** End code from InputManager */
-void log(char *c)
-{
- syscall1(TUI_LOG, reinterpret_cast<size_t>(c));
-}
-
-void log(const char *c)
-{
- syscall1(TUI_LOG, reinterpret_cast<size_t>(c));
-}
-
struct TerminalList
{
Terminal *term;
@@ -84,6 +72,7 @@ size_t g_nLastResponse = 0;
PedigreeGraphics::Framebuffer *g_pFramebuffer = 0;
+/*
void modeChanged(size_t width, size_t height)
{
syslog(LOG_ALERT, "w: %d, h: %d\n", width, height);
@@ -110,7 +99,7 @@ void modeChanged(size_t width, size_t height)
pTL = pTL->next;
}
-}
+}*/
void selectTerminal(TerminalList *pTL, DirtyRectangle &rect)
{
@@ -126,7 +115,7 @@ void selectTerminal(TerminalList *pTL, DirtyRectangle &rect)
g_pHeader->render(pTL->term->getBuffer(), rect);
pTL->term->redrawAll(rect);
-
+
doRedraw(rect);
}
@@ -319,7 +308,7 @@ int main (int argc, char **argv)
syslog(LOG_EMERG, "TUI is already running\n");
return 1;
}
-
+
struct stat info;
int err = stat("/config", &info);
if((err < 0) && (errno == ENOENT))
@@ -335,7 +324,7 @@ int main (int argc, char **argv)
syslog(LOG_EMERG, "TUI: couldn't stat /config for some reason: %s!", strerror(errno));
return 1;
}
-
+
err = stat("/config/TUI", &info);
if((err < 0) && (errno == ENOENT))
{
@@ -350,7 +339,7 @@ int main (int argc, char **argv)
syslog(LOG_EMERG, "TUI: couldn't stat /config/TUI for some reason: %s!", strerror(errno));
return 1;
}
-
+
fp = fopen("/config/TUI/.tui.lck", "w+");
if(!fp)
{
@@ -360,11 +349,11 @@ int main (int argc, char **argv)
fclose(fp);
signal(SIGINT, sigint);
-
+
// Connect to the graphics service
PedigreeGraphics::Framebuffer *pRootFramebuffer = new PedigreeGraphics::Framebuffer();
g_pFramebuffer = pRootFramebuffer->createChild(0, 0, pRootFramebuffer->getWidth(), pRootFramebuffer->getHeight());
-
+
// Have we got a working mode?
if(!g_pFramebuffer->getRawBuffer())
{
@@ -375,7 +364,7 @@ int main (int argc, char **argv)
g_nWidth = g_pFramebuffer->getWidth();
g_nHeight = g_pFramebuffer->getHeight();
-
+
g_pFramebuffer->rect(0, 0, g_nWidth, g_nHeight, 0, PedigreeGraphics::Bits24_Rgb);
g_pFramebuffer->redraw(0, 0, g_nWidth, g_nHeight, true);
@@ -393,14 +382,14 @@ int main (int argc, char **argv)
syslog(LOG_EMERG, "Error: Font '%s' not loaded!", BOLD_FONT_PATH);
return 0;
}
-
+
rgb_t fore = {0xff, 0xff, 0xff, 0xff};
rgb_t back = {0, 0, 0, 0};
g_pHeader = new Header(g_nWidth);
g_pHeader->addTab(const_cast<char*>("The Pedigree Operating System"), 0);
-
+
DirtyRectangle rect;
// DirtyRectangle rect;
@@ -414,7 +403,6 @@ int main (int argc, char **argv)
size_t maxBuffSz = (32768 * 2) - 1;
char *buffer = new char[maxBuffSz + 1];
- char str[64];
size_t tabId;
while (true)
{
@@ -424,14 +412,14 @@ int main (int argc, char **argv)
if(cmd == 0)
continue;
- if (cmd == TUI_MODE_CHANGED)
+ /*if (cmd == TUI_MODE_CHANGED)
{
uint64_t u = * reinterpret_cast<uint64_t*>(buffer);
syslog(LOG_ALERT, "u: %llx", u);
modeChanged(u&0xFFFFFFFFULL, (u>>32)&0xFFFFFFFFULL);
continue;
- }
+ }*/
Terminal *pT = 0;
TerminalList *pTL = g_pTermList;
@@ -446,8 +434,7 @@ int main (int argc, char **argv)
}
if (pT == 0)
{
- sprintf(str, "Completely unrecognised terminal ID %ld, aborting.", tabId);
- log (str);
+ syslog(LOG_ALERT, "Completely unrecognised terminal ID %ld, aborting.", tabId);
continue;
}
@@ -475,7 +462,6 @@ int main (int argc, char **argv)
case CONSOLE_READ:
{
- char str[64];
size_t i = 0;
while (i < sz)
{
@@ -513,11 +499,7 @@ int main (int argc, char **argv)
break;
default:
- {
- char str[64];
- sprintf(str, "Unknown command: %x", cmd);
- log(str);
- }
+ syslog(LOG_ALERT, "Unknown command: %x", cmd);
}
}
--
1.6.4.2