X-Git-Url: http://git.joshuawise.com/netwatch.git/blobdiff_plain/015cd976c6ff9a00fded2edbc617daf85b7b3ca1..1458b27545d4e447e751a3baa653bb9641027a24:/aseg/counter.c?ds=sidebyside diff --git a/aseg/counter.c b/aseg/counter.c index edad021..61f9b6f 100644 --- a/aseg/counter.c +++ b/aseg/counter.c @@ -1,11 +1,61 @@ +#include + char counter = 0; +unsigned long pcisave; +unsigned char vgasave; +unsigned char thestr[512]; -#define outb(port, val) \ -({ asm volatile("outb %0, %%dx" : : "a" ((unsigned char)(val)) , "d" ((unsigned short)(port))); }) +void memcpy(char *dst, char *src, int c) +{ + while (c--) + *(dst++) = *(src++); +} + +void strcpy(char *dst, char *src) +{ + while (*src) + *(dst++) = *(src++); +} + +unsigned char vgaread(unsigned char idx) +{ + outb(0x3D4, idx); + inb(0x3D5); +} + +void strblit(char *src) +{ + char *destp = (char*)(0xB8000 | (vgaread(0xC) << 5) | (vgaread(0xD) << 1)); + while (*src) + { + *(destp++) = *(src++); + *(destp++) = 0x1F; + } +} void __start (void) { + unsigned char smramc; + + pcisave = inl(0xCF8); + vgasave = inb(0x3D4); + counter++; - outb (0x80, counter); + outb(0x80, counter); + + strcpy(thestr, "15-412!"); + + smramc = pci_read8(0, 0, 0, 0x70); + pci_write8(0, 0, 0, 0x70, (smramc & 0xF3) | 0x08); + strblit(thestr); + pci_write8(0, 0, 0, 0x70, smramc); + + outl(0xCF8, pcisave); + outb(0x3D4, vgasave); + + outb(0x834, 0x40); // ack the periodic IRQ + outb(0x830, (inb(0x830) | 0x2) & ~0x40); + outb(0x830, inb(0x830) | 0x40); + }