Compartilhar via


Implementing the OEMPlatformInit Function

Windows Mobile Not SupportedWindows Embedded CE Supported

9/8/2008

Após inicializar o CPU e núcleo lógica em processo de desenvolvimento o carregador inicializar, você pode foco em Inicializar placa-nível hardware Implementando o OEMPlatformInit função.

O OEMPlatformInit função inicializa placa-nível hardware quando necessário so that codificar adicionado posteriormente pode baixar sobre o controlador Ethernet. Essa função é altamente hardware-dependente plataforma.

A seguinte lista mostra as tarefas que o OEMPlatformInit função precisa executar:

  • Inicializar o relógio em tempo real (RTC) ou qualquer outro dispositivo timekeeping usado pelo OEMEthGetSecs função. Para esta tarefa, uma segunda resolução é aceitável.

  • Inicializar memória flash memória, ou um memória flash controlador memória na maiúsculas e minúsculas de NAND memória flash memória.

  • Se o dispositivo rede residir em um barramento PCI, inicializar a hospedar ponte PCI, enumerar os barramentos para localizar o controlador rede a ser usado para downloads e apenas configurar o hardware PCI exigido para habilitar o controlador rede para operar, that is, o controlador rede próprio e qualquer intermediário lógica ponte.
    Driver de barramento PCI deve configurar o restante do barramento PCI sob a OS. Para obter mais informações sobre o driver barramento PCI, consulte Driver de barramento PCI.

  • Se o dispositivo rede residir em um barramento PCMCIA, inicializar a ponte PCMCIA ou controlador.

  • Inicialize o controlador rede a ser usado para baixar a imagem carregador inicializar de máquina de hospedar.
    Microsoft fornece um número de bibliotecas estáticas para vários controladores rede que podem ser usados para inicializar e se comunicar com o controlador.
    Se a plataforma hardware tem um interno controlador rede, ou seja, um Soldado para a placa-mãe, em seguida, OEMPlatformInit pode ser simplificada para assumir que um controlador será usado.
    Se a plataforma hardware oferecer suporte a expansão barramentos, de exemplo, PCMCIA ou PCI, a implementação para OEMPlatformInit Pode ser necessário permitir para uma variedade de rede controladores para ser conectado.
    Porque a exportar bibliotecas Controlador Ethernet um comum interface, você pode usar ponteiros função para selecionar entre um número de bibliotecas controlador para o hardware específico não sendo usado. Você pode usar esses ponteiros função em todo o carregador inicializar no local do real rede controlador biblioteca chamar.
    O seguinte exemplo de código mostra como você pode usar ponteiros função:

    // Function pointers to the support library functions of the currently 
    // installed debug Ethernet controller.
    //
    PFN_EDBG_INIT             pfnEDbgInit;
    PFN_EDBG_INIT_DMABUFFER   pfnEDbgInitDMABuffer;
    PFN_EDBG_GET_FRAME        pfnEDbgGetFrame;
    PFN_EDBG_SEND_FRAME       pfnEDbgSendFrame;
    
    ...
        while(!bFoundCard) {
            // RNDIS has its own PCI scan routine.
            // 
            dwAddress =pBootArgs->dwEdbgBaseAddr;
            cIrq = pBootArgs->ucEdbgIRQ;
            cAdaptType=pBootArgs->ucEdbgAdapterType;
            if (!SelectPCINetCard(&dwAddress,&cIrq,&cAdaptType)) { // Cannot found a card match
                break;
            }
    
            // Set up EDBG driver callbacks based on Ethernet controller type.
            //
            bFoundCard=TRUE;
            switch (cAdaptType)
            {
            case EDBG_ADAPTER_NE2000:
                pfnEDbgInit           = NE2000Init;
                pfnEDbgInitDMABuffer  = NULL;
                pfnEDbgGetFrame       = NE2000GetFrame;       
                pfnEDbgSendFrame      = NE2000SendFrame;      
                break;
    
            case EDBG_ADAPTER_DP83815:
                pfnEDbgInit           = DP83815Init;
                pfnEDbgInitDMABuffer  = DP83815InitDMABuffer;
                pfnEDbgGetFrame       = DP83815GetFrame;
                pfnEDbgSendFrame      = DP83815SendFrame;
                break;
    
            case EDBG_ADAPTER_RTL8139:
                pfnEDbgInit           = RTL8139Init;
                pfnEDbgInitDMABuffer  = RTL8139InitDMABuffer;
                pfnEDbgGetFrame       = RTL8139GetFrame;       
                pfnEDbgSendFrame      = RTL8139SendFrame;      
                break;
    
            case EDBG_ADAPTER_3C90X:
                pfnEDbgInit           = D3C90XInit;
                pfnEDbgInitDMABuffer  = D3C90XInitDMABuffer;
                pfnEDbgGetFrame       = D3C90XGetFrame;       
                pfnEDbgSendFrame      = D3C90XSendFrame;      
                break;
    
            case EDBG_USB_RNDIS:
                pfnEDbgInit           = HostMiniInit;
                pfnEDbgInitDMABuffer  = NULL;
                pfnEDbgGetFrame       = RndisEDbgGetFrame;
                pfnEDbgSendFrame      = RndisEDbgSendFrame;
                dwAddress=0; // This forces RNDIS to scan the PCI bus.
                break ;
    
            default:
                UnsportedNicCardType(cAdaptType);
                EdbgOutputDebugString("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\r\n");
                EdbgOutputDebugString("-------------------------------------------------\r\n");
                EdbgOutputDebugString(" ERROR: Unsupported Ethernet adapter type (%u).\r\n", pBootArgs->ucEdbgAdapterType);
                EdbgOutputDebugString("-------------------------------------------------\r\n");
                EdbgOutputDebugString("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n");
                bFoundCard=FALSE;
                break;
            }
        };
        if (bFoundCard) {
             pBootArgs->dwEdbgBaseAddr=dwAddress;
             pBootArgs->ucEdbgIRQ=cIrq;
             pBootArgs->ucEdbgAdapterType=cAdaptType;
        }
        else 
        if (pBootArgs->dwEdbgBaseAddr && pBootArgs->ucEdbgIRQ) {
            pfnEDbgInit           = NE2000Init;
            pfnEDbgInitDMABuffer  = NULL;
            pfnEDbgGetFrame       = NE2000GetFrame;       
            pfnEDbgSendFrame      = NE2000SendFrame;      
            bFoundCard=TRUE;
            // Default to ISA or configure NE2000 Card.
        }
        else {
            EdbgOutputDebugString("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\r\n");
            EdbgOutputDebugString("-------------------------------------------------\r\n");
            EdbgOutputDebugString(" ERROR: Unsupported Ethernet adapter type (%u).\r\n", pBootArgs->ucEdbgAdapterType);
            EdbgOutputDebugString("-------------------------------------------------\r\n");
            EdbgOutputDebugString("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n");
            SpinForever();
        }
        // Initialize NIC DMA buffer, if required.
        //
        if (pfnEDbgInitDMABuffer)
        {
            if (!pfnEDbgInitDMABuffer(ETHDMA_BUFFER_BASE, ETHDMA_BUFFER_SIZE))
            {
                EdbgOutputDebugString("ERROR: Failed to initialize Ethernet controller DMA buffer.\r\n");
                return FALSE;
            }
        }
    
        // Call driver-specific initialization.
        //
        if (!pfnEDbgInit( (BYTE *) pBootArgs->dwEdbgBaseAddr, 1, MyAddr.wMAC)) {
            EdbgOutputDebugString("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\r\n");
            EdbgOutputDebugString("---------------------------------------------\r\n");
            EdbgOutputDebugString(" Failed to initialize Ethernet board!\r\n");
            EdbgOutputDebugString(" Please check that the Ethernet card is\r\n");
            EdbgOutputDebugString(" properly installed and configured.\r\n");
            EdbgOutputDebugString("---------------------------------------------\r\n");
            EdbgOutputDebugString("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n");
            return FALSE;
        }
    ...
    
  • Inicializar os argumentos inicializar, args inicializar, área da memória e, em seguida, preencher a região com informações que serão usadas pela OS.
    Esta reserva memória compartilhada será atualizada em todo o carregador inicializar para transportar informações such as dispositivo de rede usado para baixar, incluindo endereço de base, interrupção, IP endereço, sub-rede máscara, endereço MAC e outras configurações sistema ou usuário.

Para implementar a função OEMPlatformInit

  • Para editar o arquivo Main.c, adicionando a codificar necessário para implementar totalmente a versão do stubbed a OEMPlatformInit função em Main.c.

    O seguinte exemplo de código mostra a implementação das OEMPlatformInit função de plataforma de hardware usada nesse exemplo desenvolvimento carregador inicializar.

    BOOL OEMPlatformInit(void)
    {
        BOOL                    fRet            = FALSE;
        BOOT_ARGS              *pBootArgs;                  // OEM-defined
        ETH_HARDWARE_SETTINGS  *pEdbgSettings;              // OEM-defined
        EDBG_ADDR              *pMyAddr;
    
    
        EdbgOutputDebugString("Microsoft Windows Embedded CE Ethernet Bootloader %d.%d for Platform Example (%s %s)\n\n",
                              EBOOT_VERSION_MAJOR,EBOOT_VERSION_MINOR, __DATE__, __TIME__);
    
    
        //------------------------------------------------------------------
        // Initialize the arguments passed from boot loader to kernel.
        // At a minimum, this will include the debug ethernet settings (which 
        // are loaded from flash, specified by the user, and/or discovered at 
        // runtime).
        //
        // The boot args are part of the driver globals region of RAM.  
        // This region is reserved in the .bib file.
        //------------------------------------------------------------------
    
        pBootArgs = (BOOT_ARGS*)BOOT_ARGS_PHYSICAL_MEMORY_START;
        memset(pBootArgs, 0, sizeof(BOOT_ARGS));
    
        pBootArgs->dwSig            = BOOTARG_SIG;
        pBootArgs->dwLen            = sizeof(BOOT_ARGS);
        pBootArgs->dwEdbgDebugZone  = EdbgDebugZone;
    
    
        //------------------------------------------------------------------
        // Allow user to interrupt the loader to alter settings.
        //
        // After a few seconds WaitForKeyPress should return FALSE,
        // letting the loader continue unattended.
        //------------------------------------------------------------------
    
        if (WaitForKeyPress())
        {
            //
            // Using the debug serial functions you implemented,
            // display a configuration menu to the user.
            // Let the user toggle DHCP, set a static IP address, and so on.
            //
            LoaderMainMenu();     
        }
    
    
        //------------------------------------------------------------------
        // Initialize the ethernet controller, save configuration in 
        // boot args for kernel.
        //------------------------------------------------------------------
    
        pEdbgSettings = &pBootArgs->Edbg;
        fRet          = InitEthernet(pEdbgSettings);
    
        if (!fRet) {
            EdbgOutputDebugString("ERROR: Ethernet initialization failed\r\n");
    
            SpinForever();
    
        }
    
    
        pMyAddr = &pEdbgSettings->Adapter.Addr;
        EdbgOutputDebugString("INFO: Debug Ethernet MAC Address: %B:%B:%B:%B:%B:%B\r\n",
                              pMyAddr->wMAC[0] & 0x00FF, pMyAddr->wMAC[0] >> 8,
                              pMyAddr->wMAC[1] & 0x00FF, pMyAddr->wMAC[1] >> 8,
                              pMyAddr->wMAC[2] & 0x00FF, pMyAddr->wMAC[2] >> 8);
    
        return(TRUE);
    }
    

See Also

Tasks

How to Develop a Boot Loader

Concepts

Eboot Code Library