+++ /dev/null
-/*++\r
-Copyright (c) 2006, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module name:\r
- start.c\r
-\r
-Abstract:\r
-\r
-Revision history:\r
- 2000-Feb-07 M(f)J Genesis.\r
---*/\r
-\r
-\r
-#include "Snp.h"\r
-\r
-EFI_STATUS\r
-pxe_start (\r
- SNP_DRIVER *snp\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- this routine calls undi to start the interface and changes the snp state!\r
-\r
-Arguments:\r
- snp - pointer to snp driver structure\r
-\r
-Returns:\r
-\r
---*/\r
-{\r
- PXE_CPB_START_30 *cpb;\r
- PXE_CPB_START_31 *cpb_31;\r
-\r
- cpb = snp->cpb;\r
- cpb_31 = snp->cpb;\r
- //\r
- // Initialize UNDI Start CDB for H/W UNDI\r
- //\r
- snp->cdb.OpCode = PXE_OPCODE_START;\r
- snp->cdb.OpFlags = PXE_OPFLAGS_NOT_USED;\r
- snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r
- snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;\r
- snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r
- snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;\r
- snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;\r
- snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r
- snp->cdb.IFnum = snp->if_num;\r
- snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r
-\r
- //\r
- // Make changes to H/W UNDI Start CDB if this is\r
- // a S/W UNDI.\r
- //\r
- if (snp->is_swundi) {\r
- if (snp->IsOldUndi) {\r
- snp->cdb.CPBsize = sizeof (PXE_CPB_START_30);\r
- snp->cdb.CPBaddr = (UINT64) (UINTN) cpb;\r
-\r
- cpb->Delay = (UINT64) &snp_undi32_callback_delay_30;\r
- cpb->Block = (UINT64) &snp_undi32_callback_block_30;\r
-\r
- //\r
- // Virtual == Physical. This can be set to zero.\r
- //\r
- cpb->Virt2Phys = (UINT64) &snp_undi32_callback_v2p_30;\r
- cpb->Mem_IO = (UINT64) &snp_undi32_callback_memio_30;\r
- } else {\r
- snp->cdb.CPBsize = sizeof (PXE_CPB_START_31);\r
- snp->cdb.CPBaddr = (UINT64) (UINTN) cpb_31;\r
-\r
- cpb_31->Delay = (UINT64) &snp_undi32_callback_delay;\r
- cpb_31->Block = (UINT64) &snp_undi32_callback_block;\r
-\r
- //\r
- // Virtual == Physical. This can be set to zero.\r
- //\r
- cpb_31->Virt2Phys = (UINT64) 0;\r
- cpb_31->Mem_IO = (UINT64) &snp_undi32_callback_memio;\r
-\r
- cpb_31->Map_Mem = (UINT64) &snp_undi32_callback_map;\r
- cpb_31->UnMap_Mem = (UINT64) &snp_undi32_callback_unmap;\r
- cpb_31->Sync_Mem = (UINT64) &snp_undi32_callback_sync;\r
-\r
- cpb_31->Unique_ID = (UINT64) (UINTN) snp;\r
- }\r
- }\r
- //\r
- // Issue UNDI command and check result.\r
- //\r
- DEBUG ((EFI_D_NET, "\nsnp->undi.start() "));\r
-\r
- (*snp->issue_undi32_command) ((UINT64) (UINTN) &snp->cdb);\r
-\r
- if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {\r
- //\r
- // UNDI could not be started. Return UNDI error.\r
- //\r
- DEBUG (\r
- (EFI_D_ERROR,\r
- "\nsnp->undi.start() %xh:%xh\n",\r
- snp->cdb.StatCode,\r
- snp->cdb.StatFlags)\r
- );\r
-\r
- return EFI_DEVICE_ERROR;\r
- }\r
- //\r
- // Set simple network state to Started and return success.\r
- //\r
- snp->mode.State = EfiSimpleNetworkStarted;\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-snp_undi32_start (\r
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- This is the SNP interface routine for starting the interface\r
- This routine basically retrieves snp structure, checks the SNP state and\r
- calls the pxe_start routine to actually do start undi interface\r
-\r
-Arguments:\r
- This - context pointer\r
-\r
-Returns:\r
- EFI_INVALID_PARAMETER - "This" is Null\r
- - No SNP driver can be extracted from "This"\r
- EFI_ALREADY_STARTED - The state of SNP is EfiSimpleNetworkStarted\r
- or EfiSimpleNetworkInitialized\r
- EFI_DEVICE_ERROR - The state of SNP is other than EfiSimpleNetworkStarted,\r
- EfiSimpleNetworkInitialized, and EfiSimpleNetworkStopped\r
- EFI_SUCCESS - UNDI interface is succesfully started\r
- Other - Error occurs while calling pxe_start function.\r
- \r
---*/\r
-{\r
- SNP_DRIVER *Snp;\r
- EFI_STATUS Status;\r
- UINTN Index;\r
-\r
- if (This == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
-\r
- if (Snp == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- switch (Snp->mode.State) {\r
- case EfiSimpleNetworkStopped:\r
- break;\r
-\r
- case EfiSimpleNetworkStarted:\r
- case EfiSimpleNetworkInitialized:\r
- return EFI_ALREADY_STARTED;\r
-\r
- default:\r
- return EFI_DEVICE_ERROR;\r
- }\r
-\r
- Status = pxe_start (Snp);\r
- if (Status != EFI_SUCCESS) {\r
- return Status;\r
- }\r
- //\r
- // clear the map_list in SNP structure\r
- //\r
- for (Index = 0; Index < MAX_MAP_LENGTH; Index++) {\r
- Snp->map_list[Index].virt = 0;\r
- Snp->map_list[Index].map_cookie = 0;\r
- }\r
-\r
- Snp->mode.MCastFilterCount = 0;\r
-\r
- return Status;\r
-}\r