static BOOL CheckUSBinUse(void) { // Check USB Device in Use if (*g_pOTGLinkReg & (0x3<<18)) { if (g_bDVSEN == TRUE) { g_bDVSEN = FALSE; // Disable DVS if (g_CurrentLevel != SYS_L0) { ChangeDVSLevel(SYS_L0); } OALMSG(OAL_POWER && OAL_FUNC, (L"[DVS] DVS disabled by USB\r\n")); } return TRUE; // Do not apply DVS, when USB is in Use } else { if (g_bDVSEN == FALSE) { // Enable DVS after USB operation finished g_bDVSEN = TRUE; OALMSG(OAL_POWER && OAL_FUNC, (L"[DVS] DVS enabled\r\n")); } } return FALSE; }
void OEMSWReset(void) { // // If the board design supports software-controllable hardware reset logic, it should be // used. Because this routine is specific to the S3C6410 CPU, it only uses the watchdog // timer to assert reset. One downside to this approach is that nRSTOUT isn't asserted // so any board-level logic isn't reset via this method. This routine can be overidden in // the specific platform code to control board-level reset logic, should it exist. // volatile S3C6410_SYSCON_REG *pSysConReg = (S3C6410_SYSCON_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_SYSCON, FALSE); OALMSG(TRUE, (L"[OEM] ++OEMSWReset()\r\n")); // HCLK_IROM, HCLK_MEM1, HCLK_MEM0, HCLK_MFC Should be Always On for power Mode (Something coupled with BUS operation) pSysConReg->HCLK_GATE |= ((1<<25)|(1<<22)|(1<<21)|(1<<0)); OALMSG(TRUE, (L"[OEM] + OEMSWReset() using watchdog timer\r\n")); // Generate Software Reset using watchdog timer _OEMSWReset(); // Wait for Reset // while(1); // Should Never Get Here // OALMSG(TRUE, (L"[OEM] --OEMSWReset() : Do Not See Me !!!!!! \r\n")); }
//------------------------------------------------------------------------------ // // Function: OALIntrEnableIrq/BSPIntrEnableIrq // // This function enable interrupt identified by IRQ. If implementation uses // platform callbacks it will call BSPIntrEnableIrq before IRQ is enabled in // hardware. The BSPIntrEnableIrq returns IRQ used for interrupt controller // chaining. // BOOL OALIntrEnableIrqs(UINT32 count, const UINT32 *pIrqs) { UINT32 irq, i; BOOL retVal = TRUE; SH4_RTC_REGS *pRTCRegs = OALPAtoUA(SH4_REG_PA_RTC); OALMSG(OAL_INTR&&OAL_VERBOSE, (L"+OALIntrEnableIrqs(%d, 0x%08x)\r\n", count, pIrqs)); for(i = 0; i < count; i++) { #ifndef OAL_BSP_CALLBACKS irq = pIrqs[i]; #else // Give the BSP a chance to enable the irq irq = BSPIntrEnableIrq(pIrqs[i]); #endif if(irq == OAL_INTR_IRQ_UNDEFINED) continue; switch(irq) { case IRQ_RTC_ATI: OUTREG8(&pRTCRegs->RCR1, INREG8(&pRTCRegs->RCR1) | RTC_RCR1_AIE); OALMSG(OAL_INTR&&OAL_VERBOSE, (L"INFO: IRQ_RTC_ATI Enabled\r\n")); break; default: OALMSG(OAL_ERROR, (L"ERROR: Unable to enable IRQ %d\r\n", irq)); retVal = FALSE; } } OALMSG(OAL_INTR&&OAL_VERBOSE, (L"-OALIntrEnableIrqs(rc = %d)\r\n", retVal)); return retVal; }
//------------------------------------------------------------------------------ // // Function: OALIntrDoneIrq/BSPIntrDoneIrq // // This function finish interrupt identified by IRQ. If implementation uses // platform callbacks it will call BSPIntrDoneIrq before IRQ is enabled in // hardware. The BSPIntrDoneIrq returns IRQ used for interrupt controller // chaining if it is suitable to finish it. In most cases implementation will // for both function will be similar to OALIntrEnableIrq/BSPIntrEnableIrq. // VOID OALIntrDoneIrqs(UINT32 count, const UINT32 *pIrqs) { UINT32 irq, i; SH4_RTC_REGS *pRTCRegs = OALPAtoUA(SH4_REG_PA_RTC); OALMSG(OAL_VERBOSE&&OAL_FUNC, (L"+OALIntrDoneIrqs(%d, 0x%08x)\r\n", count, pIrqs)); for(i = 0; i < count; i++) { #ifndef OAL_BSP_CALLBACKS irq = pIrqs[i]; #else irq = BSPIntrDoneIrq(pIrqs[i]); #endif if(irq == OAL_INTR_IRQ_UNDEFINED) continue; switch(irq) { case IRQ_RTC_ATI: // Clear alarm flag but do not reenable interrupt for the RTC Alarm // since that will happen the next time OEMSetAlarmTime is called OUTREG8(&pRTCRegs->RCR1, (INREG8(&pRTCRegs->RCR1) & ~(RTC_RCR1_AF))); break; default: OALMSG(OAL_ERROR, (L"ERROR: Unable to disable IRQ %d\r\n", irq)); } } OALMSG(OAL_VERBOSE&&OAL_FUNC, (L"-OALIntrDoneIrqs()\r\n")); }
//------------------------------------------------------------------------------ // // Function: OALIoCtlHalReboot // // BOOL OALIoCtlHalReboot(UINT32 code, VOID *pInpBuffer, UINT32 inpSize, VOID *pOutBuffer, UINT32 outSize, UINT32 *pOutSize) { // // If the board design supports software-controllable hardware reset logic, it should be // used. Because this routine is specific to the S3C2450 CPU, it only uses the watchdog // timer to assert reset. One downside to this approach is that nRSTOUT isn't asserted // so any board-level logic isn't reset via this method. This routine can be overidden in // the specific platform code to control board-level reset logic, should it exist. // volatile S3C2450_CLKPWR_REG *pCLKPWR = (S3C2450_CLKPWR_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_CLOCK_POWER, FALSE); //[david.modify] 2008-11-14 10:21 // lcpµØͼ¸´Î» DPSTR_R1("reboot"); return ; OALMSG(OAL_IOCTL&&OAL_FUNC, (L"+OALIoCtlHalReboot\r\n")); // Into reset pCLKPWR->SWRST = 0x533C2450; // Wait for watchdog reset... // while(TRUE); // Should never get to this point... // OALMSG(OAL_IOCTL&&OAL_FUNC, (L"-OALIoCtlHalReboot\r\n")); return(TRUE); }
//------------------------------------------------------------------------------ // // Function: OALIoCtlGetWakeSource // BOOL OALIoCtlHalGetWakeSource( UINT32 code, VOID* pInpBuffer, UINT32 inpSize, VOID* pOutBuffer, UINT32 outSize, UINT32 *pOutSize ) { BOOL rc = FALSE; OALMSG(OAL_POWER&&OAL_FUNC, (L"+OALIoCtlHalGetWakeSource\r\n")); if (pOutSize) { *pOutSize = sizeof(UINT32); } if (pOutBuffer == NULL && outSize > 0) { NKSetLastError(ERROR_INVALID_PARAMETER); goto cleanUp; } if (pOutBuffer == NULL || outSize < sizeof(UINT32)) { NKSetLastError(ERROR_INSUFFICIENT_BUFFER); goto cleanUp; } *(UINT32*)pOutBuffer = g_oalWakeSource; rc = TRUE; cleanUp: OALMSG(OAL_POWER&&OAL_FUNC, ( L"+OALIoCtlHalGetWakeSource(rc = %d, sysIntr = %d)\r\n", rc, *(UINT32*)pOutBuffer )); return rc; }
//------------------------------------------------------------------------------ // // Function: OEMStartEraseFlash // // This function is called by the bootloader to initiate the flash memory // erasing process. // BOOL OEMStartEraseFlash(ULONG address, ULONG size) { BOOL rc = FALSE; OALMSG(OAL_FUNC, ( L"+OEMStartEraseFlash(0x%08x, 0x%08x)\r\n", address, size )); if ( address < (UINT32)OALPAtoCA(IMAGE_FLASH_PA_START) || size > IMAGE_FLASH_SIZE ) { OALMSG(OAL_WARN, ( L"OEMStartEraseFlash: Invalid region (start 0x%08x size 0x%08x)\r\n", address, size )); goto cleanUp; } // Save address and size for later g_flashAddress = address; g_flashSize = size; rc = TRUE; cleanUp: OALMSG(OAL_FUNC, (L"-OEMStartEraseFlash(rc = %d)\r\n", rc)); return rc; }
//------------------------------------------------------------------------------ // // Function: OEMFinishEraseFlash // // This function is called by the bootloader to finish flash erase before // it will call OEMWriteFlash. // BOOL OEMFinishEraseFlash(void) { BOOL rc = FALSE; OALMSG(OAL_FUNC, (L"+OEMFinishEraseFlash\r\n")); OALMSG(OAL_WARN, ( L"Erase flash memory at 0x%08x size 0x%08x...", g_flashAddress, g_flashSize )); if (!OALFlashErase( OALPAtoUA(IMAGE_FLASH_PA_START), OALPAtoUA((VOID*)g_flashAddress), g_flashSize )) { OALMSG(OAL_ERROR, ( L"\r\nERROR: Flash erase for address 0x%08x failed\r\n", g_flashAddress )); goto cleanUp; } OALMSG(OAL_WARN, (L" Done\r\n")); rc = TRUE; cleanUp: OALMSG(OAL_FUNC, (L"-OEMFinishEraseFlash(rc = %d)\r\n", rc)); return rc; }
void PDD_SendRndisMessage(PDATA_WRAPPER pDataWrapper) { OALMSG(OAL_ETHER&&OAL_FUNC, (L"+RNDIS_USBFN_PDD_SendRndisMessage\r\n")); // // We don't do the actual sending here but queue it up... // We then trigger Interrupt endpoint to send interrupt to host which will in turn // use EP0 to GET_ENCAPSULATED_RESPONSE InsertTailList((&g_RndisKitlDev.listTxRndisMessageQueue), &(pDataWrapper->Link)); OALMSG(OAL_ETHER&&OAL_FUNC, ( L"+RNDIS_USBFN_PDD_SendRndisMessage: message queued.\r\n" )); // Interrupt (via interrupt endpoint) the host to GET_ENCAPSULATED_RESPONSE // g_EP3Transfer.dwCallerPermissions; g_EP3Transfer.dwFlags = USB_REQUEST_DEVICE_TO_HOST; g_EP3Transfer.pvBuffer = &g_InterruptData; // g_EP3Transfer.dwBufferPhysicalAddress; // not used g_EP3Transfer.cbBuffer = sizeof(g_InterruptData); g_EP3Transfer.cbTransferred = 0; g_EP3Transfer.dwUsbError = UFN_NOT_COMPLETE_ERROR; // Possible values are in usbfntypes.h g_EP3Transfer.pvPddData = NULL; g_EP3Transfer.pvPddTransferInfo = NULL; OALMSG(OAL_ETHER&&OAL_FUNC, ( L"+RNDIS_USBFN_PDD_SendRndisMessage: issuing interrupt...\r\n" )); g_pddInterface.pfnIssueTransfer( g_pddInterface.pvPddContext, 3, &g_EP3Transfer ); OALMSG(OAL_ETHER&&OAL_FUNC, (L"-RNDIS_USBFN_PDD_SendRndisMessage\r\n")); }
//////////////////////////////////////////////////////////////////////////////// // PDD_SendRndisPacket() // // Routine Description: // // This routine is called by MDD to send data to host via IN pipe. // PDD is guaranteed to have only one outstanding packet to send until // the packet is retured to MDD via MddSendRndisPacketComplete() // // Arguments: // // pDataWrapper :: structure holding data we need to send. // // Return Value: // // None. // void PDD_SendRndisPacket(PDATA_WRAPPER pDataWrapper) { OALMSG(OAL_ETHER&&OAL_FUNC, (L"+RNDIS_USBFN_PDD_SendRndisPacket\r\n")); OALMSG(OAL_ETHER&&OAL_FUNC, ( L"Got SendPacket Request [%d bytes]\r\n", pDataWrapper->dwDataSize )); if (g_RndisKitlDev.pTxDataWrapper != NULL) { // // BAD! // This should never happen!! // Return the packet immediately.. // OALMSG(OAL_ERROR, (L"****Multiple pending send rndis packet!!\r\n")); MddSendRndisPacketComplete(pDataWrapper); } // save the data wrapper pointer so we can return later it in TxComplete call g_RndisKitlDev.pTxDataWrapper = pDataWrapper; // g_EP2Transfer.dwCallerPermissions; g_EP2Transfer.dwFlags = USB_REQUEST_DEVICE_TO_HOST; g_EP2Transfer.pvBuffer = pDataWrapper->pucData; // g_EP2Transfer.dwBufferPhysicalAddress; // not used g_EP2Transfer.cbBuffer = pDataWrapper->dwDataSize; g_EP2Transfer.cbTransferred = 0; g_EP2Transfer.dwUsbError = UFN_NOT_COMPLETE_ERROR; // Possible values are in usbfntypes.h g_EP2Transfer.pvPddData = NULL; g_EP2Transfer.pvPddTransferInfo = NULL; g_EP2TransferState = TS_SENDING_PACKET; g_pddInterface.pfnIssueTransfer( g_pddInterface.pvPddContext, 2, &g_EP2Transfer ); OALMSG(OAL_ETHER&&OAL_FUNC, (L"-RNDIS_USBFN_PDD_SendRndisPacket\r\n")); }
// sets up a packet receive transfer on EP1 (BULK OUT) VOID SetupEP1Transfer() { // allocate data transfer for EP1 if (!g_pEP1DataWrapper) { g_pEP1DataWrapper = MDDAllocDataWrapper(); if (!g_pEP1DataWrapper) { OALMSG(OAL_ERROR, (L"No mem for RX DataWrapper\r\n")); return; } g_pEP1DataWrapper->pucData = MDDAllocMem(); if (!g_pEP1DataWrapper->pucData) { OALMSG(OAL_ERROR, (L"No mem for RX data\r\n")); MDDFreeDataWrapper(g_pEP1DataWrapper); return; } g_pEP1DataWrapper->dwDataSize = MAX_INCOMING_BUFFER; } // g_EP1Transfer.dwCallerPermissions; g_EP1Transfer.pvBuffer = g_pEP1DataWrapper->pucData; // g_EP1Transfer.dwBufferPhysicalAddress; // not used g_EP1Transfer.cbBuffer = g_pEP1DataWrapper->dwDataSize; g_EP1Transfer.cbTransferred = 0; g_EP1Transfer.dwUsbError = UFN_NOT_COMPLETE_ERROR; // Possible values are in usbfntypes.h g_EP1Transfer.pvPddData = NULL; g_EP1Transfer.pvPddTransferInfo = NULL; g_EP1Transfer.dwFlags = 0; g_pddInterface.pfnIssueTransfer( g_pddInterface.pvPddContext, 1, &g_EP1Transfer ); }
//------------------------------------------------------------------------------ BOOL InitSystemControl() { #if 0 OALMSG(OAL_ETHER&&OAL_FUNC, (L"+USBFN:: Initialize System Control\r\n")); { DWORD temp, mode; OMAP2420_SYSC1_REGS *pSysConRegs = OALPAtoUA(OMAP2420_SYSC1_REGS_PA); temp = INREG32(&pSysConRegs->ulCONTROL_DEVCONF); mode = USBX_TRX_MODE; // Clear USBT0WRIMODEI. This places the USB Controls in Unidirectional Mode temp &= 0xFF3FFFFF; // Set the Transceiver Interface Mode for USB Port 0 if ((mode == 0x01) || (mode == 0x02)) { // Change the mode to Bidirectional. temp |= 0x00800000; } // Make sure the USB Enable signal is being used as an Active-High signal temp &= 0xFFFEFFFF; // Make sure the USB module standby signal is not asserted temp &= 0xFFFF7FFF; OUTREG32(&pSysConRegs->ulCONTROL_DEVCONF, temp); } OALMSG(OAL_ETHER&&OAL_FUNC, (L"-USBFN:: Initialize System Control\r\n")); #endif return TRUE; }
BOOL InitClockController() { OALMSG(OAL_ETHER&&OAL_FUNC, (L"+USBFN:: Initialize USB Clock Mgr\r\n")); { OMAP2420_PRCM_REGS * pPRCMRegs = OALPAtoUA(OMAP2420_PRCM_REGS_PA); #if 0 // Disable the USB Interface clock CLRREG32(&pPRCMRegs->ulCM_ICLKEN2_CORE, 0x00000001); // Clear EN_USB #endif // Configure the USB Interface Clock Speed CLRREG32(&pPRCMRegs->ulCM_CLKSEL1_CORE, 0x0E000000); // Clear clk = L3_CLK/1 (boot mode only) SETREG32(&pPRCMRegs->ulCM_CLKSEL1_CORE, 0x08000000); // Set clk = L3_CLK/3 #if 0 // Ensure that the USB Interface clock remains active when the MPU enters Idle Mode. CLRREG32(&pPRCMRegs->ulCM_AUTOIDLE2_CORE, 0x00000001); // Clear AUTO_USB // Enable the USB Interface clock SETREG32(&pPRCMRegs->ulCM_ICLKEN2_CORE, 0x00000001); // Set EN_USB // Enable the USB Functional clock SETREG32(&pPRCMRegs->ulCM_FCLKEN2_CORE, 0x00000001); // Set EN_USB // Enable USB Wake-Up SETREG32(&pPRCMRegs->ulPM_WKEN2_CORE, 0x00000001); // Set EN_USB #endif } OALMSG(OAL_ETHER&&OAL_FUNC, (L"-USBFN:: Initialize USB Clock Mgr\r\n")); return TRUE; }
//------------------------------------------------------------------------------ // // Function: OALIoCtlHalInitRTC // // This function is called by WinCE OS to initialize the time after boot. // Input buffer contains SYSTEMTIME structure with default time value. // If hardware has persistent real time clock it will ignore this value // (or all call). // BOOL OALIoCtlHalInitRTC( UINT32 code, VOID *pInpBuffer, UINT32 inpSize, VOID *pOutBuffer, UINT32 outSize, UINT32 *pOutSize ) { BOOL rc = FALSE; SYSTEMTIME *pTime = (SYSTEMTIME*)pInpBuffer; OALMSG(OAL_IOCTL&&OAL_FUNC, (L"+OALIoCtlHalInitRTC(...)\r\n")); // Validate inputs if (pInpBuffer == NULL || inpSize < sizeof(SYSTEMTIME)) { NKSetLastError(ERROR_INVALID_PARAMETER); OALMSG(OAL_ERROR, ( L"ERROR: OALIoCtlHalInitRTC: Invalid parameter\r\n" )); goto cleanUp; } // Add static mapping for RTC alarm OALIntrStaticTranslate(SYSINTR_RTC_ALARM, IRQ_RTC); // Set time rc = OEMSetRealTime(pTime); cleanUp: OALMSG(OAL_IOCTL&&OAL_FUNC, (L"-OALIoCtlHalInitRTC(rc = %d)\r\n", rc)); return rc; }
//------------------------------------------------------------------------------ // // Function: OEMInterruptEnable // // This function enables the IRQ given its corresponding SysIntr value. // Function returns true if SysIntr is valid, else false. // BOOL OEMInterruptEnable(DWORD sysIntr, LPVOID pvData, DWORD cbData) { BOOL rc = FALSE; const UINT32 *pIrqs; UINT32 count; UNREFERENCED_PARAMETER(pvData); UNREFERENCED_PARAMETER(cbData); OALMSG(OAL_INTR&&OAL_VERBOSE,(L"+OEMInterruptEnable(%d, 0x%x, %d)\r\n", sysIntr, pvData, cbData)); // SYSINTR_VMINI & SYSINTR_TIMING are special cases if (sysIntr == SYSINTR_VMINI || sysIntr == SYSINTR_TIMING) { rc = TRUE; goto cleanUp; } // Obtain the SYSINTR's underlying IRQ number if (!OALIntrTranslateSysIntr(sysIntr, &count, &pIrqs)) { // Indicate invalid SysIntr OALMSG(OAL_ERROR, ( L"ERROR: OEMInterruptEnable: IRQs are undefined for SysIntr %d\r\n", sysIntr )); goto cleanUp; } // Enable the interrupt rc = OALIntrEnableIrqs(count, pIrqs); cleanUp: OALMSG(OAL_INTR&&OAL_VERBOSE, (L"-OEMInterruptEnable(rc = 1)\r\n")); return rc; }
//------------------------------------------------------------------------------ // // Function: OALIntrDisableIrq/BSPIntrDisableIrq // // This function disable interrupt identified by IRQ. If implementation uses // platform callbacks it will call BSPIntrDisableIrq before IRQ is disabled in // hardware. The BSPIntrEnableIrq returns IRQ used for interrupt controller // chaining if it is suitable to disable it. // VOID OALIntrDisableIrqs(UINT32 count, const UINT32 *pIrqs) { UINT32 irq, i; SH4_RTC_REGS *pRTCRegs = OALPAtoUA(SH4_REG_PA_RTC); OALMSG(OAL_INTR&&OAL_VERBOSE, (L"+OALIntrDisableIrqs(%d, 0x%08x)\r\n", count, pIrqs)); for(i = 0; i < count; i++) { #ifndef OAL_BSP_CALLBACKS irq = pIrqs[i]; #else irq = BSPIntrDisableIrq(pIrqs[i]); #endif if(irq == OAL_INTR_IRQ_UNDEFINED) continue; switch(irq) { case IRQ_RTC_ATI: OUTREG8(&pRTCRegs->RCR1, INREG8(&pRTCRegs->RCR1) & ~RTC_RCR1_AIE); OALMSG(OAL_INTR&&OAL_VERBOSE, (L"INFO: IRQ_RTC_ATI Disabled\r\n")); break; default: OALMSG(OAL_ERROR, (L"ERROR: Unable to disable IRQ %d\r\n", irq)); } } OALMSG(OAL_INTR&&OAL_VERBOSE, (L"-OALIntrDisableIrqs()\r\n")); }
//------------------------------------------------------------------------------ // // Function: OEMIsFlashAddr // // This function determines whether the address provided lies in a platform's // flash or RAM address range. // // EBOOT decision depends on download type. Download type is // set in OMEMultiBinNotify. // BOOL OEMIsFlashAddr( ULONG address ) { BOOL rc; UNREFERENCED_PARAMETER(address); OALMSG(OAL_FUNC, (L"+OEMIsFlashAddr(0x%08x)\r\n", address)); // Depending on download type switch (g_eboot.type) { case DOWNLOAD_TYPE_XLDR: case DOWNLOAD_TYPE_EBOOT: case DOWNLOAD_TYPE_LOGO: case DOWNLOAD_TYPE_FLASHNAND: case DOWNLOAD_TYPE_FLASHNOR: rc = TRUE; break; default: rc = FALSE; break; } OALMSG(OAL_FUNC, (L"-OEMIsFlashAddr(rc = %d)\r\n", rc)); return rc; }
VOID OEMProfileTimerDisable() { BOOL enabled; UINT32 irq; OALMSG(TRUE, (L"+OEMProfileTimerDisable()\r\n")); // No disable without enable if (!g_profiler.enabled) goto cleanUp; // Following code should not be interrupted enabled = INTERRUPTS_ENABLE(FALSE); // Disable the profile timer interrupt irq = IRQ_TIMER2; OALIntrDisableIrqs(1, &irq); // Deconfigure profiling ISR callback function. g_pProfilerISR = NULL; // Reset flag g_profiler.enabled = FALSE; // Enable interrupts INTERRUPTS_ENABLE(enabled); cleanUp: OALMSG(TRUE, (L"-OEMProfileTimerDisable\r\n")); }
BOOL OEMKitlStartup(void) { OAL_KITL_ARGS KITLArgs; OAL_KITL_ARGS *pKITLArgs; BOOL bRet = FALSE; UCHAR *szDeviceId,buffer[OAL_KITL_ID_SIZE]="\0"; OALMSG(OAL_KITL&&OAL_FUNC, (L"[KITL] ++OEMKitlStartup()\r\n")); // Look for bootargs left by the bootloader or left over from an earlier boot. // pKITLArgs = (OAL_KITL_ARGS *)OALArgsQuery(OAL_ARGS_QUERY_KITL); szDeviceId = (UCHAR*)OALArgsQuery(OAL_ARGS_QUERY_DEVID); // If no KITL arguments were found (typically provided by the bootloader), then select // some default settings. // if (pKITLArgs == NULL) { memset(&KITLArgs, 0, sizeof(OAL_KITL_ARGS)); // By default, enable KITL and use USB Serial KITLArgs.flags |= OAL_KITL_FLAGS_ENABLED; KITLArgs.devLoc.IfcType = Internal; KITLArgs.devLoc.BusNumber = 0; KITLArgs.devLoc.PhysicalLoc = (PVOID)S3C6410_BASE_REG_PA_USBOTG_LINK; KITLArgs.devLoc.LogicalLoc = (DWORD)KITLArgs.devLoc.PhysicalLoc; pKITLArgs = &KITLArgs; } if (pKITLArgs->devLoc.LogicalLoc == BSP_BASE_REG_PA_DM9000A_IOBASE) { // Ethernet specific initialization //configure chipselect for DM9000A InitSROMC_DM9000A(); //setting EINT7 as IRQ_LAN if (!(pKITLArgs->flags & OAL_KITL_FLAGS_POLL)) { g_pGPIOReg = (S3C6410_GPIO_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_GPIO, FALSE); } // Setup pointers to the power on and power off functions to enable KITL // functionality across suspend/resume // Modify the g_kitlEthCS8900A structure defined in kitl_cfg.h g_kitlEthDM9000A.pfnPowerOff = (OAL_KITLETH_POWER_OFF)BSPKitlEthPowerOff; g_kitlEthDM9000A.pfnPowerOn = (OAL_KITLETH_POWER_ON)BSPKitlEthPowerOn; } bRet = OALKitlInit ((LPCSTR)szDeviceId, pKITLArgs, g_kitlDevices); OALMSG(OAL_KITL&&OAL_FUNC, (L"[KITL] --OEMKitlStartup() = %d\r\n", bRet)); return bRet; }
//------------------------------------------------------------------------------ // // Function: OALIoCtlHalInitRTC // // This function is called by WinCE OS to initialize the time after boot. // Input buffer contains SYSTEMTIME structure with default time value. // If hardware has persistent real time clock it will ignore this value // (or all call). // BOOL OALIoCtlHalInitRTC( UINT32 code, VOID *pInpBuffer, UINT32 inpSize, VOID *pOutBuffer, UINT32 outSize, UINT32 *pOutSize) { BOOL rc = FALSE; BOOL bResetRTC = FALSE; SYSTEMTIME SysTime; OALMSG(OAL_IOCTL&&OAL_FUNC, (L"+OALIoCtlHalInitRTC(...)\r\n")); // Validate inputs if (pInpBuffer == NULL || inpSize < sizeof(SYSTEMTIME)) { NKSetLastError(ERROR_INVALID_PARAMETER); OALMSG(OAL_ERROR, ( L"ERROR: OALIoCtlHalInitRTC: Invalid parameter\r\n" )); goto cleanUp; } // Initialize critical section for RTC functions. InitializeCriticalSection(&g_oalRTCcs); g_oalRTCcsInit = 1; // Add static mapping for RTC alarm OALIntrStaticTranslate(SYSINTR_RTC_ALARM, IRQ_RTC_ALARM); OEMGetRealTime(&SysTime); /* RTC Time validity check */ bResetRTC = (SysTime.wYear < RTC_YEAR_DATUM || (SysTime.wYear - RTC_YEAR_DATUM) > 99) ? TRUE : bResetRTC; bResetRTC = (SysTime.wMonth > 12 || SysTime.wMonth < 1) ? TRUE : bResetRTC; bResetRTC = (SysTime.wDay > 31 || SysTime.wDay < 1) ? TRUE : bResetRTC; bResetRTC = (SysTime.wDayOfWeek > 6 || SysTime.wDayOfWeek < 0) ? TRUE : bResetRTC; bResetRTC = (SysTime.wHour > 23 || SysTime.wHour < 0) ? TRUE : bResetRTC; bResetRTC = (SysTime.wMinute > 59 || SysTime.wMinute < 0) ? TRUE : bResetRTC; bResetRTC = (SysTime.wSecond > 59 || SysTime.wSecond < 0) ? TRUE : bResetRTC; if(bResetRTC) { OALMSG(OAL_RTC&&OAL_ERROR,(L"Invalid RTC Time (%d.%d.%d, %d:%d:%d, (%d th day of week)\r\n", \ SysTime.wYear, SysTime.wMonth, SysTime.wDay, \ SysTime.wHour, SysTime.wMinute, SysTime.wSecond, \ SysTime.wDayOfWeek )); } // Set time if(bResetRTC) { rc = OEMSetRealTime(&g_oalRtcResetTime); } cleanUp: OALMSG(OAL_IOCTL&&OAL_FUNC, (L"-OALIoCtlHalInitRTC(rc = %d)\r\n", rc)); return rc; }
void main(void) { OEMInitDebugSerial(); OALMSG(TRUE,(TEXT("IPLmain\r\n"))); //InitializeDisplay(); OALMSG(OAL_ERROR, (TEXT("Start: IPLmain start \r\n"))); IPLmain(); }
//------------------------------------------------------------------------------ // // Function: OEMSetRealTime // // Updates the RTC with the specified system time. // BOOL OEMSetRealTime(LPSYSTEMTIME pTime) { BOOL rc = FALSE; volatile S3C6400_RTC_REG *pRTCReg; if (pTime == NULL) goto cleanUp; OALMSG(OAL_RTC&&OAL_FUNC, ( L"+OEMSetRealTime(%d/%d/%d %d:%d:%d.%03d)\r\n", pTime->wYear, pTime->wMonth, pTime->wDay, pTime->wHour, pTime->wMinute, pTime->wSecond, pTime->wMilliseconds)); OALMSG(TRUE, ( L"OEMSetRealTime(%d/%d/%d %d:%d:%d.%03d)\r\n", pTime->wYear, pTime->wMonth, pTime->wDay, pTime->wHour, pTime->wMinute, pTime->wSecond, pTime->wMilliseconds)); // The RTC will only support a BCD year value of 0 - 99. The year datum is // 1980, so any dates greater than 2079 will fail unless the datum is // adjusted. if ((pTime->wYear < RTC_YEAR_DATUM) || ((pTime->wYear - RTC_YEAR_DATUM) > 99)) { OALMSG(OAL_ERROR, (L"ERROR: OEMSetRealTime: " L"RTC cannot support a year greater than %d or less than %d " L"(value %d)\r\n", (RTC_YEAR_DATUM + 99), RTC_YEAR_DATUM, pTime->wYear)); goto cleanUp; } // Get uncached virtual address pRTCReg = (S3C6400_RTC_REG *)OALPAtoVA(S3C6400_BASE_REG_PA_RTC, FALSE); // Enable RTC control. pRTCReg->RTCCON |= (1<<0); pRTCReg->BCDSEC = TO_BCD(pTime->wSecond); pRTCReg->BCDMIN = TO_BCD(pTime->wMinute); pRTCReg->BCDHOUR = TO_BCD(pTime->wHour); pRTCReg->BCDDATE = TO_BCD(pTime->wDay); pRTCReg->BCDDAY = pTime->wDayOfWeek + 1; pRTCReg->BCDMON = TO_BCD(pTime->wMonth); pRTCReg->BCDYEAR = TO_BCD(pTime->wYear - RTC_YEAR_DATUM); // Disable RTC control. pRTCReg->RTCCON &= ~(1<<0); // Done rc = TRUE; cleanUp: OALMSG(OAL_RTC&&OAL_FUNC, (L"-OEMSetRealTime(rc = %d)\r\n", rc)); return rc; }
static UINT32 ReadFlashNK( ) { UINT32 rc = (UINT32)BL_ERROR; ROMHDR *pTOC; ULONG offset, size; UCHAR *pData; DWORD *pInfo; UCHAR *pBase = OALPAtoVA(g_ulFlashBase, FALSE); UCHAR *pStart = (void *)((UINT32)pBase + IMAGE_WINCE_NOR_OFFSET); OALMSG(OAL_INFO, (L"\r\nLoad NK image from flash memory\r\n")); // Set address where to place image pData = (UCHAR*)IMAGE_WINCE_CODE_CA; // First read 4kB with pointer to TOC offset = 0; size = 4096; memcpy(pData + offset, pStart, size); // Verify that we get CE image pInfo = (DWORD *)(pData + offset + ROM_SIGNATURE_OFFSET); if (*pInfo != ROM_SIGNATURE) { OALMSG(OAL_ERROR, (L"ERROR: Image signature not found\r\n")); goto cleanUp; } // Read image up through actual TOC offset = size; size = pInfo[2] - size + sizeof(ROMHDR); memcpy(pData + offset, pStart + offset, size); // Verify image if (!VerifyImage(pData, &pTOC)) { OALMSG(OAL_ERROR, (L"ERROR: NK image doesn't have ROM signature\r\n")); goto cleanUp; } // Read remainder of image offset += size; size = pTOC->physlast - pTOC->physfirst - offset; memcpy(pData + offset, pStart + offset, size); OALMSG(OAL_INFO, (L"NK Image Loaded\r\n")); // Done g_eboot.launchAddress = OALVAtoPA((UCHAR*)IMAGE_WINCE_CODE_CA); rc = BL_JUMP; cleanUp: return rc; }
//------------------------------------------------------------------------------ // // Function: OALIoCtlHalQueryDisplaySettings // // This function is called by GDI to query the kernel for information // about a preferred resolution for the system to use. // static BOOL OALIoCtlHalQueryDisplaySettings( UINT32 dwIoControlCode, VOID *lpInBuf, UINT32 nInBufSize, VOID *lpOutBuf, UINT32 nOutBufSize, UINT32* lpBytesReturned) { DWORD dwErr = 0; DWORD *displayType; DWORD *framebufferDepth; OALMSG(TRUE, (TEXT("++OALIoCtlHalQueryDisplaySettings()\r\n"))); displayType=(DWORD*) OALArgsQuery(BSP_ARGS_QUERY_DISPLAYTYPE); OALMSG(TRUE, (TEXT("++BSP_ARGS_QUERY_DISPLAYTYPE: %d\r\n"), *displayType)); framebufferDepth=(DWORD*) OALArgsQuery(BSP_ARGS_QUERY_FRAMEBUFFERDEPTH); OALMSG(TRUE, (TEXT("++BSP_ARGS_QUERY_FRAMEBUFFERDEPTH: %d\r\n"), *framebufferDepth)); if (lpBytesReturned) { *lpBytesReturned = 0; } if (lpOutBuf == NULL) { dwErr = 1; } else if ((sizeof(DWORD)*2) > nOutBufSize) { dwErr = 2; } else { // Check the boot arg structure for the default display settings. __try { ((PDWORD)lpOutBuf)[0] = (DWORD)(*displayType); ((PDWORD)lpOutBuf)[1] = (DWORD)(*framebufferDepth); if (lpBytesReturned) { *lpBytesReturned = sizeof (DWORD)*2; } } __except (EXCEPTION_EXECUTE_HANDLER) { dwErr = 3; } } if (dwErr) { OALMSG(OAL_ERROR, (TEXT("[OAL:ERR] OALIoCtlHalQueryDisplaySettings() Failed dwErr = %s\r\n"), (dwErr==1)?"outbuf is NULL":"size of outbuf is too small")); NKSetLastError(dwErr); } OALMSG(TRUE, (TEXT("++OALIoCtlHalQueryDisplaySettings()\r\n"))); return !dwErr; }
BOOL WriteFlashNK( UINT32 address, UINT32 size ) { BOOL rc = FALSE; UCHAR *pData; void *pBase = OALPAtoVA(g_ulFlashBase, FALSE); void *pStart = (void *)((UINT32)pBase + IMAGE_WINCE_NOR_OFFSET); OALLog(L"\r\nWriting NK image to flash memory\r\n"); // Get data location pData = OEMMapMemAddr(address, address); // Verify that we get CE image if (!VerifyImage(pData, NULL)) { OALMSG(OAL_ERROR, (L"ERROR: OEMWriteFlash: NK image signature not found\r\n")); goto cleanUp; } // Unlock blocks if (!OALFlashLock(pBase, pStart, size, FALSE)) { OALMSG(OAL_ERROR, (L"ERROR: OEMWriteFlash: NK blocks could not be unlocked\r\n")); goto cleanUp; } // Erase blocks if (!OALFlashErase(pBase, pStart, size)) { OALMSG(OAL_ERROR, (L"ERROR: OEMWriteFlash: NK blocks could not be erased\r\n")); goto cleanUp; } // Write blocks if (!OALFlashWrite(pBase, pStart, size, pData)) { OALMSG(OAL_ERROR, (L"ERROR: OEMWriteFlash: NK blocks could not be written\r\n")); goto cleanUp; } OALLog(L"NK image written\r\n"); // Change boot device to NOR g_bootCfg.bootDevLoc.IfcType = Internal; g_bootCfg.bootDevLoc.LogicalLoc = BSP_NOR_REGS_PA; // Done rc = TRUE; cleanUp: return rc; }
//------------------------------------------------------------------------------ // // Function: OEMInterruptDone // // OEMInterruptDone is called by the kernel when a device driver // calls InterruptDone(). The system is not preemtible when this // function is called. // VOID OEMInterruptDone(DWORD sysIntr) { OALMSG(OAL_INTR&&OAL_VERBOSE, (L"+OEMInterruptDone(%d)\r\n", sysIntr)); // Re-enable interrupts OALIntrDoneIrqs(1, &g_oalSysIntr2Irq[sysIntr]); OALMSG(OAL_INTR&&OAL_VERBOSE, (L"-OEMInterruptDone\r\n")); }
static void InitializeINFORMSFR(void) { volatile S3C6410_SYSCON_REG *pSysConReg = (S3C6410_SYSCON_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_SYSCON, FALSE); OALMSG(TRUE, (L"[OAL] ++InitializeINFORMSFR()\r\n")); pSysConReg->INFORM0 = 0x64100000; OALMSG(TRUE, (L"[OAL] --InitializeINFORMSFR()\r\n")); }
//------------------------------------------------------------------------------ // // Function: OEMInterruptDisable // // This function disables the IRQ given its corresponding SysIntr value. // VOID OEMInterruptDisable(DWORD SysIntr) { OALMSG(OAL_INTR&&OAL_VERBOSE, (L"+OEMInterruptDisable(%d)\r\n", SysIntr)); // Disable interrupts OALIntrDisableIrqs(1, &g_oalSysIntr2Irq[SysIntr]); OALMSG(OAL_INTR&&OAL_VERBOSE, (L"-OEMInterruptDisable\r\n")); }
//------------------------------------------------------------------------------ // // Function: OALArgsQuery // // This function is called from other OAL modules to return boot arguments. // Boot arguments are typically placed in fixed memory location and they are // filled by boot loader. In case that boot arguments can't be located // the function should return NULL. The OAL module then must use default // values. // VOID* OALArgsQuery(UINT32 type) { VOID *pData = NULL; BSP_ARGS *pArgs; OALMSG(OAL_ARGS&&OAL_FUNC, (L"+OALArgsQuery(%d)\r\n", type)); // Get pointer to expected boot args location pArgs = (BSP_ARGS*)IMAGE_SHARE_ARGS_UA_START; // Check if there is expected signature #ifdef OMNIBOOK_VER if ((pArgs->header.signature == OAL_ARGS_SIGNATURE) && (pArgs->header.oalVersion == OAL_ARGS_VERSION) && (pArgs->header.bspVersion == BSP_ARGS_VERSION)) #else //!OMNIBOOK_VER if ((pArgs->header.signature == OAL_ARGS_SIGNATURE) || (pArgs->header.oalVersion == OAL_ARGS_VERSION) || (pArgs->header.bspVersion == BSP_ARGS_VERSION)) #endif OMNIBOOK_VER { // Depending on required args switch (type) { case OAL_ARGS_QUERY_DEVID: pData = &pArgs->deviceId; break; case OAL_ARGS_QUERY_UUID: pData = &pArgs->uuid; break; case OAL_ARGS_QUERY_KITL: pData = &pArgs->kitl; break; case BSP_ARGS_QUERY_HIVECLEAN: pData = &pArgs->bHiveCleanFlag; break; case BSP_ARGS_QUERY_CLEANBOOT: pData = &pArgs->bCleanBootFlag; break; case BSP_ARGS_QUERY_FORMATPART: pData = &pArgs->bFormatPartFlag; break; default: break; } } else { OALMSG(TRUE, (TEXT("[OAL:ERR] Arguments area is invalid\r\n"))); } OALMSG(OAL_ARGS&&OAL_FUNC, (L"-OALArgsQuery(pData = 0x%08x)\r\n", pData)); return pData; }
//------------------------------------------------------------------------------ // // Function: OEMGetRealTime // // Reads the current RTC value and returns a system time. // BOOL OEMGetRealTime(SYSTEMTIME *pTime) { volatile S3C6410_RTC_REG *pRTCReg; UINT16 seconds; BOOL rc = FALSE; BOOL csEnter; /* can get called before IoctlHalInitRTC, if so then don't try to enter (uninitialized) cs (kernel should be single-proc, single-threaded here) */ if (g_oalRTCcsInit) { EnterCriticalSection(&g_oalRTCcs); csEnter = TRUE; } else csEnter = FALSE; OALMSG(OAL_RTC&&OAL_FUNC, (L"+OEMGetRealTime(pTime = 0x%x)\r\n", pTime)); if (pTime == NULL) goto cleanUp; // Get uncached virtual address pRTCReg = (S3C6410_RTC_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_RTC, FALSE); // Enable RTC control. pRTCReg->RTCCON |= (1<<0); do { seconds = FROM_BCD(pRTCReg->BCDSEC & 0x7f); pTime->wYear = FROM_BCD((pRTCReg->BCDYEAR & 0xff)) + RTC_YEAR_DATUM; pTime->wMonth = FROM_BCD(pRTCReg->BCDMON & 0x1f); pTime->wDay = FROM_BCD(pRTCReg->BCDDATE & 0x3f); pTime->wDayOfWeek = pRTCReg->BCDDAY - 1; pTime->wHour = FROM_BCD(pRTCReg->BCDHOUR & 0x3f); pTime->wMinute = FROM_BCD(pRTCReg->BCDMIN & 0x7f); pTime->wSecond = FROM_BCD(pRTCReg->BCDSEC & 0x7f); pTime->wMilliseconds= 0; } while (pTime->wSecond != seconds); // Disable RTC control. pRTCReg->RTCCON &= ~(1<<0); // Done rc = TRUE; cleanUp: OALMSG(OAL_RTC&&OAL_FUNC, (L"-OEMGetRealTime(rc = %d)\r\n", rc)); if (csEnter) LeaveCriticalSection(&g_oalRTCcs); return rc; }