void checkHeartbeat() { if (cyclesUntilReset>=0) cyclesUntilReset = cyclesUntilReset - 1; if (cyclesUntilReset==0) { cyclesUntilReset = -1; HardReset(); } }
nsresult nsSMILTimedElement::SetBeginOrEndSpec(const nsAString& aSpec, PRBool aIsBegin) { nsRefPtr<nsSMILTimeValueSpec> spec; SMILTimeValueSpecList& timeSpecsList = aIsBegin ? mBeginSpecs : mEndSpecs; nsTArray<nsSMILInstanceTime>& instancesList = aIsBegin ? mBeginInstances : mEndInstances; timeSpecsList.Clear(); instancesList.Clear(); HardReset(); // XXX Need to take care of time dependents here PRInt32 start; PRInt32 end = -1; PRInt32 length; do { start = end + 1; end = aSpec.FindChar(';', start); length = (end == -1) ? -1 : end - start; spec = NS_NewSMILTimeValueSpec(this, aIsBegin, Substring(aSpec, start, length)); if (spec) timeSpecsList.AppendElement(spec); } while (end != -1 && spec); if (!spec) { timeSpecsList.Clear(); instancesList.Clear(); HardReset(); return NS_ERROR_FAILURE; } UpdateCurrentInterval(); return NS_OK; }
static bool MessageDone() { // TODO: check pin capabilities switch (rx_msg.type) { case HARD_RESET: CHECK(rx_msg.args.hard_reset.magic == IOIO_MAGIC); HardReset(); break; case CHECK_INTERFACE: CheckInterface(rx_msg.args.check_interface.interface_id); break; case READ_FINGERPRINT: if (!ReadFingerprint()) { log_printf("Failed to read fingerprint"); return false; } break; case WRITE_FINGERPRINT: if (!WriteFingerprint(rx_msg.args.write_fingerprint.fingerprint)) { log_printf("Failed to write fingerprint"); return false; } break; case WRITE_IMAGE: rx_message_state = WAIT_FILE; rx_message_remaining = rx_msg.args.write_image.size; if (!EraseFingerprint()) { log_printf("Failed to erase fingerprint"); return false; } file_checksum = 0; log_printf("Starting to receive image file"); IOIOFileInit(); break; // BOOKMARK(add_feature): Add incoming message handling to switch clause. default: log_printf("Unexpected message type: 0x%x", rx_msg.type); return false; } return true; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->ui->b_disconnect->setEnabled(false); this->ui->b_send->setEnabled(false); this->ui->b_sendlast->setEnabled(false); this->ui->b_receive->setEnabled(false); this->ui->b_verify->setEnabled(false); this->stlink = new stlinkv2(); this->devices = new DeviceList(this); this->tfThread = new transferThread(); if (this->devices->IsLoaded()) { this->ui->gb_top->setEnabled(true); this->log(QString::number(this->devices->getDevicesCount())+" Device descriptions loaded."); QObject::connect(this->ui->b_quit,SIGNAL(clicked()),this,SLOT(Quit())); QObject::connect(this->ui->b_qt,SIGNAL(clicked()),qApp,SLOT(aboutQt())); QObject::connect(this->ui->b_connect, SIGNAL(clicked()), this, SLOT(Connect())); QObject::connect(this->ui->b_disconnect, SIGNAL(clicked()), this, SLOT(Disconnect())); QObject::connect(this->ui->b_send, SIGNAL(clicked()), this, SLOT(Send())); QObject::connect(this->ui->b_sendlast, SIGNAL(clicked()), this, SLOT(SendLast())); QObject::connect(this->ui->b_receive, SIGNAL(clicked()), this, SLOT(Receive())); QObject::connect(this->ui->b_verify, SIGNAL(clicked()), this, SLOT(Verify())); QObject::connect(this->ui->b_halt, SIGNAL(clicked()), this, SLOT(HaltMCU())); QObject::connect(this->ui->b_run, SIGNAL(clicked()), this, SLOT(RunMCU())); QObject::connect(this->ui->b_reset, SIGNAL(clicked()), this, SLOT(ResetMCU())); QObject::connect(this->ui->r_jtag, SIGNAL(clicked()), this, SLOT(setModeJTAG())); QObject::connect(this->ui->r_swd, SIGNAL(clicked()), this, SLOT(setModeSWD())); QObject::connect(this->ui->b_hardReset, SIGNAL(clicked()), this, SLOT(HardReset())); // Thread QObject::connect(this->tfThread, SIGNAL(sendProgress(quint32)), this, SLOT(updateProgress(quint32))); QObject::connect(this->tfThread, SIGNAL(sendStatus(QString)), this, SLOT(updateStatus(QString))); QObject::connect(this->tfThread, SIGNAL(sendLoaderStatus(QString)), this, SLOT(updateLoaderStatus(QString))); QObject::connect(this->stlink, SIGNAL(bufferPct(quint32)), this, SLOT(updateLoaderPct(quint32))); QObject::connect(this->tfThread, SIGNAL(sendLock(bool)), this, SLOT(lockUI(bool))); QObject::connect(this->ui->b_stop, SIGNAL(clicked()), this->tfThread, SLOT(halt())); QObject::connect(this->tfThread, SIGNAL(sendLog(QString)), this, SLOT(log(QString))); // Help QObject::connect(this->ui->b_help, SIGNAL(clicked()), this, SLOT(showHelp())); }
static BOOL MessageDone() { // TODO: check pin capabilities switch (rx_msg.type) { case HARD_RESET: CHECK(rx_msg.args.hard_reset.magic == IOIO_MAGIC); HardReset(); break; case SOFT_RESET: SoftReset(); Echo(); break; case SET_PIN_DIGITAL_OUT: CHECK(rx_msg.args.set_pin_digital_out.pin < NUM_PINS); SetPinDigitalOut(rx_msg.args.set_pin_digital_out.pin, rx_msg.args.set_pin_digital_out.value, rx_msg.args.set_pin_digital_out.open_drain); break; case SET_DIGITAL_OUT_LEVEL: CHECK(rx_msg.args.set_digital_out_level.pin < NUM_PINS); SetDigitalOutLevel(rx_msg.args.set_digital_out_level.pin, rx_msg.args.set_digital_out_level.value); break; case SET_PIN_DIGITAL_IN: CHECK(rx_msg.args.set_pin_digital_in.pin < NUM_PINS); CHECK(rx_msg.args.set_pin_digital_in.pull < 3); SetPinDigitalIn(rx_msg.args.set_pin_digital_in.pin, rx_msg.args.set_pin_digital_in.pull); break; case SET_CHANGE_NOTIFY: CHECK(rx_msg.args.set_change_notify.pin < NUM_PINS); if (rx_msg.args.set_change_notify.cn) { Echo(); } SetChangeNotify(rx_msg.args.set_change_notify.pin, rx_msg.args.set_change_notify.cn); if (!rx_msg.args.set_change_notify.cn) { Echo(); } break; case SET_PIN_PWM: CHECK(rx_msg.args.set_pin_pwm.pin < NUM_PINS); CHECK(rx_msg.args.set_pin_pwm.pwm_num < NUM_PWM_MODULES); SetPinPwm(rx_msg.args.set_pin_pwm.pin, rx_msg.args.set_pin_pwm.pwm_num, rx_msg.args.set_pin_pwm.enable); break; case SET_PWM_DUTY_CYCLE: CHECK(rx_msg.args.set_pwm_duty_cycle.pwm_num < NUM_PWM_MODULES); SetPwmDutyCycle(rx_msg.args.set_pwm_duty_cycle.pwm_num, rx_msg.args.set_pwm_duty_cycle.dc, rx_msg.args.set_pwm_duty_cycle.fraction); break; case SET_PWM_PERIOD: CHECK(rx_msg.args.set_pwm_period.pwm_num < NUM_PWM_MODULES); SetPwmPeriod(rx_msg.args.set_pwm_period.pwm_num, rx_msg.args.set_pwm_period.period, rx_msg.args.set_pwm_period.scale_l | (rx_msg.args.set_pwm_period.scale_h) << 1); break; case SET_PIN_ANALOG_IN: CHECK(rx_msg.args.set_pin_analog_in.pin < NUM_PINS); SetPinAnalogIn(rx_msg.args.set_pin_analog_in.pin); break; case UART_DATA: CHECK(rx_msg.args.uart_data.uart_num < NUM_UART_MODULES); UARTTransmit(rx_msg.args.uart_data.uart_num, rx_msg.args.uart_data.data, rx_msg.args.uart_data.size + 1); break; case UART_CONFIG: CHECK(rx_msg.args.uart_config.uart_num < NUM_UART_MODULES); CHECK(rx_msg.args.uart_config.parity < 3); UARTConfig(rx_msg.args.uart_config.uart_num, rx_msg.args.uart_config.rate, rx_msg.args.uart_config.speed4x, rx_msg.args.uart_config.two_stop_bits, rx_msg.args.uart_config.parity); break; case SET_PIN_UART: CHECK(rx_msg.args.set_pin_uart.pin < NUM_PINS); CHECK(rx_msg.args.set_pin_uart.uart_num < NUM_UART_MODULES); SetPinUart(rx_msg.args.set_pin_uart.pin, rx_msg.args.set_pin_uart.uart_num, rx_msg.args.set_pin_uart.dir, rx_msg.args.set_pin_uart.enable); break; case SPI_MASTER_REQUEST: CHECK(rx_msg.args.spi_master_request.spi_num < NUM_SPI_MODULES); CHECK(rx_msg.args.spi_master_request.ss_pin < NUM_PINS); { const BYTE total_size = rx_msg.args.spi_master_request.total_size + 1; const BYTE data_size = rx_msg.args.spi_master_request.data_size_neq_total ? rx_msg.args.spi_master_request.data_size : total_size; const BYTE res_size = rx_msg.args.spi_master_request.res_size_neq_total ? rx_msg.args.spi_master_request.vararg[ rx_msg.args.spi_master_request.data_size_neq_total] : total_size; const BYTE* const data = &rx_msg.args.spi_master_request.vararg[ rx_msg.args.spi_master_request.data_size_neq_total + rx_msg.args.spi_master_request.res_size_neq_total]; SPITransmit(rx_msg.args.spi_master_request.spi_num, rx_msg.args.spi_master_request.ss_pin, data, data_size, total_size, total_size - res_size); } break; case SPI_CONFIGURE_MASTER: CHECK(rx_msg.args.spi_configure_master.spi_num < NUM_SPI_MODULES); SPIConfigMaster(rx_msg.args.spi_configure_master.spi_num, rx_msg.args.spi_configure_master.scale, rx_msg.args.spi_configure_master.div, rx_msg.args.spi_configure_master.smp_end, rx_msg.args.spi_configure_master.clk_edge, rx_msg.args.spi_configure_master.clk_pol); break; case SET_PIN_SPI: CHECK(rx_msg.args.set_pin_spi.mode < 3); CHECK((!rx_msg.args.set_pin_spi.enable && rx_msg.args.set_pin_spi.mode == 1) || rx_msg.args.set_pin_spi.pin < NUM_PINS); CHECK((!rx_msg.args.set_pin_spi.enable && rx_msg.args.set_pin_spi.mode != 1) || rx_msg.args.set_pin_spi.spi_num < NUM_SPI_MODULES); SetPinSpi(rx_msg.args.set_pin_spi.pin, rx_msg.args.set_pin_spi.spi_num, rx_msg.args.set_pin_spi.mode, rx_msg.args.set_pin_spi.enable); break; case I2C_CONFIGURE_MASTER: CHECK(rx_msg.args.i2c_configure_master.i2c_num < NUM_I2C_MODULES); I2CConfigMaster(rx_msg.args.i2c_configure_master.i2c_num, rx_msg.args.i2c_configure_master.rate, rx_msg.args.i2c_configure_master.smbus_levels); break; case I2C_WRITE_READ: CHECK(rx_msg.args.i2c_write_read.i2c_num < NUM_I2C_MODULES); { unsigned int addr; if (rx_msg.args.i2c_write_read.ten_bit_addr) { addr = rx_msg.args.i2c_write_read.addr_lsb; addr = addr << 8 | ((rx_msg.args.i2c_write_read.addr_msb << 1) | 0b11110000); } else { CHECK(rx_msg.args.i2c_write_read.addr_msb == 0 && rx_msg.args.i2c_write_read.addr_lsb >> 7 == 0 && rx_msg.args.i2c_write_read.addr_lsb >> 2 != 0b0011110); addr = rx_msg.args.i2c_write_read.addr_lsb << 1; } I2CWriteRead(rx_msg.args.i2c_write_read.i2c_num, addr, rx_msg.args.i2c_write_read.data, rx_msg.args.i2c_write_read.write_size, rx_msg.args.i2c_write_read.read_size); } break; case SET_ANALOG_IN_SAMPLING: CHECK(rx_msg.args.set_analog_pin_sampling.pin < NUM_PINS); ADCSetScan(rx_msg.args.set_analog_pin_sampling.pin, rx_msg.args.set_analog_pin_sampling.enable); break; case CHECK_INTERFACE: CheckInterface(rx_msg.args.check_interface.interface_id); break; case ICSP_SIX: ICSPSix(rx_msg.args.icsp_six.inst); break; case ICSP_REGOUT: ICSPRegout(); break; case ICSP_PROG_ENTER: ICSPEnter(); break; case ICSP_PROG_EXIT: ICSPExit(); break; case ICSP_CONFIG: if (rx_msg.args.icsp_config.enable) { Echo(); } ICSPConfigure(rx_msg.args.icsp_config.enable); if (!rx_msg.args.icsp_config.enable) { Echo(); } break; case INCAP_CONFIG: CHECK(rx_msg.args.incap_config.incap_num < NUM_INCAP_MODULES); CHECK(!rx_msg.args.incap_config.double_prec || 0 == (rx_msg.args.incap_config.incap_num & 0x01)); CHECK(rx_msg.args.incap_config.mode < 6); CHECK(rx_msg.args.incap_config.clock < 4); InCapConfig(rx_msg.args.incap_config.incap_num, rx_msg.args.incap_config.double_prec, rx_msg.args.incap_config.mode, rx_msg.args.incap_config.clock); break; case SET_PIN_INCAP: CHECK(rx_msg.args.set_pin_incap.incap_num < NUM_INCAP_MODULES); CHECK(!rx_msg.args.set_pin_incap.enable || rx_msg.args.set_pin_incap.pin < NUM_PINS); SetPinInCap(rx_msg.args.set_pin_incap.pin, rx_msg.args.set_pin_incap.incap_num, rx_msg.args.set_pin_incap.enable); break; case SOFT_CLOSE: log_printf("Soft close requested"); Echo(); state = STATE_CLOSING; break; case SET_PIN_PULSECOUNTER: CHECK(rx_msg.args.set_pin_pulsecounter.pin < NUM_PINS); CHECK(rx_msg.args.set_pin_pulsecounter.mode < 4); CHECK(rx_msg.args.set_pin_pulsecounter.rateord < 9); CHECK(rx_msg.args.set_pin_pulsecounter.stepsord < 4); SetPinPulseCounter(rx_msg.args.set_pin_pulsecounter.pin, rx_msg.args.set_pin_pulsecounter.enable, rx_msg.args.set_pin_pulsecounter.mode, rx_msg.args.set_pin_pulsecounter.rateord, rx_msg.args.set_pin_pulsecounter.stepsord); break; // BOOKMARK(add_feature): Add incoming message handling to switch clause. // Call Echo() if the message is to be echoed back. default: return FALSE; } return TRUE; }
/************************************ * Main program * ************************************/ int32_t main() { int32_t quit = 0,i, correct,number; char buf[257]; char *langs[]={ "US\0","DE\0","SE\0","FR\0","IT\0", }; /* Read UAE configuration */ i = GetUaeConfig( &config ); while( quit == 0 ) { printf(" UAE-Control v0.1\n\n"); printf(" 1) Reset\n"); printf(" 2) Debug\n"); printf(" 3) Exit Emulator\n"); printf(" 4) Change framerate (Currently : %ld)\n", config.framerate); printf(" 5) Toggle sound (Currently : %s)\n", config.do_output_sound ? "ON" : "OFF"); printf(" 6) Toggle fake joystick (Currently : %s)\n", config.do_fake_joystick ? "ON" : "OFF"); printf(" 7) Change language (Currently : %s)\n", langs[config.keyboard]); printf(" 8) Eject a disk\n"); printf(" 9) Insert a disk\n"); printf("10) Exit UAE-Control\n\n"); correct = 0; while( correct == 0 ) { printf(" Command : "); gets( buf ); i = atoi( buf ); if ((i > 0) && (i < 11)) correct = 1; } switch( i ) { case 1: HardReset(); break; case 2: DebugFunc(); break; case 3: ExitEmu(); break; case 4: printf(" Enter new framerate (1-20) :"); gets( buf ); number = atoi( buf ); if (SetFrameRate (number)) GetUaeConfig(&config); else printf(" Illegal value, not changed.\n"); break; case 5: if (config.do_output_sound) DisableSound(); else EnableSound(); GetUaeConfig( &config ); break; case 6: if (config.do_fake_joystick) DisableJoystick(); else EnableJoystick(); GetUaeConfig( &config ); break; case 7: printf(" 1 = US, 2 = DE, 3 = SE, 4 = FR, 5 = IT\n"); printf(" What will it be : "); gets( buf ); number = atoi( buf ); if ((number >= 1) && (number <= 5)) { ChangeLanguage( number-1 ); GetUaeConfig( &config ); } else { printf(" Illegal value, not changed.\n"); } break; case 8: print_drive_status(); printf(" Eject which drive (1-4): "); gets( buf ); number = atoi( buf ); if ((number >= 1) && (number <=4 )) { EjectDisk( number-1 ); GetUaeConfig( &config ); } else { printf(" Illegal drive, not changed.\n"); } break; case 9: print_drive_status(); printf(" Enter disk to drive (1-4): "); gets( buf ); number = atoi( buf ); if ((number >= 1) && (number <= 4)) { printf("Name of diskfile :"); gets( buf ); InsertDisk( (UBYTE *)&buf, number - 1 ); GetUaeConfig( &config ); } else { printf(" Illegal drive, not changed.\n"); } break; case 10: quit = 1; break; } } quit_program(0, ""); return(0); }
/* Function Name : LPC3xxx_MiniportInitialize Description : Called by the NDIS Wrapper to initialize the adapter. 0. Verify the Adapter v/s the driver 1. Create and initilize the adapter structure 2. Read and load the registry settings 3. Initialize the chip 4. Establish the link Parameters : PNDIS_STATUS OpenErrorStatus - Additional error status, if return value is error PUINT MediumIndex - specifies the medium type the driver or its network adapter uses PNDIS_MEDIUM MediumArray - Specifies an array of NdisMediumXXX values from which MiniportInitialize selects one that its network adapter supports or that the driver supports as an interface to higher-level drivers. UINT MediumArraySize - Specifies the number of elements at MediumArray NDIS_HANDLE AdapterHandle - Specifies a handle identifying the miniport’s network adapter, which is assigned by the NDIS library NDIS_HANDLE ConfigurationContext - Specifies a handle used only during initialization for calls to NdisXXX configuration and initialization functions Return Value : NDIS_STATUS Status */ NDIS_STATUS LPC3xxx_MiniportInitialize( PNDIS_STATUS pOpenErrorStatus, PUINT pMediumIndex, PNDIS_MEDIUM pMediumArray, UINT nMediumArraySize, NDIS_HANDLE hAdapterHandle, NDIS_HANDLE hConfigurationContext) { NDIS_STATUS Status = NDIS_STATUS_SUCCESS; UINT nArrayIndex; PMINIPORT_ADAPTER pAdapter; PHYSICAL_ADDRESS pa; DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS ==> MiniportInitialize\r\n"))); //Check for the supported 802.3 media for(nArrayIndex = 0; nArrayIndex < nMediumArraySize; nArrayIndex++) { if(NdisMedium802_3 == pMediumArray[nArrayIndex]) break; } if(nArrayIndex == nMediumArraySize) { DEBUGMSG(ZONE_INIT | ZONE_ERROR, (TEXT("LPC3xxx NDIS : ERROR - No Supported Media types \r\n"))); DEBUGMSG(ZONE_INIT | ZONE_ERROR, (TEXT("LPC3xxx NDIS <== MiniportInitialize \r\n"))); return(NDIS_STATUS_UNSUPPORTED_MEDIA); } *pMediumIndex = nArrayIndex; //Allocate memory for the adapter structure Status = NdisAllocateMemory((PVOID *) &pAdapter, MINIPORT_ADAPTER_SIZE, 0, HighestAcceptedMax); if(Status != NDIS_STATUS_SUCCESS) { DEBUGMSG(ZONE_INIT | ZONE_ERROR, (TEXT("LPC3xxx NDIS: ERROR - No Memory for Adapter Structure!\r\n"))); DEBUGMSG(ZONE_INIT | ZONE_ERROR, (TEXT("LPC3xxx NDIS <== MiniPort Initialize\r\n"))); return(NDIS_STATUS_RESOURCES); } NdisZeroMemory(pAdapter, MINIPORT_ADAPTER_SIZE); //Clean it up //Set up the default values pAdapter->hAdapter = hAdapterHandle; pAdapter->eState = INITIALIZING_STATE; pAdapter->IsInterruptSet = FALSE; pAdapter->IsPortRegistered = FALSE; pAdapter->dwIRQNumber = -1; pAdapter->bMediaConnected = FALSE; pAdapter->bAutoNeg = TRUE; // Autoneg per default (overriden by registry settings) pAdapter->bFullDuplex = TRUE; // Full duplex per default pAdapter->b100Mbps = TRUE; // 100 Mbps per default pAdapter->bRMII = TRUE; // RMII interface per default //Setup Receive control Register pAdapter->bPerfectMatch = TRUE; // We want to receive the frames for this station pAdapter->bPromiscuous = FALSE; // Not in Promescuous mode per default pAdapter->bRxBroadcast = TRUE; // We do forward the broadcasted frames (DHCP required at least) pAdapter->bRxMulticastHash = TRUE; // We forward matched multicast frames pAdapter->bRxMulticastAll = FALSE; // We do not forward all multicast frames pAdapter->bRxUnicastHash = TRUE; // We do not forward matched unicast frames pAdapter->bRxUnicastAll = TRUE; // We do not forward all unicast frames pAdapter->dwBufferPhyAddr = 0; pAdapter->dwTxStrides = 0; pAdapter->dwRxStrides = 0; pAdapter->dwControllerAddress = 0; pAdapter->pEMACRegs = NULL; pAdapter->dwEMACBuffersSize = 0; pAdapter->pPATXDesc = 0; pAdapter->pPARXDesc = 0; pAdapter->pPATXBuffer = 0; pAdapter->pPARXBuffer = 0; pAdapter->pPATXStatus = 0; pAdapter->pPARXStatus = 0; pAdapter->pVAEMACBuffers= NULL; pAdapter->pVATXDesc = NULL; pAdapter->pVARXDesc = NULL; pAdapter->pVATXStatus = NULL; pAdapter->pVARXStatus = NULL; //Allocate memory for the LookAhead buffer pAdapter->dwLookAheadBufferSize = MAX_FRAME_SIZE; Status = NdisAllocateMemory((PVOID *) &pAdapter->pVALookAheadBuffer, pAdapter->dwLookAheadBufferSize, 0, HighestAcceptedMax); if(Status != NDIS_STATUS_SUCCESS) { DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS: ERROR - No Memory for LookAhead buffer!\r\n"))); DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS <== MiniPort Initialize\r\n"))); BackOut(pAdapter); return(NDIS_STATUS_RESOURCES); } NdisZeroMemory(pAdapter->pVALookAheadBuffer, pAdapter->dwLookAheadBufferSize); //Clean it up pAdapter->MACAddress[0] = 0x02; pAdapter->MACAddress[1] = 0x03; pAdapter->MACAddress[2] = 0x04; pAdapter->MACAddress[3] = 0x06; pAdapter->MACAddress[4] = 0x06; pAdapter->MACAddress[5] = 0x08; //Get the adapter information from the registry Status = GetRegistrySettings(pAdapter, hConfigurationContext); if(Status != NDIS_STATUS_SUCCESS) { DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS: ERROR - Configure Adapter failed!\r\n"))); DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS <== MiniPort Initialize\r\n"))); BackOut(pAdapter); return(NDIS_STATUS_FAILURE); } // Allocate the memory for Buffers // Computing required space pAdapter->dwEMACBuffersSize = pAdapter->dwRxStrides * ( sizeof(LPCS_ETH_DESC) + sizeof(LPCS_ETH_RX_STATUS) + MAX_FRAME_SIZE) + pAdapter->dwTxStrides * ( sizeof(LPCS_ETH_DESC) + sizeof(LPCS_ETH_TX_STATUS) + MAX_FRAME_SIZE); // Allocating space pAdapter->pVAEMACBuffers = MapRegisters (pAdapter->dwBufferPhyAddr, pAdapter->dwEMACBuffersSize); if(pAdapter->pVAEMACBuffers == NULL) { RETAILMSG(1, (TEXT("LPC3xxx NDIS:ERROR : Can't Allocate Buffer!\r\n"))); BackOut(pAdapter); DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS:<== MiniPort Initialize FAILED !!\r\n"))); return(NDIS_STATUS_RESOURCES); } DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS:Allocated DMA Buffers Successfully!\r\n"))); // Splitting allocated buffers into smaller areas // Physical Addresses pAdapter->pPARXDesc = pAdapter->dwBufferPhyAddr; pAdapter->pPARXStatus = pAdapter->pPARXDesc + pAdapter->dwRxStrides * sizeof(LPCS_ETH_DESC); pAdapter->pPATXDesc = pAdapter->pPARXStatus + pAdapter->dwRxStrides * sizeof(LPCS_ETH_RX_STATUS); pAdapter->pPATXStatus = pAdapter->pPATXDesc + pAdapter->dwTxStrides * sizeof(LPCS_ETH_DESC); pAdapter->pPARXBuffer = pAdapter->pPATXStatus + pAdapter->dwTxStrides * sizeof(LPCS_ETH_TX_STATUS); pAdapter->pPATXBuffer = pAdapter->pPARXBuffer + pAdapter->dwRxStrides * MAX_FRAME_SIZE; // Virtual Addresses pAdapter->pVARXDesc = pAdapter->pVAEMACBuffers; pAdapter->pVARXStatus = (PVOID)((DWORD)pAdapter->pVARXDesc + pAdapter->dwRxStrides * sizeof(LPCS_ETH_DESC)); pAdapter->pVATXDesc = (PVOID)((DWORD)pAdapter->pVARXStatus + pAdapter->dwRxStrides * sizeof(LPCS_ETH_RX_STATUS)); pAdapter->pVATXStatus = (PVOID)((DWORD)pAdapter->pVATXDesc + pAdapter->dwTxStrides * sizeof(LPCS_ETH_DESC)); pAdapter->pVARXBuffer = (PVOID)((DWORD)pAdapter->pVATXStatus + pAdapter->dwTxStrides * sizeof(LPCS_ETH_TX_STATUS)); pAdapter->pVATXBuffer = (PVOID)((DWORD)pAdapter->pVARXBuffer + pAdapter->dwRxStrides * MAX_FRAME_SIZE); // Allocating the TX Packet buffer Status = NdisAllocateMemory((PVOID *) &pAdapter->pTXPackets, sizeof(TX_PACKET) * pAdapter->dwTxStrides, 0, HighestAcceptedMax); if(Status != NDIS_STATUS_SUCCESS) { DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS: ERROR - No Memory for TXBuffers buffer!\r\n"))); DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS <== MiniPort Initialize\r\n"))); BackOut(pAdapter); return(NDIS_STATUS_RESOURCES); } NdisZeroMemory(pAdapter->pTXPackets, sizeof(TX_PACKET) * pAdapter->dwTxStrides); //Clean it up //Register the interrupt NdisMSetAttributes(pAdapter->hAdapter, (NDIS_HANDLE) pAdapter, TRUE, NdisInterfaceInternal); Status = NdisMRegisterInterrupt(&pAdapter->InterruptInfo, pAdapter->hAdapter, pAdapter->dwIRQNumber, 0, TRUE, FALSE, NdisInterruptLatched); if(Status != NDIS_STATUS_SUCCESS) { DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS : ERROR - Can't Attach to Interrupt!\r\n"))); BackOut(pAdapter); DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS:<== MiniPort Initialize\r\n"))); return(Status); } else DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS: Interrupt Registered !!! \r\n"))); pAdapter->IsInterruptSet = TRUE; //Register the IOBase address. Modify this code according to the platform Status = NdisMRegisterIoPortRange((PVOID *) &(pAdapter->pEMACRegs), pAdapter->hAdapter, pAdapter->dwControllerAddress, sizeof(ETHERNET_REGS_T)); if(Status != NDIS_STATUS_SUCCESS) { RETAILMSG(1, (TEXT("LAN91C9111 : ERROR - Can't Register I/O Port Range!\r\n"))); DEBUGMSG(ZONE_INIT, (TEXT("LAN91C9111 <== MiniPort Initialize\r\n"))); BackOut(pAdapter); return(NDIS_STATUS_RESOURCES); } pAdapter->IsPortRegistered = TRUE; //EnablePeriphClock(ETHERNET); pa.QuadPart = CLK_PM_BASE; n_pCLKPWRRegs = (CLKPWR_REGS_T *) MmMapIoSpace(pa, sizeof (CLKPWR_REGS_T), FALSE); if (n_pCLKPWRRegs == NULL) { RETAILMSG(1, (_T("LCD: lpc32xx_hw_init: Critcal error: cannot map registers!\r\n"))); MmUnmapIoSpace(n_pCLKPWRRegs, sizeof(CLKPWR_REGS_T)); return; } n_pCLKPWRRegs->clkpwr_macclk_ctrl = CLKPWR_MACCTRL_HRCCLK_EN| CLKPWR_MACCTRL_MMIOCLK_EN| CLKPWR_MACCTRL_DMACLK_EN| CLKPWR_MACCTRL_USE_RMII_PINS; // // Initialize Tx and Rx DMA Descriptors //DEBUGMSG(ZONE_INIT, (L"LPC_EthInit: Initializing Descriptor engine\r\n")); //EMAC_InitEngine(pAdapter); if(!HardReset(pAdapter)) { return NDIS_STATUS_FAILURE; } DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS <== MiniportInitialize \r\n"))); //Ready return NDIS_STATUS_SUCCESS; }