Import backup from 2005-06-02

This commit is contained in:
josh committed 2017-07-25 22:23:50 -04:00
1 parent b0132c866e
commit 692cf2fc08
22 files changed
+512 -244

No files matched your search

+34 -70
View File
@@ -9,27 +9,24 @@
#include "lang/lang.h"
#include "kernel.h"
#include "display/vesafb.h"
#include "char/keyboard.h"
#include "display/kout.h"
extern real_mode_param_t rm_params; // check if a video mode is activated
int display_type;
int display_activeConsole = -1; // start with no active console
display_t myDisplays[12]; // f1-f12 change displays
// initialization routine for display subsystem
int display_init()
{
int width = 80;
int height = 25;
int displayType = DISPLAY_CONSOLE;
if (rm_params.vid_addr) // framebuffer mode
if (!rm_params.vid_addr) // framebuffer mode
{
vesafb_init(rm_params.width, rm_params.height, rm_params.bpp);
width = vesafb_getWidth();
height = vesafb_getHeight();
displayType = DISPLAY_FB;
vconsole_setup(80, 25);
display_activate(KERNEL_MSG_CONSOLE);
}
vconsole_setup(width, height);
// vconsole_activate(0);
else
display_type = DISPLAY_GRAPHICAL;
return 0;
}
@@ -37,73 +34,40 @@ int display_init()
// activate the given display
int display_activate(u32_t id)
{
if (id > 11)
if (id == display_activeConsole)
return 0;
if (display_type != DISPLAY_CONSOLE)
return -1;
switch (myDisplays[id].type)
if (id >= VCONSOLE_MAX)
return -2;
if (display_activeConsole >= 0)
vconsole_deactivate(display_activeConsole);
if (vconsole_activate(id)) // if true, didn't work to activate console
{
case DISPLAY_CONSOLE:
case DISPLAY_FB:
display_activeConsole = myDisplays[id].id;
// return vconsole_draw(display_activeConsole);
case DISPLAY_GRAPHICAL:
default:
return -2;
vconsole_activate(display_activeConsole); // restore old one
return -3;
}
display_activeConsole = id;
return 0;
}
// routine to refresh a console window
int display_console_draw(minor_t id, int cursorPosition, u16_t *buffer, int buff_len)
void display_key_event(u32_t keyCode)
{
if (id == display_activeConsole)
if (display_type == DISPLAY_CONSOLE)
{
int i;
for (i = 0; i < 12; i++)
u32_t kbdScan = KBD_SCAN(keyCode);
if ( /* kbdFlags & KBDF_ALT && */ kbdScan >= 0x3B && kbdScan <= 0x44) // switch displays F1-F10
{
if (myDisplays[i].id == id)
{
if (myDisplays[i].type == DISPLAY_CONSOLE)
{
memcpyw((void *)CONSOLE_MEMORY, buffer, buff_len);
writeCursorPosition(cursorPosition);
return 0;
}
else if (myDisplays[i].type == DISPLAY_FB)
return vesafb_draw(buffer, buff_len, cursorPosition);
return -2;
}
display_activate(kbdScan - 0x3B);
return;
}
if ( /* kbdFlags & KBDF_ALT && */ kbdScan >= 0x57 && kbdScan <= 0x58) // F11-F12
{
display_activate(kbdScan - 0x4D);
return;
}
}
return -1;
if (KBD_ASCII(keyCode))
putc(KBD_ASCII(keyCode));
}
// write a character to the screen
int display_console_put_char(minor_t id, u16_t c, int position)
{
if (id == display_activeConsole)
{
if (myDisplays[id].type == DISPLAY_CONSOLE)
*(u16_t *)(CONSOLE_MEMORY + (position << 1)) = c;
else if (myDisplays[id].type == DISPLAY_FB)
vesafb_draw_char(position, c);
return 0;
}
return -1;
}
// move the cursor on the screen
int display_console_update_cursor(minor_t id, int cursorPosition)
{
if (id == display_activeConsole)
{
if (myDisplays[id].type == DISPLAY_CONSOLE)
writeCursorPosition(cursorPosition);
else if (myDisplays[id].type == DISPLAY_FB)
vesafb_update_cursor(cursorPosition);
return 0;
}
return -1;
}
+4 -7
View File
@@ -9,10 +9,8 @@
#include "hos_defines.h"
#include "devices.h"
#define DISPLAY_NULL 0
#define DISPLAY_CONSOLE 1
#define DISPLAY_FB 2
#define DISPLAY_GRAPHICAL 3
#define DISPLAY_CONSOLE 0
#define DISPLAY_GRAPHICAL 1
typedef struct
{
@@ -22,9 +20,8 @@ typedef struct
int display_init();
int display_activate(u32_t id);
int display_console_draw(minor_t id, int cursorPosition, u16_t *buffer, int buff_len);
int display_console_put_char(minor_t id, u16_t c, int position);
int display_console_update_cursor(minor_t id, int cursorPosition);
void display_key_event(u32_t keyCode);
#endif
+1 -1
View File
@@ -17,7 +17,7 @@ void putc(int c)
#ifdef PARALLEL_DEBUG
char_write(MAJOR_MISC_CHAR, MISC_CHAR_LP0, c);
#endif
char_write(MAJOR_VCONSOLE, 1, c); // write to vconsole with minor 1, first allocated
char_write(MAJOR_VCONSOLE, KERNEL_MSG_CONSOLE, c); // write to vconsole with minor 1, first allocated
}