Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[console] Add dual monitor support to console-direct driver #1980

Merged
merged 7 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions elks/arch/i86/drivers/char/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ endif
else
ifdef CONFIG_CONSOLE_DIRECT
OBJS += console-direct.o bell-8254.o
ifdef CONFIG_CONSOLE_DUAL
OBJS += crtc-6845.o
endif
vkoskiv marked this conversation as resolved.
Show resolved Hide resolved
endif
endif

Expand Down
1 change: 1 addition & 0 deletions elks/arch/i86/drivers/char/config.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mainmenu_option next_comment
Headless CONFIG_CONSOLE_HEADLESS" Direct
if [ "$CONFIG_CONSOLE_DIRECT" = "y" ]; then
bool ' Scancode keyboard driver' CONFIG_KEYBOARD_SCANCODE y
bool ' Dual-screen console support' CONFIG_CONSOLE_DUAL n
fi
bool 'Serial Console' CONFIG_CONSOLE_SERIAL n
if [[ "$CONFIG_CONSOLE_DIRECT" = "y" || "$CONFIG_CONSOLE_BIOS" = "y" ]]; then
Expand Down
54 changes: 29 additions & 25 deletions elks/arch/i86/drivers/char/console-bios.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,35 @@

#define MAXPARMS 28

#define MAX_DISPLAYS 1

struct console;
typedef struct console Console;

struct console {
int cx, cy; /* cursor position */
void (*fsm)(Console *, int);
unsigned char display;
unsigned char attr; /* current attribute */
unsigned char XN; /* delayed newline on column 80 */
unsigned char color; /* fg/bg attr */
int pageno; /* video ram page # */
unsigned short Width;
unsigned short Height;
#ifdef CONFIG_EMUL_ANSI
int savex, savey; /* saved cursor position */
unsigned char *parmptr; /* ptr to params */
unsigned char params[MAXPARMS]; /* ANSI params */
#endif
};

static Console *glock;
static struct wait_queue glock_wait;
static Console Con[MAX_CONSOLES], *Visible;
static Console *glock; /* Which console owns the graphics hardware */
static int Width, MaxCol, Height, MaxRow;
static Console *Visible[MAX_DISPLAYS];
static Console Con[MAX_CONSOLES];
static int NumConsoles = MAX_CONSOLES;
static int kraw;
static int Current_VCminor = 0;
static int Current_VCminor;

#ifdef CONFIG_EMUL_ANSI
#define TERM_TYPE " emulating ANSI "
Expand Down Expand Up @@ -93,7 +98,7 @@ static void PositionCursorGet (int * x, int * y)
*y = row;
}

static void DisplayCursor(int onoff)
static void DisplayCursor(Console * C, int onoff)
{
}

Expand All @@ -111,14 +116,14 @@ static void scroll(register Console * C, int n, int x, int y, int xx, int yy)
int a;

a = C->attr;
if (C != Visible) {
if (C != Visible[C->display]) {
bios_setpage(C->pageno);
}

bios_scroll (a, n, x, y, xx, yy);

if (C != Visible) {
bios_setpage(Visible->pageno);
if (C != Visible[C->display]) {
bios_setpage(Visible[C->display]->pageno);
}
}

Expand All @@ -129,13 +134,13 @@ static void ClearRange(register Console * C, int x, int y, int xx, int yy)

static void ScrollUp(register Console * C, int y)
{
scroll(C, 1, 0, y, MaxCol, MaxRow);
scroll(C, 1, 0, y, C->Width - 1, C->Height - 1);
}

#ifdef CONFIG_EMUL_ANSI
static void ScrollDown(register Console * C, int y)
{
scroll(C, -1, 0, y, MaxCol, MaxRow);
scroll(C, -1, 0, y, C->Width - 1, C->Height - 1);
}
#endif

Expand All @@ -148,12 +153,13 @@ static void ScrollDown(register Console * C, int y)

void Console_set_vc(int N)
{
if ((N >= NumConsoles) || (Visible == &Con[N]) || glock)
Console *C = &Con[N];
if ((N >= NumConsoles) || (Visible[C->display] == C) || glock)
return;
Visible = &Con[N];
Visible[C->display] = C;

bios_setpage(N);
PositionCursor(Visible);
PositionCursor(Visible[C->display]);
Current_VCminor = N;
}

Expand All @@ -171,23 +177,21 @@ void INITPROC console_init(void)
Console *C;
int i;

MaxCol = (Width = SETUP_VID_COLS) - 1;

/* Trust this. Cga does not support peeking at 0x40:0x84. */
MaxRow = (Height = SETUP_VID_LINES) - 1;
C = Con;
C->Width = SETUP_VID_COLS;
C->Height = SETUP_VID_LINES;

if (peekb(0x49, 0x40) == 7) /* BIOS data segment */
NumConsoles = 1;

C = Con;
Visible = C;

for (i = 0; i < NumConsoles; i++) {
C->display = 0;
C->cx = C->cy = 0;
if (!i) {
// Get current cursor position
// to write after boot messages
PositionCursorGet (&C->cx, &C->cy);
Visible[C->display] = C;
// Get current cursor position
// to write after boot messages
PositionCursorGet (&C->cx, &C->cy);
}
C->fsm = std_char;
C->pageno = i;
Expand All @@ -201,13 +205,13 @@ void INITPROC console_init(void)
#endif

/* Do not erase early printk() */
/* ClearRange(C, 0, C->cy, MaxCol, MaxRow); */
/* ClearRange(C, 0, C->cy, C->MaxCol, C->MaxRow); */

C++;
}

kbd_init();

printk("BIOS console %ux%u"TERM_TYPE"(%d virtual consoles)\n",
Width, Height, NumConsoles);
Con[0].Width, Con[0].Height, NumConsoles);
}
80 changes: 44 additions & 36 deletions elks/arch/i86/drivers/char/console-direct-pc98.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,36 @@

#define MAXPARMS 28

#define MAX_DISPLAYS 1

struct console;
typedef struct console Console;

struct console {
int cx, cy; /* cursor position */
void (*fsm)(Console *, int);
unsigned char display;
unsigned char attr; /* current attribute */
unsigned char XN; /* delayed newline on column 80 */
unsigned int vseg; /* video segment for page */
int basepage; /* start of video ram */
unsigned int vseg; /* vram for this console page */
int vseg_offset; /* vram offset of vseg for this console page */
unsigned short Width;
unsigned short Height;
#ifdef CONFIG_EMUL_ANSI
int savex, savey; /* saved cursor position */
unsigned char *parmptr; /* ptr to params */
unsigned char params[MAXPARMS]; /* ANSI params */
#endif
};

static Console *glock;
static struct wait_queue glock_wait;
static Console Con[MAX_CONSOLES], *Visible;
static Console *glock; /* Which console owns the graphics hardware */
static int Width, MaxCol, Height, MaxRow;
static Console *Visible[MAX_DISPLAYS];
static Console Con[MAX_CONSOLES];
static int NumConsoles = MAX_CONSOLES;

int Current_VCminor = 0;
int kraw = 0;
int Current_VCminor;
int kraw;
unsigned VideoSeg;
unsigned AttributeSeg;

Expand All @@ -92,11 +97,11 @@ static void PositionCursor(register Console * C)
{
int Pos;

Pos = C->cx + Width * C->cy + C->basepage;
Pos = C->cx + C->Width * C->cy + C->vseg_offset;
cursor_set(Pos * 2);
}

static void DisplayCursor(int onoff)
static void DisplayCursor(Console * C, int onoff)
{
if (onoff)
cursor_on();
Expand Down Expand Up @@ -130,7 +135,7 @@ static void VideoWrite(register Console * C, int c)
word_t addr;
word_t attr;

addr = (C->cx + C->cy * Width) << 1;
addr = (C->cx + C->cy * C->Width) << 1;
attr = (C->attr == A_DEFAULT) ? A98_DEFAULT : conv_pcattr(C->attr);

pokew(addr, (seg_t) AttributeSeg, attr);
Expand All @@ -145,39 +150,43 @@ static void ClearRange(register Console * C, int x, int y, int xx, int yy)
attr = (C->attr == A_DEFAULT) ? A98_DEFAULT : conv_pcattr(C->attr);

xx = xx - x + 1;
vp = (__u16 *)((__u16)(x + y * Width) << 1);
vp = (__u16 *)((__u16)(x + y * C->Width) << 1);
do {
for (x = 0; x < xx; x++) {
pokew((word_t) vp, AttributeSeg, attr);
pokew((word_t) (vp++), (seg_t) C->vseg, (word_t) ' ');
}
vp += (Width - xx);
vp += (C->Width - xx);
} while (++y <= yy);
}

static void ScrollUp(register Console * C, int y)
{
register __u16 *vp;
__u16 *vp;
unsigned short MaxRow = C->Height - 1;
unsigned short MaxCol = C->Width - 1;

vp = (__u16 *)((__u16)(y * Width) << 1);
vp = (__u16 *)((__u16)(y * C->Width) << 1);
if ((unsigned int)y < MaxRow) {
fmemcpyb(vp, AttributeSeg, vp + Width, AttributeSeg, (MaxRow - y) * (Width << 1));
fmemcpyb(vp, C->vseg, vp + Width, C->vseg, (MaxRow - y) * (Width << 1));
fmemcpyb(vp, AttributeSeg, vp + C->Width, AttributeSeg, (MaxRow - y) * (C->Width << 1));
fmemcpyb(vp, C->vseg, vp + C->Width, C->vseg, (MaxRow - y) * (C->Width << 1));
}
ClearRange(C, 0, MaxRow, MaxCol, MaxRow);
}

#ifdef CONFIG_EMUL_ANSI
static void ScrollDown(register Console * C, int y)
{
register __u16 *vp;
__u16 *vp;
unsigned short MaxRow = C->Height - 1;
unsigned short MaxCol = C->Width - 1;
int yy = MaxRow;

vp = (__u16 *)((__u16)(yy * Width) << 1);
vp = (__u16 *)((__u16)(yy * C->Width) << 1);
while (--yy >= y) {
fmemcpyb(vp, AttributeSeg, vp - Width, AttributeSeg, Width << 1);
fmemcpyb(vp, C->vseg, vp - Width, C->vseg, Width << 1);
vp -= Width;
fmemcpyb(vp, AttributeSeg, vp - C->Width, AttributeSeg, C->Width << 1);
fmemcpyb(vp, C->vseg, vp - C->Width, C->vseg, C->Width << 1);
vp -= C->Width;
}
ClearRange(C, 0, y, MaxCol, y);
}
Expand All @@ -192,12 +201,12 @@ static void ScrollDown(register Console * C, int y)

void Console_set_vc(int N)
{
if ((N >= NumConsoles) || (Visible == &Con[N]) || glock)
return;
Visible = &Con[N];

SetDisplayPage(Visible);
PositionCursor(Visible);
Console *C = &Con[N];
if ((N >= NumConsoles) || (Visible[C->display] == C) || glock)
return;
Visible[C->display] = C;
SetDisplayPage(Visible[C->display]);
PositionCursor(Visible[C->display]);
Current_VCminor = N;
}

Expand All @@ -224,26 +233,25 @@ void INITPROC console_init(void)
AttributeSeg = 0xE200;
}

MaxCol = (Width = 80) - 1;

MaxRow = (Height = 25) - 1;
C = Con;
C->Width = 80;
C->Height = 25;

PageSizeW = 2000;

NumConsoles = 1;

C = Con;
Visible = C;

for (i = 0; i < NumConsoles; i++) {
C->display = 0;
C->cx = C->cy = 0;
if (!i) {
Visible[C->display] = C;
C->cx = read_tvram_x() % 160;
C->cy = read_tvram_x() / 160;
}
C->fsm = std_char;
C->basepage = i * PageSizeW;
C->vseg = VideoSeg + (C->basepage >> 3);
C->vseg_offset = i * PageSizeW;
C->vseg = VideoSeg + (C->vseg_offset >> 3);
C->attr = A_DEFAULT;

#ifdef CONFIG_EMUL_ANSI
Expand All @@ -261,5 +269,5 @@ void INITPROC console_init(void)
kbd_init();

printk("Direct console, %s kbd %ux%u"TERM_TYPE"(du virtual consoles)\n",
kbd_name, Width, Height, NumConsoles);
kbd_name, Con[0].Width, Con[0].Height, NumConsoles);
}
Loading
Loading