From: Jacob Potter Date: Fri, 26 Sep 2008 02:48:21 +0000 (-0400) Subject: add some more structured packet handling X-Git-Url: http://git.joshuawise.com/netwatch.git/commitdiff_plain/0cd80c5181dfee5d7853de038f08303c6a33c01b?hp=--cc add some more structured packet handling --- 0cd80c5181dfee5d7853de038f08303c6a33c01b diff --git a/aseg/Makefile b/aseg/Makefile index 359759c..80ef859 100644 --- a/aseg/Makefile +++ b/aseg/Makefile @@ -1,6 +1,6 @@ CC=gcc CFLAGS=-I../include -I../include/raw -nostdlib -nostdinc -fno-builtin -D__RAW__ -Wall -Werror -pedantic -ansi -std=gnu99 -OBJS=counter.o firstrun.o ../pci/pci-raw.o ../lib/minilib.o ../lib/console.o ../ich2/smram-ich2.o ../ich2/smi.o vga-overlay.o ../lib/sprintf.o ../lib/doprnt.o +OBJS=counter.o firstrun.o ../pci/pci-raw.o ../lib/minilib.o ../lib/console.o ../ich2/smram-ich2.o ../ich2/smi.o vga-overlay.o packet.o ../lib/sprintf.o ../lib/doprnt.o all: aseg.elf diff --git a/aseg/counter.c b/aseg/counter.c index 88915dc..7b34f3a 100644 --- a/aseg/counter.c +++ b/aseg/counter.c @@ -4,6 +4,7 @@ #include #include #include "vga-overlay.h" +#include "packet.h" unsigned int counter = 0; unsigned long pcisave; @@ -70,7 +71,16 @@ void gbl_rls_handler(smi_event_t ev) unsigned long ecx; ecx = *(unsigned long*)0xAFFD4; - dologf("ECX was %08x", ecx); + + packet_t * packet = check_packet(ecx); + if (!packet) + { + dologf("WARN: bad packet at %08x", ecx); + return; + } + + dologf("Got packet: type %08x", packet->type); + *(unsigned long*)0xAFFD4 = 0x2BADD00D; } diff --git a/tools/.gitignore b/tools/.gitignore index e2ec8c1..4e3fe9d 100644 --- a/tools/.gitignore +++ b/tools/.gitignore @@ -1 +1,4 @@ smram-ich2 +port +pci +poke-rls diff --git a/tools/poke-rls-asm.S b/tools/poke-rls-asm.S index 980b4bf..2273169 100644 --- a/tools/poke-rls-asm.S +++ b/tools/poke-rls-asm.S @@ -1,7 +1,6 @@ .global poke poke: - # Preload registers: $0x1BADD00D - mov $0x1BADD00D, %ecx + mov 8(%esp), %ecx # Parameter: I/O port to set bit 2 of mov 4(%esp), %edx diff --git a/tools/poke-rls.c b/tools/poke-rls.c index 01de181..6946fb7 100644 --- a/tools/poke-rls.c +++ b/tools/poke-rls.c @@ -14,12 +14,21 @@ static uint16_t _get_PMBASE() return pmbase; } +typedef struct { + uint32_t signature; + uint32_t type; + uint8_t data[]; +} packet_t; -extern unsigned int poke(unsigned long addr); +extern unsigned int poke(unsigned long addr, unsigned long * value); int main(int argc, char **argv) { unsigned int res; + packet_t * packet = (packet_t *)memalign(4096, sizeof(packet_t)); + + packet->signature = 0x1BADD00D; + packet->type = 0xF00FC7C8; if (iopl(3) < 0) { @@ -27,6 +36,6 @@ int main(int argc, char **argv) return 1; } - res = poke(_get_PMBASE() + 0x04); - printf("found %p\n", res); + res = poke(_get_PMBASE() + 0x04, (void *)packet); + printf("returned %p\n", res); }