From: Joshua Wise Date: Mon, 10 Nov 2008 19:10:54 +0000 (-0500) Subject: p2v and v2p, in a manner of type A... X-Git-Url: http://git.joshuawise.com/netwatch.git/commitdiff_plain/68beefa85564e151acd18e12733897a5201fe67e p2v and v2p, in a manner of type A... --- diff --git a/aseg-paging/Makefile b/aseg-paging/Makefile index 58d2652..0bbe048 100644 --- a/aseg-paging/Makefile +++ b/aseg-paging/Makefile @@ -46,6 +46,7 @@ OBJS = ../ich2/smi.o \ ../lib/sprintf.o \ ../lib/console.o \ ../lib/serial.o \ + ../lib/paging.o \ ../aseg/keyboard.o \ ../aseg/packet.o \ $(LWIP_OBJS) \ diff --git a/aseg-paging/smi.c b/aseg-paging/smi.c index eada78d..bd29f64 100644 --- a/aseg-paging/smi.c +++ b/aseg-paging/smi.c @@ -15,27 +15,17 @@ unsigned char vgasave = 0; void smi_entry(void) { char statstr[512]; - outb(0x80, 0x0B); + pcisave = inl(0xCF8); vgasave = inb(0x3D4); - outb(0x80, 0x1B); -/* pci_unbother_all(); - */ + counter++; - outb(0x80, 0x2B); sprintf(statstr, "NetWatch! %08x %08x", smi_status(), counter); - outb(0x80, 0x3B); strblit(statstr, 0, 0); - outb(0x80, 0x4B); serial_init(); -/* dolog("wee!"); - */ - - /* eth_poll(); - */ if (inl(0x840) & 0x1000) { @@ -48,9 +38,8 @@ void smi_entry(void) smi_poll(); -/* + pci_bother_all(); - */ outl(0xCF8, pcisave); outb(0x3D4, vgasave); } diff --git a/include/paging.h b/include/paging.h new file mode 100644 index 0000000..69c12eb --- /dev/null +++ b/include/paging.h @@ -0,0 +1,7 @@ +#ifndef __PAGING_H +#define __PAGING_H + +extern unsigned long memory_v2p(void *virt); +extern void *memory_p2v(unsigned long phys); + +#endif diff --git a/lib/paging.c b/lib/paging.c new file mode 100644 index 0000000..8fe80a9 --- /dev/null +++ b/lib/paging.c @@ -0,0 +1,24 @@ +#include +#include + +unsigned long memory_v2p(void *virt) +{ + unsigned long _virt = (unsigned long)virt; + + if (_virt >= 0xA0000 && _virt < 0xC0000) + return _virt; + if (_virt >= 0x200000 && _virt < 0x300000) + return _virt - 0x200000 + /* XXX */ 0x1FF80000; + outputf("WARNING: v2p(%08x)", _virt); + return 0xFFFFFFFF; +} + +void *memory_p2v(unsigned long phys) +{ + if (phys >= 0xA0000 && phys < 0xC0000) + return (void*)phys; + if (phys >= 0x1FF80000 && phys < 0x20000000) + return (void*)(phys - 0x1FF80000 + 0x200000); + outputf("WARNING: p2v(%08x)", phys); + return (void *)0xFFFFFFFF; +} diff --git a/net/3c90x.c b/net/3c90x.c index 336e2a7..83a30ef 100644 --- a/net/3c90x.c +++ b/net/3c90x.c @@ -45,6 +45,7 @@ #include #include #include +#include #define XCVR_MAGIC (0x5A00) /** any single transmission fails after 16 collisions or other errors diff --git a/net/etherboot-compat.h b/net/etherboot-compat.h index 2d8d98f..b72885b 100644 --- a/net/etherboot-compat.h +++ b/net/etherboot-compat.h @@ -1,6 +1,8 @@ #ifndef _ETHERBOOT_COMPAT_H #define _ETHERBOOT_COMPAT_H +#include + #define ETH_ALEN 6 struct dev { @@ -18,6 +20,6 @@ struct nic { void (*transmit) (const char *dest_addr, unsigned int proto, unsigned int size, const char *pkt); }; -#define virt_to_bus(x) ((unsigned long)x) +#define virt_to_bus(x) memory_v2p((void *)(x)) #endif