svn path=/trunk/; revision=402
This commit is contained in:
Eric Kohl 1999-04-19 18:44:36 +00:00
parent 81b9b25bc7
commit 94f82b0796

View file

@ -16,10 +16,14 @@
#define NR_ROWS 50 #define NR_ROWS 50
#define NR_COLUMNS 80 #define NR_COLUMNS 80
#define NR_SCANLINES 8
#define CRTC_COMMAND 0x3d4 #define CRTC_COMMAND 0x3d4
#define CRTC_DATA 0x3d5 #define CRTC_DATA 0x3d5
#define CRTC_COLUMNS 0x01
#define CRTC_ROWS 0x12
#define CRTC_SCANLINES 0x09
#define CRTC_CURSORSTART 0x0a #define CRTC_CURSORSTART 0x0a
#define CRTC_CURSOREND 0x0b #define CRTC_CURSOREND 0x0b
#define CRTC_CURSORPOSLO 0x0f #define CRTC_CURSORPOSLO 0x0f
@ -43,15 +47,14 @@
typedef struct _DEVICE_EXTENSION typedef struct _DEVICE_EXTENSION
{ {
PBYTE VideoMemory; PBYTE VideoMemory; /* Pointer to video memory */
SHORT CursorX;
SHORT CursorY;
DWORD CursorSize; DWORD CursorSize;
BOOL CursorVisible; BOOL CursorVisible;
WORD CharAttribute; WORD CharAttribute;
DWORD Mode; DWORD Mode;
BYTE ScanLines; /* Height of a text line */ BYTE ScanLines; /* Height of a text line */
BYTE Rows; /* Number of rows */
BYTE Columns; /* Number of columns */
} DEVICE_EXTENSION, *PDEVICE_EXTENSION; } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
@ -63,7 +66,6 @@ typedef struct _DEVICE_EXTENSION
NTSTATUS ScrCreate (PDEVICE_OBJECT DeviceObject, PIRP Irp) NTSTATUS ScrCreate (PDEVICE_OBJECT DeviceObject, PIRP Irp)
{ {
// PIO_STACK_LOCATION stk = IoGetCurrentIrpStackLocation (Irp);
PDEVICE_EXTENSION DeviceExtension; PDEVICE_EXTENSION DeviceExtension;
NTSTATUS Status; NTSTATUS Status;
unsigned int offset; unsigned int offset;
@ -72,6 +74,7 @@ NTSTATUS ScrCreate (PDEVICE_OBJECT DeviceObject, PIRP Irp)
DeviceExtension = DeviceObject->DeviceExtension; DeviceExtension = DeviceObject->DeviceExtension;
/* initialize device extension */ /* initialize device extension */
/* get pointer to video memory */ /* get pointer to video memory */
/* FIXME : use MmMapIoSpace() */ /* FIXME : use MmMapIoSpace() */
DeviceExtension->VideoMemory = (PBYTE)(IDMAP_BASE + VIDMEM_BASE); DeviceExtension->VideoMemory = (PBYTE)(IDMAP_BASE + VIDMEM_BASE);
@ -96,23 +99,18 @@ NTSTATUS ScrCreate (PDEVICE_OBJECT DeviceObject, PIRP Irp)
__asm__("sti\n\t"); __asm__("sti\n\t");
DeviceExtension->CursorX = (SHORT)(offset % NR_COLUMNS); DeviceExtension->ScanLines = NR_SCANLINES; /* FIXME: read it from CRTC */
DeviceExtension->CursorY = (SHORT)(offset / NR_COLUMNS); DeviceExtension->Rows = NR_ROWS; /* FIXME: read it from CRTC */
DeviceExtension->Columns = NR_COLUMNS; /* FIXME: read it from CRTC */
DeviceExtension->CursorSize = 5; /* FIXME: value correct?? */ DeviceExtension->CursorSize = 5; /* FIXME: value correct?? */
DeviceExtension->CursorVisible = TRUE; DeviceExtension->CursorVisible = TRUE;
DeviceExtension->ScanLines = 8; /* FIXME: read it from CRTC */
/* more initialization */ /* more initialization */
DeviceExtension->CharAttribute = 0x17; /* light grey on blue */ DeviceExtension->CharAttribute = 0x17; /* light grey on blue */
DeviceExtension->Mode = ENABLE_PROCESSED_OUTPUT | DeviceExtension->Mode = ENABLE_PROCESSED_OUTPUT |
ENABLE_WRAP_AT_EOL_OUTPUT; ENABLE_WRAP_AT_EOL_OUTPUT;
/* FIXME: more initialization?? */
/* show blinking cursor */ /* show blinking cursor */
/* FIXME: calculate cursor size */ /* FIXME: calculate cursor size */
__asm__("cli\n\t"); __asm__("cli\n\t");
@ -140,18 +138,20 @@ NTSTATUS ScrWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
char *vidmem; char *vidmem;
int i, j, offset; int i, j, offset;
int cursorx, cursory; int cursorx, cursory;
int rows, columns;
DeviceExtension = DeviceObject->DeviceExtension; DeviceExtension = DeviceObject->DeviceExtension;
vidmem = DeviceExtension->VideoMemory; vidmem = DeviceExtension->VideoMemory;
// cursorx = DeviceExtension->CursorX; rows = DeviceExtension->Rows;
// cursory = DeviceExtension->CursorY; columns = DeviceExtension->Columns;
outb_p(CRTC_COMMAND, CRTC_CURSORPOSHI);
offset = inb_p(CRTC_DATA)<<8;
outb_p(CRTC_COMMAND, CRTC_CURSORPOSLO);
offset += inb_p(CRTC_DATA);
cursory = offset / NR_COLUMNS; outb_p(CRTC_COMMAND, CRTC_CURSORPOSHI);
cursorx = offset % NR_COLUMNS; offset = inb_p(CRTC_DATA)<<8;
outb_p(CRTC_COMMAND, CRTC_CURSORPOSLO);
offset += inb_p(CRTC_DATA);
cursory = offset / columns;
cursorx = offset % columns;
for (i = 0; i < stk->Parameters.Write.Length; i++, pch++) for (i = 0; i < stk->Parameters.Write.Length; i++, pch++)
{ {
@ -164,7 +164,7 @@ NTSTATUS ScrWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
} }
else if (cursory > 0) else if (cursory > 0)
{ {
cursorx = NR_COLUMNS - 1; cursorx = columns - 1;
cursory--; cursory--;
} }
break; break;
@ -181,10 +181,10 @@ NTSTATUS ScrWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
offset = TAB_WIDTH - (cursorx % TAB_WIDTH); offset = TAB_WIDTH - (cursorx % TAB_WIDTH);
for (j = 0; j < offset; j++) for (j = 0; j < offset; j++)
{ {
vidmem[(cursorx * 2) + (cursory * NR_COLUMNS * 2)] = ' '; vidmem[(cursorx * 2) + (cursory * columns * 2)] = ' ';
cursorx++; cursorx++;
if (cursorx >= NR_COLUMNS) if (cursorx >= columns)
{ {
cursory++; cursory++;
cursorx = 0; cursorx = 0;
@ -193,10 +193,10 @@ NTSTATUS ScrWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
break; break;
default: default:
vidmem[(cursorx * 2) + (cursory * NR_COLUMNS * 2)] = *pch; vidmem[(cursorx * 2) + (cursory * columns * 2)] = *pch;
vidmem[(cursorx * 2) + (cursory * NR_COLUMNS * 2) + 1] = (char) DeviceExtension->CharAttribute; vidmem[(cursorx * 2) + (cursory * columns * 2) + 1] = (char) DeviceExtension->CharAttribute;
cursorx++; cursorx++;
if (cursorx >= NR_COLUMNS) if (cursorx >= columns)
{ {
cursory++; cursory++;
cursorx = 0; cursorx = 0;
@ -205,27 +205,27 @@ NTSTATUS ScrWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
} }
if (cursory >= NR_ROWS) if (cursory >= rows)
{ {
unsigned short *LinePtr; unsigned short *LinePtr;
memcpy (vidmem, memcpy (vidmem,
&vidmem[NR_COLUMNS * 2], &vidmem[columns * 2],
NR_COLUMNS * (NR_ROWS - 1) * 2); columns * (rows - 1) * 2);
LinePtr = (unsigned short *) &vidmem[NR_COLUMNS * (NR_ROWS - 1) * 2]; LinePtr = (unsigned short *) &vidmem[columns * (rows - 1) * 2];
for (j = 0; j < NR_COLUMNS; j++) for (j = 0; j < columns; j++)
{ {
LinePtr[j] = DeviceExtension->CharAttribute << 8; LinePtr[j] = DeviceExtension->CharAttribute << 8;
} }
cursory = NR_ROWS - 1; cursory = rows - 1;
} }
} }
/* Set the cursor position */ /* Set the cursor position */
offset = (cursory * NR_COLUMNS) + cursorx; offset = (cursory * columns) + cursorx;
outb_p (CRTC_COMMAND, CRTC_CURSORPOSLO); outb_p (CRTC_COMMAND, CRTC_CURSORPOSLO);
outb_p (CRTC_DATA, offset); outb_p (CRTC_DATA, offset);
@ -233,8 +233,6 @@ NTSTATUS ScrWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
offset >>= 8; offset >>= 8;
outb_p (CRTC_DATA, offset); outb_p (CRTC_DATA, offset);
DeviceExtension->CursorX = cursorx;
DeviceExtension->CursorY = cursory;
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
@ -260,6 +258,8 @@ NTSTATUS ScrIoControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
case IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO: case IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO:
{ {
PCONSOLE_SCREEN_BUFFER_INFO pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer; PCONSOLE_SCREEN_BUFFER_INFO pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer;
int rows = DeviceExtension->Rows;
int columns = DeviceExtension->Columns;
unsigned int offset; unsigned int offset;
__asm__("cli\n\t"); __asm__("cli\n\t");
@ -269,21 +269,21 @@ NTSTATUS ScrIoControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
offset += (inb_p (CRTC_DATA) << 8); offset += (inb_p (CRTC_DATA) << 8);
__asm__("sti\n\t"); __asm__("sti\n\t");
pcsbi->dwSize.X = NR_ROWS; pcsbi->dwSize.X = rows;
pcsbi->dwSize.Y = NR_COLUMNS; pcsbi->dwSize.Y = columns;
pcsbi->dwCursorPosition.X = (SHORT)(offset % NR_COLUMNS); pcsbi->dwCursorPosition.X = (SHORT)(offset % columns);
pcsbi->dwCursorPosition.Y = (SHORT)(offset / NR_COLUMNS); pcsbi->dwCursorPosition.Y = (SHORT)(offset / columns);
pcsbi->wAttributes = DeviceExtension->CharAttribute; pcsbi->wAttributes = DeviceExtension->CharAttribute;
pcsbi->srWindow.Left = 0; pcsbi->srWindow.Left = 0;
pcsbi->srWindow.Right = NR_COLUMNS - 1; pcsbi->srWindow.Right = columns - 1;
pcsbi->srWindow.Top = 0; pcsbi->srWindow.Top = 0;
pcsbi->srWindow.Bottom = NR_ROWS - 1; pcsbi->srWindow.Bottom = rows - 1;
pcsbi->dwMaximumWindowSize.X = NR_COLUMNS; pcsbi->dwMaximumWindowSize.X = columns;
pcsbi->dwMaximumWindowSize.Y = NR_ROWS; pcsbi->dwMaximumWindowSize.Y = rows;
Irp->IoStatus.Information = sizeof (CONSOLE_SCREEN_BUFFER_INFO); Irp->IoStatus.Information = sizeof (CONSOLE_SCREEN_BUFFER_INFO);
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
@ -295,12 +295,9 @@ NTSTATUS ScrIoControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
PCONSOLE_SCREEN_BUFFER_INFO pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer; PCONSOLE_SCREEN_BUFFER_INFO pcsbi = (PCONSOLE_SCREEN_BUFFER_INFO)Irp->AssociatedIrp.SystemBuffer;
unsigned int offset; unsigned int offset;
DeviceExtension->CursorX = pcsbi->dwCursorPosition.X;
DeviceExtension->CursorY = pcsbi->dwCursorPosition.Y;
DeviceExtension->CharAttribute = pcsbi->wAttributes; DeviceExtension->CharAttribute = pcsbi->wAttributes;
offset = (pcsbi->dwCursorPosition.Y * NR_COLUMNS) + offset = (pcsbi->dwCursorPosition.Y * DeviceExtension->Columns) +
pcsbi->dwCursorPosition.X; pcsbi->dwCursorPosition.X;
__asm__("cli\n\t"); __asm__("cli\n\t");
@ -386,11 +383,9 @@ NTSTATUS ScrIoControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
DWORD dwCount; DWORD dwCount;
vidmem = DeviceExtension->VideoMemory; vidmem = DeviceExtension->VideoMemory;
offset = (Buf->dwCoord.Y * NR_COLUMNS * 2) + offset = (Buf->dwCoord.Y * DeviceExtension->Columns * 2) +
(Buf->dwCoord.X * 2) + 1; (Buf->dwCoord.X * 2) + 1;
CHECKPOINT
for (dwCount = 0; dwCount < Buf->nLength; dwCount++) for (dwCount = 0; dwCount < Buf->nLength; dwCount++)
{ {
vidmem[offset + (dwCount * 2)] = (char) Buf->wAttribute; vidmem[offset + (dwCount * 2)] = (char) Buf->wAttribute;
@ -412,7 +407,7 @@ NTSTATUS ScrIoControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
DWORD dwCount; DWORD dwCount;
vidmem = DeviceExtension->VideoMemory; vidmem = DeviceExtension->VideoMemory;
offset = (Buf->dwCoord.Y * NR_COLUMNS * 2) + offset = (Buf->dwCoord.Y * DeviceExtension->Columns * 2) +
(Buf->dwCoord.X * 2) + 1; (Buf->dwCoord.X * 2) + 1;
for (dwCount = 0; dwCount < stk->Parameters.Write.Length; dwCount++, pAttr++) for (dwCount = 0; dwCount < stk->Parameters.Write.Length; dwCount++, pAttr++)
@ -436,7 +431,7 @@ NTSTATUS ScrIoControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
DWORD dwCount; DWORD dwCount;
vidmem = DeviceExtension->VideoMemory; vidmem = DeviceExtension->VideoMemory;
offset = (Buf->dwCoord.Y * NR_COLUMNS * 2) + offset = (Buf->dwCoord.Y * DeviceExtension->Columns * 2) +
(Buf->dwCoord.X * 2) + 1; (Buf->dwCoord.X * 2) + 1;
for (dwCount = 0; dwCount < stk->Parameters.Write.Length; dwCount++, pAttr++) for (dwCount = 0; dwCount < stk->Parameters.Write.Length; dwCount++, pAttr++)
@ -466,7 +461,7 @@ NTSTATUS ScrIoControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
DWORD dwCount; DWORD dwCount;
vidmem = DeviceExtension->VideoMemory; vidmem = DeviceExtension->VideoMemory;
offset = (Buf->dwCoord.Y * NR_COLUMNS * 2) + offset = (Buf->dwCoord.Y * DeviceExtension->Columns * 2) +
(Buf->dwCoord.X * 2); (Buf->dwCoord.X * 2);
CHECKPOINT CHECKPOINT
@ -492,7 +487,7 @@ NTSTATUS ScrIoControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
DWORD dwCount; DWORD dwCount;
vidmem = DeviceExtension->VideoMemory; vidmem = DeviceExtension->VideoMemory;
offset = (Buf->dwCoord.Y * NR_COLUMNS * 2) + offset = (Buf->dwCoord.Y * DeviceExtension->Columns * 2) +
(Buf->dwCoord.X * 2); (Buf->dwCoord.X * 2);
for (dwCount = 0; dwCount < stk->Parameters.Write.Length; dwCount++, pChar++) for (dwCount = 0; dwCount < stk->Parameters.Write.Length; dwCount++, pChar++)
@ -516,7 +511,7 @@ NTSTATUS ScrIoControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
DWORD dwCount; DWORD dwCount;
vidmem = DeviceExtension->VideoMemory; vidmem = DeviceExtension->VideoMemory;
offset = (Buf->dwCoord.Y * NR_COLUMNS * 2) + offset = (Buf->dwCoord.Y * DeviceExtension->Columns * 2) +
(Buf->dwCoord.X * 2) + 1; (Buf->dwCoord.X * 2) + 1;
for (dwCount = 0; dwCount < stk->Parameters.Write.Length; dwCount++, pChar++) for (dwCount = 0; dwCount < stk->Parameters.Write.Length; dwCount++, pChar++)
@ -543,10 +538,6 @@ NTSTATUS ScrIoControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
} }
VOID ScrStartIo(PDEVICE_OBJECT DeviceObject, PIRP Irp) VOID ScrStartIo(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{ {
// PIO_STACK_LOCATION stk = IoGetCurrentIrpStackLocation(Irp); // PIO_STACK_LOCATION stk = IoGetCurrentIrpStackLocation(Irp);
@ -615,4 +606,3 @@ DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
return (STATUS_SUCCESS); return (STATUS_SUCCESS);
} }