Newer
Older
Scratch / ubixos-home / src / sys / drivers / mouse.c
#include <drivers/8259.h>
#include <ubixos/io.h>
#include <ubixos/types.h>


void initMouse() {
  static uInt8 s1[] = { 0xF3, 0xC8, 0xF3, 0x64, 0xF3, 0x50, 0 };
  static uInt8 s2[] = { 0xF6, 0xE6, 0xF4, 0xF3, 0x64, 0xE8, 0x03, 0 };  
  uInt8 *ch;
  enableIrq(12);
  outportByte(0x64,0xA8);
  for (ch = s1; *ch; ch++) {
    outportByte(0x64,0xD4);
    outportByte(0x60,*ch);
    }
  for (ch = s2; *ch; ch++) {
    outportByte(0x64,0xD4);
    outportByte(0x60,*ch);
    }
  outportByte(0x64,0xA8);
  outportByte(0x60,0xF2);
  kprintf("inByte: [%i]\n",inportByte(0x64));
  kprintf("inByte: [%i]\n",inportByte(0x60));
  kprintf("inByte: [%i]\n",inportByte(0x64));
  kprintf("inByte: [%i]\n",inportByte(0x60));
  }
  
asm(
    ".global mouseISR    \n"
    "mouseISR:       \n"
//    "xchgl %eax,(%esp)   \n"
//    "pushl %ecx          \n"
//    "pushl %edx          \n"
//   "push %ds            \n"
//    "push %es            \n"
//    "push %fs            \n"
    "call mouseISR2      \n"
//    "pop %fs             \n"
//    "pop %es             \n"
//    "pop %ds             \n"
//    "popl %edx           \n"
//    "popl %ecx           \n"
//    "popl %eax           \n"
    "iret                \n"
    );  

void mouseISR2() {
  kprintf("MouseByte: [%i]\n",inportByte(0x60));
  }