DWORD OEMKitlGetSecs() { SYSTEMTIME st; DWORD dwRet; static DWORD dwLastTime; // For making sure we aren't running backward static DWORD dwBias; // after post-init, it's possible that someone is holding the RTC CS, and we cannot safely call OEMGetRealTime while in KITL. // So we use CurMSec directly after post init. // NOTE: if this function is called while interrupts are off, the time will not advance. // if (!IsAfterPostInit()) { OEMGetRealTime( &st ); dwRet = ((60UL * (60UL * (24UL * (31UL * st.wMonth + st.wDay) + st.wHour) + st.wMinute)) + st.wSecond); dwBias = dwRet; } else { dwRet = (CurMSec/1000) + dwBias; } if (dwRet < dwLastTime) { KITLOutputDebugString ("! Time went backwards (or wrapped): cur: %u, last %u\n", dwRet,dwLastTime); } dwLastTime = dwRet; return (dwRet); }
void S3C6400UART_PowerOn(void) { UINT32 DivSlot; float Div; OEMInitDebugSerial(); // for What ??? KITLOutputDebugString ("[KITL] S3C6400UART_PowerOn()\r\n"); if (KitlIoPortBase == S3C6400_BASE_REG_PA_UART0) { // UART0 Clock Enable g_pSysConReg->PCLK_GATE |= (1<<1); // UART0 g_pSysConReg->SCLK_GATE |= (1<<5); // UART0~3 // UART0 Port Initialize (RXD0 : GPA0, TXD0: GPA1) g_pGPIOReg->GPACON = (g_pGPIOReg->GPACON & ~(0xff<<0)) | (0x22<<0); // GPA0->RXD0, GPA1->TXD0 g_pGPIOReg->GPAPUD = (g_pGPIOReg->GPAPUD & ~(0xf<<0)) | (0x1<<0); // RXD0: Pull-down, TXD0: pull up/down disable } else if (KitlIoPortBase == S3C6400_BASE_REG_PA_UART1) { // UART1 Clock Enable g_pSysConReg->PCLK_GATE |= (1<<2); // UART1 g_pSysConReg->SCLK_GATE |= (1<<5); // UART0~3 // UART1 Port Initialize (RXD1 : GPA4, TXD1: GPA5) g_pGPIOReg->GPACON = (g_pGPIOReg->GPACON & ~(0xff<<16)) | (0x22<<16); // GPA4->RXD1, GPA5->TXD1 g_pGPIOReg->GPAPUD = (g_pGPIOReg->GPAPUD & ~(0xf<<8)) | (0x1<<8); // RXD1: Pull-down, TXD1: pull up/down disable } else if (KitlIoPortBase == S3C6400_BASE_REG_PA_UART2) { // UART2 Clock Enable g_pSysConReg->PCLK_GATE |= (1<<3); // UART2 g_pSysConReg->SCLK_GATE |= (1<<5); // UART0~3 // UART2 Port Initialize (RXD2 : GPB0, TXD2: GPB1) g_pGPIOReg->GPBCON = (g_pGPIOReg->GPBCON & ~(0xff<<0)) | (0x22<<0); // GPB0->RXD2, GPB1->TXD2 g_pGPIOReg->GPBPUD = (g_pGPIOReg->GPBPUD & ~(0xf<<0)) | (0x1<<0); // RXD2: Pull-down, TXD2: pull up/down disable } else if (KitlIoPortBase == S3C6400_BASE_REG_PA_UART3) { // UART3 Clock Enable g_pSysConReg->PCLK_GATE |= (1<<4); // UART3 g_pSysConReg->SCLK_GATE |= (1<<5); // UART0~3 // UART3 Port Initialize (RXD3 : GPB2, TXD3: GPB3) g_pGPIOReg->GPBCON = (g_pGPIOReg->GPBCON & ~(0xff<<8)) | (0x22<<8); // GPB2->RXD3, GPB3->TXD3 g_pGPIOReg->GPBPUD = (g_pGPIOReg->GPBPUD & ~(0xf<<4)) | (0x1<<4); // RXD3: Pull-down, TXD3: pull up/down disable } // Initialize UART // g_pUARTReg->ULCON = (0<<6)|(0<<3)|(0<<2)|(3<<0); // Normal Mode, No Parity, 1 Stop Bit, 8 Bit Data g_pUARTReg->UCON = (0<<10)|(1<<9)|(1<<8)|(0<<7)|(0<<6)|(0<<5)|(0<<4)|(1<<2)|(1<<0); // PCLK divide, Polling Mode g_pUARTReg->UFCON = (0<<6)|(0<<4)|(0<<2)|(0<<1)|(0<<0); // Disable FIFO g_pUARTReg->UMCON = (0<<5)|(0<<4)|(0<<0); // Disable Auto Flow Control Div = (float)((float)S3C6400_PCLK/(16.0*(float)CBR_115200)) - 1; DivSlot = (UINT32)((Div-(int)Div)*16); g_pUARTReg->UBRDIV = (UINT32)Div; g_pUARTReg->UDIVSLOT = aSlotTable[DivSlot]; }
//------------------------------------------------------------------------------ static BOOL VerifyChecksum (DWORD cbRecord, LPBYTE pbRecord, DWORD dwChksum) { // Check the CRC DWORD dwCRC = 0; DWORD i; for (i = 0; i < cbRecord; i++) dwCRC += *pbRecord ++; if (dwCRC != dwChksum) KITLOutputDebugString ("ERROR: Checksum failure (expected=0x%x computed=0x%x)\r\n", dwChksum, dwCRC); return (dwCRC == dwChksum); }
// discard outstanding messages when reset static VOID PDD_DiscardPendingMessages() { PLIST_ENTRY pLink; PDATA_WRAPPER pDataWrapper; DWORD dwDiscards = 0; while (!IsListEmpty(&(g_RndisKitlDev.listTxRndisMessageQueue))) { // remove pending message pLink = RemoveHeadList(&(g_RndisKitlDev.listTxRndisMessageQueue)); pDataWrapper = CONTAINING_RECORD(pLink, DATA_WRAPPER, Link); // let MDD free buffer MddSendRndisMessageComplete(pDataWrapper); // record number ++dwDiscards; } KITLOutputDebugString("Discard %d Pending Messages\r\n", dwDiscards); }
DWORD OEMKitlGetSecs (void) { SYSTEMTIME st; DWORD dwRet; static DWORD dwBias; static DWORD dwLastTime; OEMGetRealTime( &st ); dwRet = ((60UL * (60UL * (24UL * (31UL * st.wMonth + st.wDay) + st.wHour) + st.wMinute)) + st.wSecond); dwBias = dwRet; if (dwRet < dwLastTime) { KITLOutputDebugString("[KITL] Time went backwards (or wrapped): cur: %u, last %u\n", dwRet,dwLastTime); } dwLastTime = dwRet; return (dwRet); }
//------------------------------------------------------------------------------ // // Function: printPCIConfig // // Dumps information about a PCI card // static void printPCIConfig( __in const PCI_COMMON_CONFIG* const config ) { KITLOutputDebugString("+printPCIConfig\r\n"); KITLOutputDebugString("config.VendorID = 0x%x\r\n", config->VendorID); KITLOutputDebugString("config.DeviceID = 0x%x\r\n", config->DeviceID); KITLOutputDebugString("config.Command = 0x%x\r\n", config->Command); KITLOutputDebugString("config.Status = 0x%x\r\n", config->Status); KITLOutputDebugString("config.RevisionID = 0x%x\r\n", config->RevisionID); KITLOutputDebugString("config.ProgIf = 0x%x\r\n", config->ProgIf); KITLOutputDebugString("config.SubClass = 0x%x\r\n", config->SubClass); KITLOutputDebugString("config.BaseClass = 0x%x\r\n", config->BaseClass); KITLOutputDebugString("config.CacheLineSize = 0x%x\r\n", config->CacheLineSize); KITLOutputDebugString("config.LatencyTimer = 0x%x\r\n", config->LatencyTimer); KITLOutputDebugString("config.HeaderType = 0x%x\r\n", config->HeaderType); KITLOutputDebugString("config.BIST = 0x%x\r\n", config->BIST); KITLOutputDebugString("config.BaseAddresses[0] = 0x%x\r\n", config->u.type1.BaseAddresses[0]); KITLOutputDebugString("config.BaseAddresses[1] = 0x%x\r\n", config->u.type1.BaseAddresses[1]); KITLOutputDebugString("config.PrimaryBusNumber = 0x%x\r\n", config->u.type1.PrimaryBusNumber); KITLOutputDebugString("config.SecondaryBusNumber = 0x%x\r\n", config->u.type1.SecondaryBusNumber); KITLOutputDebugString("config.SubordinateBusNumber = 0x%x\r\n", config->u.type1.SubordinateBusNumber); KITLOutputDebugString("config.SecondaryLatencyTimer = 0x%x\r\n", config->u.type1.SecondaryLatencyTimer); KITLOutputDebugString("config.IOBase = 0x%x\r\n", config->u.type1.IOBase); KITLOutputDebugString("config.IOLimit = 0x%x\r\n", config->u.type1.IOLimit); KITLOutputDebugString("config.SecondaryStatus = 0x%x\r\n", config->u.type1.SecondaryStatus); KITLOutputDebugString("config.MemoryBase = 0x%x\r\n", config->u.type1.MemoryBase); KITLOutputDebugString("config.MemoryLimit = 0x%x\r\n", config->u.type1.MemoryLimit); KITLOutputDebugString("config.PrefetchableMemoryBase = 0x%x\r\n", config->u.type1.PrefetchableMemoryBase); KITLOutputDebugString("config.PrefetchableMemoryLimit = 0x%x\r\n", config->u.type1.PrefetchableMemoryLimit); KITLOutputDebugString("config.PrefetchableMemoryBaseUpper32 = 0x%x\r\n", config->u.type1.PrefetchableMemoryBaseUpper32); KITLOutputDebugString("config.PrefetchableMemoryLimitUpper32 = 0x%x\r\n", config->u.type1.PrefetchableMemoryLimitUpper32); KITLOutputDebugString("config.IOBaseUpper = 0x%x\r\n", config->u.type1.IOBaseUpper); KITLOutputDebugString("config.IOLimitUpper = 0x%x\r\n", config->u.type1.IOLimitUpper); KITLOutputDebugString("config.Reserved2 = 0x%x\r\n", config->u.type1.Reserved2); KITLOutputDebugString("config.ExpansionROMBase = 0x%x\r\n", config->u.type1.ExpansionROMBase); KITLOutputDebugString("config.InterruptLine = 0x%x\r\n", config->u.type1.InterruptLine); KITLOutputDebugString("config.InterruptPin = 0x%x\r\n", config->u.type1.InterruptPin); KITLOutputDebugString("config.BridgeControl = 0x%x\r\n", config->u.type1.BridgeControl); KITLOutputDebugString("-printPCIConfig\r\n"); }
//------------------------------------------------------------------------------ // // Function: InitKitlNIC // // Finds a supported PCI NIC, matching against g_NicSupported // If nothing is found it will return attempt to use dwDfltType with the input params, dwIrq and dwIoBase. // If that failes too, it will return NULL // PCKITL_NIC_INFO InitKitlNIC( DWORD dwIrq, DWORD dwIoBase, DWORD dwDfltType ) { PCI_COMMON_CONFIG pciConfig; int funcType, bus, device, function; PCSUPPORTED_NIC pNicFound; int length = 0; enum { FIND_BY_VENDOR, // 0 FIND_BY_TYPE // 1 }; // InitKitlNIC returns a pointer to this static KTIL_NIC_INFO KitlNic; KITLOutputDebugString("InitKitlNIC: Searching for PCI Ethernet NIC (dwIrq = %x, dwIoBase = %x, dwDfltType = %x) ...\r\n", dwIrq, dwIoBase, dwDfltType); // Pass 1: iterate searching for vendor (this is the best match) // Pass 2: iterate searching for matching type for (funcType = FIND_BY_VENDOR; funcType <= FIND_BY_TYPE; funcType++) { // iterate through buses for (bus = 0; bus < PCI_MAX_BUS; bus++) { // iterate through devices for (device = 0; device < PCI_MAX_DEVICES; device++) { // iterate through functions for (function = 0; function < PCI_MAX_FUNCTION; function++) { // read PCI config data OAL_PCI_LOCATION pciLoc; pciLoc.logicalLoc = bus << 16 | device << 8 | function; length = OALPCICfgRead(0, pciLoc, 0, (sizeof(pciConfig) - sizeof(pciConfig.DeviceSpecific)), &pciConfig); if (length == 0 || (pciConfig.VendorID == 0xFFFF)) break; // network controller or USB? if ( ( (pciConfig.BaseClass == PCI_CLASS_NETWORK_CTLR) && (pciConfig.SubClass == PCI_SUBCLASS_NET_ETHERNET_CTLR)) // Network device. || ( (pciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV) && (pciConfig.SubClass == PCI_SUBCLASS_BR_OTHER))) { // Other Unknown Special Devices DWORD dwFoundBase = pciConfig.u.type0.BaseAddresses[0] & 0xFFFFFFFC; DWORD dwFoundIrq = pciConfig.u.type0.InterruptLine; if (dwFoundIrq && dwFoundBase) { if ( (!dwIrq && !dwIoBase) // IRQ && IoBase not specified -- use 1st found || (dwIrq == OAL_KITL_IRQ_INVALID) // Undefined IRQ = Poll mode -- use first found || (!dwIoBase && (dwIrq == dwFoundIrq)) // IRQ match, no IO base specified || (dwIoBase == dwFoundBase)) // IOBase match { if(funcType == FIND_BY_VENDOR) { pNicFound = FindNICByVendor (&pciConfig); } else if(funcType == FIND_BY_TYPE) { pNicFound = FindNICByType ((UCHAR) dwDfltType); } if (pNicFound) { // found NIC card KitlNic.dwIoBase = dwFoundBase; KitlNic.dwIrq = dwFoundIrq; KitlNic.dwBus = bus; KitlNic.dwDevice = device; KitlNic.dwFunction = function; KitlNic.pDriver = pNicFound->pDriver; KitlNic.dwType = pNicFound->Type; memcpy (&KitlNic.pciConfig, &pciConfig, sizeof(pciConfig)); KITLOutputDebugString ("InitKitlNIC: Found PCI Ethernet NIC (type = %x, IRQ=%d, IOBase=0x%x).\r\n", pNicFound->Type, dwFoundIrq, dwFoundBase); return &KitlNic; } else { KITLOutputDebugString ("InitKitlNIC: skipping unknown PCI Ethernet NIC: (subclass=%x, Vendor=%x, Device=%x)\r\n", pciConfig.SubClass, pciConfig.VendorID, pciConfig.DeviceID); } } else { // found a NIC, but it didn't match what the bootloader was using KITLOutputDebugString ("InitKitlNIC: skipping PCI Ethernet NIC: (subclass = %x, IRQ=%d, IOBase=0x%x).\r\n", pciConfig.SubClass, dwFoundIrq, dwFoundBase); } } } if (function == 0 && !(pciConfig.HeaderType & 0x80)) break; } if (length == 0) break; } if (length == 0 && device == 0) break; } } // can't find it on PCI bus, if IRQ and IoBase are specified, use it if (dwIrq && dwIoBase && (pNicFound = FindNICByType ((UCHAR) dwDfltType))) { KitlNic.dwIoBase = dwIoBase; KitlNic.dwIrq = dwIrq; KitlNic.pDriver = pNicFound->pDriver; KitlNic.dwType = dwDfltType; // Signal that we're using a device but it's not on the PCI bus memset(&KitlNic.pciConfig, LEGACY_KITL_DEVICE_BYTEPATTERN, sizeof(pciConfig)); KITLOutputDebugString ("InitKitlNIC: Can't find PCI Ethernet NIC, use specified data (type = %x, IRQ=%d, IOBase=0x%x).\r\n", pNicFound->Type, dwIrq, dwIoBase); return &KitlNic; } return NULL; }
/* S3C6400UART_Init * * Called by PQOAL KITL framework to initialize the serial port * * Return Value: */ BOOL S3C6400UART_Init (KITL_SERIAL_INFO *pSerInfo) { UINT32 DivSlot; float Div; KITLOutputDebugString ("[KITL] ++S3C6400UART_Init()\r\n"); KITLOutputDebugString ("[KITL] pAddress = 0x%x\n", pSerInfo->pAddress); KITLOutputDebugString ("[KITL] BaudRate = 0x%x\n", pSerInfo->baudRate); KITLOutputDebugString ("[KITL] DataBits = 0x%x\n", pSerInfo->dataBits); KITLOutputDebugString ("[KITL] StopBits = 0x%x\n", pSerInfo->stopBits); KITLOutputDebugString ("[KITL] Parity = 0x%x\n", pSerInfo->parity); KitlIoPortBase = (DWORD)pSerInfo->pAddress; if (KitlIoPortBase == 0) { KITLOutputDebugString ("[KITL:ERR] KitlIoPortBase is NULL\r\n"); return FALSE; } g_pUARTReg = (S3C6400_UART_REG *)OALPAtoVA(KitlIoPortBase, FALSE); g_pGPIOReg = (S3C6400_GPIO_REG *)OALPAtoVA(S3C6400_BASE_REG_PA_GPIO, FALSE); g_pSysConReg = (S3C6400_SYSCON_REG *)OALPAtoVA(S3C6400_BASE_REG_PA_SYSCON, FALSE); if (KitlIoPortBase == S3C6400_BASE_REG_PA_UART0) { // UART0 Clock Enable g_pSysConReg->PCLK_GATE |= (1<<1); // UART0 g_pSysConReg->SCLK_GATE |= (1<<5); // UART0~3 // UART0 Port Initialize (RXD0 : GPA0, TXD0: GPA1) g_pGPIOReg->GPACON = (g_pGPIOReg->GPACON & ~(0xff<<0)) | (0x22<<0); // GPA0->RXD0, GPA1->TXD0 g_pGPIOReg->GPAPUD = (g_pGPIOReg->GPAPUD & ~(0xf<<0)) | (0x1<<0); // RXD0: Pull-down, TXD0: pull up/down disable } else if (KitlIoPortBase == S3C6400_BASE_REG_PA_UART1) { // UART1 Clock Enable g_pSysConReg->PCLK_GATE |= (1<<2); // UART1 g_pSysConReg->SCLK_GATE |= (1<<5); // UART0~3 // UART1 Port Initialize (RXD1 : GPA4, TXD1: GPA5) g_pGPIOReg->GPACON = (g_pGPIOReg->GPACON & ~(0xff<<16)) | (0x22<<16); // GPA4->RXD1, GPA5->TXD1 g_pGPIOReg->GPAPUD = (g_pGPIOReg->GPAPUD & ~(0xf<<8)) | (0x1<<8); // RXD1: Pull-down, TXD1: pull up/down disable } else if (KitlIoPortBase == S3C6400_BASE_REG_PA_UART2) { // UART2 Clock Enable g_pSysConReg->PCLK_GATE |= (1<<3); // UART2 g_pSysConReg->SCLK_GATE |= (1<<5); // UART0~3 // UART2 Port Initialize (RXD2 : GPB0, TXD2: GPB1) g_pGPIOReg->GPBCON = (g_pGPIOReg->GPBCON & ~(0xff<<0)) | (0x22<<0); // GPB0->RXD2, GPB1->TXD2 g_pGPIOReg->GPBPUD = (g_pGPIOReg->GPBPUD & ~(0xf<<0)) | (0x1<<0); // RXD2: Pull-down, TXD2: pull up/down disable } else if (KitlIoPortBase == S3C6400_BASE_REG_PA_UART3) { // UART3 Clock Enable g_pSysConReg->PCLK_GATE |= (1<<4); // UART3 g_pSysConReg->SCLK_GATE |= (1<<5); // UART0~3 // UART3 Port Initialize (RXD3 : GPB2, TXD3: GPB3) g_pGPIOReg->GPBCON = (g_pGPIOReg->GPBCON & ~(0xff<<8)) | (0x22<<8); // GPB2->RXD3, GPB3->TXD3 g_pGPIOReg->GPBPUD = (g_pGPIOReg->GPBPUD & ~(0xf<<4)) | (0x1<<4); // RXD3: Pull-down, TXD3: pull up/down disable } // Initialize UART // g_pUARTReg->ULCON = (0<<6)|(0<<3)|(0<<2)|(3<<0); // Normal Mode, No Parity, 1 Stop Bit, 8 Bit Data g_pUARTReg->UCON = (0<<10)|(1<<9)|(1<<8)|(0<<7)|(0<<6)|(0<<5)|(0<<4)|(1<<2)|(1<<0); // PCLK divide, Polling Mode g_pUARTReg->UFCON = (0<<6)|(0<<4)|(0<<2)|(0<<1)|(0<<0); // Disable FIFO g_pUARTReg->UMCON = (0<<5)|(0<<4)|(0<<0); // Disable Auto Flow Control Div = (float)((float)S3C6400_PCLK/(16.0*(float)CBR_115200)) - 1; DivSlot = (UINT32)((Div-(int)Div)*16); g_pUARTReg->UBRDIV = (UINT32)Div; g_pUARTReg->UDIVSLOT = aSlotTable[DivSlot]; pSerInfo->bestSize = 1; // read it one by one KITLOutputDebugString ("[KITL] --S3C6400UART_Init()\r\n"); return TRUE; }
void S3C6400UART_PowerOff(void) { KITLOutputDebugString ("[KITL] S3C6400UART_PowerOff()\r\n"); return; }
BOOL OEMKitlStartup(void) { OAL_KITL_ARGS kitlArgs; OAL_KITL_ARGS *pArgs; BOOL bRet = FALSE; UCHAR *szDeviceId,buffer[OAL_KITL_ID_SIZE]="\0"; OALMSG(OAL_KITL&&OAL_FUNC, (L"[KITL] ++OEMKitlStartup()\r\n")); OALMSG(TRUE, (L"[KITL] ++OEMKitlStartup()\r\n")); memset(&kitlArgs, 0, sizeof (kitlArgs)); pArgs = (OAL_KITL_ARGS *)OALArgsQuery(OAL_ARGS_QUERY_KITL); szDeviceId = (UCHAR*)OALArgsQuery(OAL_ARGS_QUERY_DEVID); // Common parts kitlArgs.devLoc.IfcType = InterfaceTypeUndefined; g_kitlDevice.ifcType = InterfaceTypeUndefined; if((pArgs->flags & OAL_KITL_FLAGS_ENABLED) == 0) { RETAILMSG(1,(TEXT("KITL was Disabled from EBOOT !!\r\nPlease set KITL Configuration in EBoot !!\r\n"))); return FALSE; } #ifdef KITL_SERIAL KITLOutputDebugString ("[KITL] KITL: Serial\n"); bRet = InitKitlSerialArgs (&kitlArgs); strcpy(buffer,"6400SerialKITL"); szDeviceId = buffer; g_kitlDevice.id = kitlArgs.devLoc.LogicalLoc; #endif #ifdef KITL_USBSERIAL KITLOutputDebugString ("[KITL] KITL: USB Serial\n"); bRet = InitKitlUSBSerialArgs (&kitlArgs); strcpy(buffer,"6400USBSerialKITL"); szDeviceId = buffer; g_kitlDevice.id = kitlArgs.devLoc.LogicalLoc; #endif #ifdef KITL_USBRNDIS // TODO: TO be implemented #endif #ifdef KITL_ETHERNET KITLOutputDebugString("[KITL]: Ethernet\r\n"); if (pArgs->devLoc.LogicalLoc == 0) { KITLOutputDebugString ("[KITL] pArgs = NULL\n"); bRet = InitKitlEtherArgs(&kitlArgs); OALKitlCreateName(BSP_DEVICE_PREFIX, kitlArgs.mac, buffer); szDeviceId = buffer; g_kitlDevice.id = kitlArgs.devLoc.LogicalLoc; } else { KITLOutputDebugString ("[KITL] Kitl args bring from argument setting of RAM\n"); pArgs->flags |= OAL_KITL_FLAGS_VMINI; memcpy(&kitlArgs, pArgs, sizeof(kitlArgs)); g_kitlDevice.name = L"6400Ethernet"; g_kitlDevice.ifcType = kitlArgs.devLoc.IfcType; g_kitlDevice.id = kitlArgs.devLoc.LogicalLoc; g_kitlDevice.type = OAL_KITL_TYPE_ETH; g_kitlDevice.pDriver = (void *)&g_kitlEthCS8900A; bRet = TRUE; } #endif // KITL_ETHERNET RETAILMSG(KITL_DBON, (L"DeviceId................. %hs\r\n", szDeviceId)); RETAILMSG(KITL_DBON, (L"kitlArgs.flags............. 0x%x\r\n", kitlArgs.flags)); RETAILMSG(KITL_DBON, (L"kitlArgs.devLoc.IfcType.... %d\r\n", kitlArgs.devLoc.IfcType)); RETAILMSG(KITL_DBON, (L"kitlArgs.devLoc.LogicalLoc. 0x%x\r\n", kitlArgs.devLoc.LogicalLoc)); RETAILMSG(KITL_DBON, (L"kitlArgs.devLoc.PhysicalLoc 0x%x\r\n", kitlArgs.devLoc.PhysicalLoc)); RETAILMSG(KITL_DBON, (L"kitlArgs.devLoc.Pin........ %d\r\n", kitlArgs.devLoc.Pin)); RETAILMSG(KITL_DBON, (L"kitlArgs.ip4address........ %s\r\n", OALKitlIPtoString(kitlArgs.ipAddress))); if (bRet == FALSE) { KITLOutputDebugString ("[KITL] KITL: None\n"); RETAILMSG(TRUE, (TEXT("[KITL] KITL Argument Initialize Fail !!\n"))); return FALSE; } KITLOutputDebugString ("[KITL] Call OALKitlInit()\r\n"); bRet = OALKitlInit ((LPCSTR)szDeviceId, &kitlArgs, &g_kitlDevice); OALMSG(OAL_KITL&&OAL_FUNC, (L"[KITL] --OEMKitlStartup() = %d\r\n", bRet)); OALMSG(TRUE, (L"[KITL] --OEMKitlStartup() = %d\r\n", bRet)); return bRet; }
VOID BLWriteFlashNK(OAL_BLMENU_ITEM *pMenu) { DWORD i = 0; UCHAR ch; DWORD dwImageStart, dwImageLength, dwRecAddr, dwRecLen, dwRecChk; DWORD dwRecNum = 0; LPBYTE lpDest = NULL; OAL_KITL_TYPE bkType; wcscpy(g_bootCfg.filename, L"nk.bin"); if (BL_ERROR == BLSDCardDownload(g_bootCfg.filename)) { OALLog(TEXT("SD boot failed to open file\r\n")); goto CleanUp; } bkType = g_eboot.type; g_eboot.bootDeviceType = BOOT_SDCARD_TYPE; g_eboot.type = DOWNLOAD_TYPE_RAM; for (i=0; i < 7; i++) OEMReadData(1, &ch); if (!OEMReadData (sizeof (DWORD), (LPBYTE) &dwImageStart) || !OEMReadData (sizeof (DWORD), (LPBYTE) &dwImageLength)) { KITLOutputDebugString ("Unable to read image start/length\r\n"); return ; } while ( OEMReadData (sizeof (DWORD), (LPBYTE) &dwRecAddr) && OEMReadData (sizeof (DWORD), (LPBYTE) &dwRecLen) && OEMReadData (sizeof (DWORD), (LPBYTE) &dwRecChk) ) { KITLOutputDebugString(" <> Record [ %d ] dwRecAddr = 0x%x, dwRecLen = 0x%x\r\n", dwRecNum, dwRecAddr, dwRecLen); dwRecNum++; // last record of .bin file uses sentinel values for address and checksum. if (!dwRecAddr && !dwRecChk) { break; } // map the record address (FLASH data is cached, for example) lpDest = OEMMapMemAddr (dwImageStart, dwRecAddr); // read data block if (!OEMReadData (dwRecLen, lpDest)) { KITLOutputDebugString ("****** Data record %d corrupted, ABORT!!! ******\r\n", dwRecNum); return ; } if (!VerifyChecksum (dwRecLen, lpDest, dwRecChk)) { KITLOutputDebugString ("****** Checksum failure on record %d, ABORT!!! ******\r\n", dwRecNum); return ; } // Look for ROMHDR to compute ROM offset. NOTE: romimage guarantees that the record containing // the TOC signature and pointer will always come before the record that contains the ROMHDR contents. // if (dwRecLen == sizeof(ROMHDR) && (*(LPDWORD) OEMMapMemAddr(dwImageStart, dwImageStart+ROM_SIGNATURE_OFFSET) == ROM_SIGNATURE)) { DWORD dwTempOffset = (dwRecAddr - *(LPDWORD)OEMMapMemAddr(dwImageStart, dwImageStart+ ROM_SIGNATURE_OFFSET + sizeof(ULONG))); ROMHDR *pROMHdr = (ROMHDR *)lpDest; // Check to make sure this record really contains the ROMHDR. // if ((pROMHdr->physfirst == (dwImageStart - dwTempOffset)) && (pROMHdr->physlast == (dwImageStart - dwTempOffset + dwImageLength)) && (DWORD)(HIWORD(pROMHdr->dllfirst << 16) <= pROMHdr->dlllast) && (DWORD)(LOWORD(pROMHdr->dllfirst << 16) <= pROMHdr->dlllast)) { KITLOutputDebugString("rom_offset=0x%x.\r\n", dwTempOffset); } } } // while( records remaining ) g_eboot.bootDeviceType = bkType; //g_eboot.type = DOWNLOAD_TYPE_RAM; g_eboot.type = DOWNLOAD_TYPE_FLASHNAND; if (OEMWriteFlash(dwImageStart, dwImageLength)) OALLog(L"BLWriteFlashNK success..\n"); else OALLog(L"BLWriteFlashNK fail..\n"); //write boot device for nand flash if (BLWriteBootCfg(&g_bootCfg)) { OALLog(L" Current settings has been saved\r\n"); } else { OALLog(L"ERROR: Settings save failed!\r\n"); } CleanUp: return; }