Import backup from 2003-10-06
This commit is contained in:
parent
7a0351e123
commit
5da602b162
4
kernel.c
4
kernel.c
@ -68,7 +68,7 @@ void k_init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
mm_init();
|
mm_init();
|
||||||
mouse_enableData();
|
mouse_init();
|
||||||
enable_ints();
|
enable_ints();
|
||||||
printf("Memory available to OS: %d MB (Bytes: %d)\n", mm_totalmem/0x100000, mm_totalmem);
|
printf("Memory available to OS: %d MB (Bytes: %d)\n", mm_totalmem/0x100000, mm_totalmem);
|
||||||
pic1_mask(0); //unmask IRQ's 0-7
|
pic1_mask(0); //unmask IRQ's 0-7
|
||||||
@ -94,7 +94,7 @@ void isr(dword num)
|
|||||||
isr_keyboard(); //isr_keybard() takes care of calling eoi()
|
isr_keyboard(); //isr_keybard() takes care of calling eoi()
|
||||||
break;
|
break;
|
||||||
case 0x2C: // IRQ12 - PS/2 mouse
|
case 0x2C: // IRQ12 - PS/2 mouse
|
||||||
printf("InB: %x, %x, %x", inportb(0x60), inportb(0x60), inportb(0x60));
|
isr_mouse();
|
||||||
eoi2();
|
eoi2();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
51
mouse.c
51
mouse.c
@ -3,17 +3,54 @@
|
|||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
|
|
||||||
|
|
||||||
|
void mouse_init()
|
||||||
void mouse_enableData()
|
|
||||||
{
|
{
|
||||||
outportb(0x64, 0x60);
|
outportb(0x64, 0x20); //tell keyboard controller we are going to read keyboard controller command byte
|
||||||
outportb(0x60, 0x03);
|
byte temp = inportb(0x60); //read keyboard controller command byte
|
||||||
|
outportb(0x64, 0x60); //tell keyboard controller we are going to write keyboard controller command byte
|
||||||
|
outportb(0x60, 0x03 | (temp&0x40)); //write keyboard controller command byte: enable mouse/keyboard ints, include original XLATE bit from temp (bit6)
|
||||||
|
|
||||||
outportb(0x64, 0xA8); //enable mouse port
|
outportb(0x64, 0xA8); //enable mouse port
|
||||||
|
|
||||||
outportb(0x64, 0xD4); //send command to mouse, not kbd
|
outportb(0x64, 0xD4); //send command to mouse, not kbd
|
||||||
outportb(0x60, 0xF4); //enable data reporting
|
outportb(0x60, 0xF4); //enable data reporting
|
||||||
// outportb(0x60, 0xFA);
|
|
||||||
// inportb(0x60); //get ACK off 0x60 port
|
//outportb(0x64, 0xD4);
|
||||||
// outportb(0x60, 0xFF); //mouse reset
|
//outportb(0x60, 0xE7); //scaling 2:1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void isr_mouse()
|
||||||
|
{
|
||||||
|
byte inb = inportb(0x60); //read mouse byte
|
||||||
|
//printf("InB: %x\n", inb);
|
||||||
|
//return;
|
||||||
|
if ((inb == 0xFA) && (mouse_bytesRead < 1)) //ACK
|
||||||
|
return;
|
||||||
|
mouse_inbuffer[mouse_bytesRead] = inb;
|
||||||
|
mouse_bytesRead++;
|
||||||
|
if (mouse_bytesRead == 3) //complete packet received
|
||||||
|
{
|
||||||
|
mouse_bytesRead = 0;
|
||||||
|
int adjx = (char) mouse_inbuffer[1];
|
||||||
|
int adjy = (char) mouse_inbuffer[2];
|
||||||
|
mouse_x += adjx;
|
||||||
|
mouse_y -= adjy; //-= because screen y coordinates are opposite mouse y coordinates
|
||||||
|
if (mouse_inbuffer[0] & 0x01) //left button
|
||||||
|
{
|
||||||
|
video_pset(VXR/2+mouse_x, VYR/2+mouse_y, 0x00FFFFFF);
|
||||||
|
printf("X: %d, Y: %d\n", mouse_x, mouse_y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
video_pset(VXR/2+mouse_x, VYR/2+mouse_y, 0x00000000);
|
||||||
|
printf("X: %d, Y: %d\n", mouse_x, mouse_y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
9
mouse.h
9
mouse.h
@ -3,7 +3,14 @@
|
|||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
|
|
||||||
|
|
||||||
void mouse_enableData();
|
int mouse_x = 0;
|
||||||
|
int mouse_y = 0;
|
||||||
|
int mouse_bytesRead = 0;
|
||||||
|
byte mouse_inbuffer[16];
|
||||||
|
|
||||||
|
void mouse_init();
|
||||||
|
void isr_mouse();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
4
video.c
4
video.c
@ -1,10 +1,6 @@
|
|||||||
//video.c
|
//video.c
|
||||||
// 08/13/03 Josh Holtrop
|
// 08/13/03 Josh Holtrop
|
||||||
|
|
||||||
ModeInfoBlock video_mode;
|
|
||||||
byte *vid_ptr24;
|
|
||||||
word *vid_ptr16;
|
|
||||||
dword *vid_ptr32;
|
|
||||||
|
|
||||||
void video_init(ModeInfoBlock *mib)
|
void video_init(ModeInfoBlock *mib)
|
||||||
{
|
{
|
||||||
|
7
video.h
7
video.h
@ -1,6 +1,7 @@
|
|||||||
//video.h
|
//video.h
|
||||||
// 08/18/03 Josh Holtrop
|
// 08/18/03 Josh Holtrop
|
||||||
|
|
||||||
|
|
||||||
void video_init();
|
void video_init();
|
||||||
void video_horiz(int y, int x1, int x2, dword color);
|
void video_horiz(int y, int x1, int x2, dword color);
|
||||||
void video_vert(int x, int y1, int y2, dword color);
|
void video_vert(int x, int y1, int y2, dword color);
|
||||||
@ -52,6 +53,12 @@ typedef struct{
|
|||||||
byte Reserved[206];
|
byte Reserved[206];
|
||||||
} ModeInfoBlock;
|
} ModeInfoBlock;
|
||||||
|
|
||||||
|
ModeInfoBlock video_mode;
|
||||||
|
byte *vid_ptr24;
|
||||||
|
word *vid_ptr16;
|
||||||
|
dword *vid_ptr32;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user