1 /* 2 * Copyright 2006, Marcus Overhagen <marcus@overhagen.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #include <OS.h> 7 #include <KernelExport.h> 8 #include <string.h> 9 10 #include "pxe_undi.h" 11 12 #define TRACE_UNDI 13 #ifdef TRACE_UNDI 14 # define TRACE(x...) dprintf(x) 15 #else 16 # define TRACE(x...) 17 #endif 18 19 20 21 22 PXE_STRUCT *gPxeData; 23 24 25 PXE_STRUCT * 26 pxe_undi_find_data() 27 { 28 PXE_STRUCT *data = NULL; 29 for (char *addr = (char *)0x8D000; addr < (char *)0xA0000; addr += 16) { 30 if (*(uint32 *)addr == 'EXP!' /* '!PXE' */) { 31 TRACE("found !PXE at %p\n", addr); 32 data = (PXE_STRUCT *)addr; 33 break; 34 } 35 } 36 return data; 37 } 38 39 40 void 41 pxe_undi_init() 42 { 43 TRACE("pxe_undi_init\n"); 44 45 gPxeData = pxe_undi_find_data(); 46 if (!gPxeData) 47 panic("can't find !PXE structure"); 48 49 TRACE("entrypoint at %p\n", *(uint32 *)&gPxeData->EntryPointSP); 50 51 52 PXENV_UNDI_GET_INFORMATION get_info; 53 54 memset(&get_info, 0, sizeof(get_info)); 55 56 TRACE("PXENV_UNDI_GET_INFORMATION at %p\n", &get_info); 57 58 uint16 res = call_pxe_bios(gPxeData, UNDI_GET_INFORMATION, &get_info); 59 60 TRACE("res = %04x\n", res); 61 62 TRACE("Status = %x\n", get_info.Status); 63 TRACE("BaseIo = %x\n", get_info.BaseIo); 64 TRACE("IntNumber = %x\n", get_info.IntNumber); 65 TRACE("MaxTranUnit = %x\n", get_info.MaxTranUnit); 66 TRACE("HwType = %x\n", get_info.HwType); 67 TRACE("HwAddrLen = %x\n", get_info.HwAddrLen); 68 TRACE("MAC = %02x:%02x:%02x:%02x:%02x:%02x\n", get_info.CurrentNodeAddress[0], get_info.CurrentNodeAddress[1], 69 get_info.CurrentNodeAddress[2], get_info.CurrentNodeAddress[3], 70 get_info.CurrentNodeAddress[4], get_info.CurrentNodeAddress[5] ); 71 TRACE("RxBufCt = %x\n", get_info.RxBufCt); 72 TRACE("TxBufCt = %x\n", get_info.TxBufCt); 73 } 74