Keyboard* CreateKeyboard() { Keyboard* keyb; keyb = (Keyboard*) malloc(sizeof(Keyboard)); InitKeyboard(keyb); return keyb; }
void kmain( void* mdb,u32i magic ) { if( magic != 0x2BADB002 ) { while(1); } InitDescriptorTables(); VideoInit(); SetColor(BLACK,BRIGHT_WHITE); KPrintf("This is Atomic Kernel 12715A\n"); KPrintf("Starting Timer..."); InitTimer(100); KPrintf("Done.\n"); KPrintf("Starting Keyboard..."); InitKeyboard(); KPrintf("Done.\n"); KPrintf("Starting Paging..."); InitialisePaging(); KPrintf("Done.\n"); KPrintf("Starting Heap..."); HeapInit(); KPrintf("Done.\n"); u32i *A,*B,*C; A = Kmalloc(8); B = Kmalloc(8); KPrintf("A:%x,B:%x",A,B); KFree(A); KFree(B); C = Kmalloc(16); KPrintf("C:%x\n",C); while(1); }
void Input::Startup(HWND hWnd) { m_pDIObject = NULL; m_pDIKeyboardDevice = NULL; m_pDIMouseDevice = NULL; //Clears the buffer before use ZeroMemory(&KeyBuffer, 256); bool result = false; result = InitDirectInput(); if(!result) { MessageBox (NULL, "InitDirectInput Failed", "ERROR", MB_OK); } result = false; result = InitKeyboard(hWnd); if(!result) { MessageBox (NULL, "InitKeyboard Failed", "ERROR", MB_OK); } result = false; result = InitMouse(hWnd); if(!result) { MessageBox (NULL, "InitMouse Failed", "Error", MB_OK); } }
// Initialize Direct input object bool DXInput::Init() { // Create Direct Input object HRESULT hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&m_pDIObject, NULL) ; if (FAILED(hr)) { DXTRACE_ERR_MSGBOX(DXGetErrorString(hr), hr) ; //ERRORBOX(L"Create Direct Input object failed!") ; return false ; } // Initialize keyboard else if (!InitKeyboard()) { //ERRORBOX(L"Initialize keyboard failed!") ; DXTRACE_ERR_MSGBOX(DXGetErrorString(hr), hr) ; } // Initialize mouse else if (!InitMouse()) { //ERRORBOX(L"Initialize mouse failed!") ; DXTRACE_ERR_MSGBOX(DXGetErrorString(hr), hr) ; } return true ; }
/* Init: * Initialise l'émulateur et réserve les ressources nécessaires. */ int to7_Init(int disk_ctrl) { /* on détecte les instances multiples */ if (to7_alive) return ErrorMessage(TO7_MULTIPLE_INIT, NULL); if (InitHardware(disk_ctrl) == TO7_ERROR) return TO7_ERROR; if (InitMemory() == TO7_ERROR) { to7_Exit(); return TO7_ERROR; } InitKeyboard(); InitMouse(); InitDisk(); InitK7(); to7_alive = TRUE; atexit(to7_Exit); return TO7_OK; }
bool Input::Init(HWND windowHandle) { if (!m_directInput) { HINSTANCE instanceHandle = GetModuleHandle(nullptr); if (FAILED(DirectInput8Create(instanceHandle, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&m_directInput, nullptr))) { MessageBox(NULL, L"DirectInput8Create Fail", L"Error", MB_OK | MB_ICONERROR); return false; } } if (m_windowHandle != windowHandle) { m_windowHandle = windowHandle; if (!InitKeyboard()) return false; if (!InitMouse()) return false; } return true; }
int main( void ) { unsigned char key; //инициализация USART`a UBRRH = 0; UBRRL = 51; //скорость обмена 9600 бод при Fcpu = 8MГц UCSRB = (1<<TXEN); // разр передачи. UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0); //размер слова 8 разрядов //инициализация таймера Т0 TIMSK = (1<<TOIE0); //разрешение прерывания по переполнению TCCR0 = (1<<CS02)|(0<<CS01)|(0<<CS00); //предделитель 256 TCNT0 = 0x83; //прерывания каждые 4 мс //инициализация портов и переменных InitKeyboard(); __enable_interrupt(); while(1){ //если зафиксировано нажатие, //отправить код кнопки в терминал key = GetKey(); if (key) USART_SendChar(key); } return 0; }
/** * Function: InputKeyboard::InputKeyboard(...) * Description: InputKeyboard constructor * @ param hWnd: * Pointer to windowHandle, used to set the "SetCooperativeLevel" */ InputKeyboard::InputKeyboard( HWND argHwnd ) { dInput = NULL; dDevice = NULL; hwnd = argHwnd; InitKeyboard(); }
MikanLiteInput::MikanLiteInput( void ) { mouse.point.x = 0; mouse.point.y = 0; mouse.buf[ 0 ] = mouse.buf[ 1 ] = mouse.buf[ 2 ] = false; mouse.frame[ 0 ] = mouse.frame[ 1 ] = mouse.frame[ 2 ] = 0; InitKeyboard(); }
void CComponentInputKeyboard::Init(CInputDevice* pcDevice, CComponentInput* pcComponentInput) { CInputVirtualDevice* pcVirtual; pcVirtual = pcDevice->CreateDefaultVirtualDeviceFromThis("Text Editor Input"); InitDevice(pcVirtual, pcDevice, pcComponentInput); InitKeyboard(pcComponentInput->GetInput()); pcVirtual->Enable(); }
InputHandler::InputHandler(HWND handleWindow) { handle = handleWindow; m_pDIObject = NULL; m_pDIKeyboardDevice = NULL; InitDirectInput(); InitKeyboard(); InitMouse(); }
extern "C" void DisplayInit(void) { DisplaySetup(); StartDisplay(); #ifndef __PC__ DisplayHwSetup(); #endif OS_CREATETASK(&TCBDisplayMainTask, "Display Main Task", DisplayMainTask, DISPLAY_MAIN_TASK_PRIO, DisplayTaskStack); #ifndef __PC__ InitKeyboard(); #endif }
CInput::CInput(HWND hWnd, HINSTANCE hInst) { m_input = NULL; m_keyboardDevice = NULL; // Init keyboard if(!InitKeyboard(hWnd,hInst)) { MessageBox(hWnd,"Cannot initialize keyboard device","Error",MB_OK | MB_ICONERROR); } // Init mouse if(!InitMouse(hWnd,hInst)) { MessageBox(hWnd,"Cannot initialize mouse device","Error",MB_OK | MB_ICONERROR); } }
static void DoCheatSeq(void) { #if defined(DOS) || defined(SDL) || defined(FLASH) SilenceSound(1); #endif KillKeyboard(); KillVideo(); DoConsoleCheatConfig(); InitVideo(CurGame); InitKeyboard(); #if defined(DOS) || defined(SDL) || defined(FLASH) SilenceSound(0); #endif }
//--- void xmain(int argc, char *argv[]) { vc_initBuiltins(); vc_initLibrary(); InitGarlick(); Handle::init(); strcpy(mapname,""); LoadConfig(); if (argc == 2) { if (strlen(argv[1]) > 254) err("Mapname argument too long!"); strcpy(mapname, argv[1]); } InitVideo(); mouse_Init(); InitKeyboard(); joy_Init(); InitScriptEngine(); gameWindow->setTitle(APPNAME); if (sound) snd_Init(soundengine); win_movie_init(); ResetSprites(); timer_Init(gamerate); LUA *lua; se = lua = new LUA(); #ifdef ALLOW_SCRIPT_COMPILATION DisplayCompileImage(); lua->compileSystem(); CompileMaps("lua", lua); #endif se->ExecAutoexec(); while (true && strlen(mapname)) Engine_Start(mapname); err(""); }
//=============================================== //DirectInputの初期化 //=============================================== //[input] // なし //[return] // hr:結果 //=============================================== HRESULT CInput::CreateDevice() { HRESULT hr; /*デバイスの生成*/ hr = DirectInput8Create(Joker::GetHInst(), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&m_pDirectInput, NULL); if(FAILED(hr) ) { return hr; } InitKeyboard(); InitJoystick(); return S_OK; }
HRESULT CInput::InitDirectInput(const CInputConsoleSection_InitInput& initCommand) { HRESULT hr = 0; /* m_hInputLock = CreateEvent( NULL, FALSE, FALSE, NULL ); if (!m_hInputLock) { return E_FAIL; }*/ m_hMouseInput = CreateEvent( NULL, FALSE, FALSE, NULL ); if (!m_hMouseInput) { return E_FAIL; } m_hKeyboardInput = CreateEvent( NULL, FALSE, FALSE, NULL ); if (!m_hKeyboardInput) { return E_FAIL; } m_hJoystickInput = CreateEvent( NULL, FALSE, FALSE, NULL ); if (!m_hJoystickInput) { return E_FAIL; } hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&m_pDI, NULL ) ; if (initCommand.bNeedMouse) if (FAILED(hr=InitMouse(initCommand.hWnd))) return hr; if (initCommand.bNeedKeyboard) if (FAILED(hr=InitKeyboard(initCommand.hWnd))) return hr; m_hWnd = initCommand.hWnd; return hr; }
/** @brief Init OS after load. * @param NULL * @return NULL */ void OS_Init(void) { BOOTINFO* info; int32 screenWidth, screenHeight; uint8* bgBuf, *resVram; boolean re[2]; uint32 tmpAddr; InitPeripheralBuffer(); init_gdtidt(); init_pic(); io_sti(); // 恢复中断 tim_init(); io_out8(PIC0_IMR, 0xf8); /* PIT和PIC1和键盘设置为许可(11111000) */ io_out8(PIC1_IMR, 0xef); /* 鼠标设置为许可(11101111) */ info = (BOOTINFO*) ADR_BOOTINFO; screenHeight = info->screenHeight; screenWidth = info->screenWidth; init_palette(); mem_init(); fat_init(); re[0] = mem_alloc(768 * 1024, &tmpAddr); resVram = (uint8*)tmpAddr; sheet_init(resVram); InitMouse(); InitKeyboard(); re[1] = mem_alloc(768 * 1024, &tmpAddr); bgBuf = (uint8*)tmpAddr; //screenWidth * screenHeight sheet_add(bgBuf, screenWidth, screenHeight, 0, 0, NONE_COL, &bgSheet); fill_box(bgSheet, DARKGRASS, 0, 0, info->screenWidth, info->screenHeight); if(re[0] == FALSE || re[1] == FALSE) { fill_box(bgSheet, RED, 0, 0, info->screenWidth, info->screenHeight); } }
//============================================================================= // 入力処理の初期化 //============================================================================= HRESULT InitInput(HINSTANCE hInst, HWND hWnd) { HRESULT hr; if(!g_pDInput) { // DirectInputオブジェクトの作成 hr = DirectInput8Create(hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&g_pDInput, NULL); } // キーボードの初期化 InitKeyboard(hInst, hWnd); // マウスの初期化 InitMouse(hInst, hWnd); return hr; }
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // Name : 入力処理の初期化 // Description : 入力処理全般を初期化する // Arguments : hInst / インスタンス // hWnd / ウィンドウハンドル // Returns : 成否 //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ HRESULT CInput::InitInput(HINSTANCE hInst, HWND hWnd) { // ----- DirectInputオブジェクトの作成 if(FAILED(DirectInput8Create(hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&m_pDInput, NULL))) return E_FAIL; // ----- キーボードの初期化 if(FAILED(InitKeyboard(hWnd))) return E_FAIL; // ----- マウスの初期化 if(FAILED(InitMouse(hWnd))) return E_FAIL; // ----- ゲームパッドの初期化 //if(FAILED(InitJoypad(hWnd))) // return E_FAIL; return S_OK; }
int maemo_x11_update_keys() { XEvent evt; XClientMessageEvent *xce; int leave = 0; Display *disp = (Display *)gpuDisp; if (!disp) return 0; if (!initialized) { initialized++; InitKeyboard(); } while (XPending(disp)>0) { XNextEvent(disp, &evt); switch (evt.type) { case KeyPress: case KeyRelease: key_press_event(evt.xkey.keycode, evt.type==KeyPress ? 1 : (evt.type==KeyRelease ? 2 : 0) ); break; case ClientMessage: xce = (XClientMessageEvent *)&evt; if (xce->message_type == wmprotocols && (Atom)xce->data.l[0] == wmdelwindow) leave = 1; break; } } if (leave) { DestroyKeyboard(); exit(1); } return 0; }
long PADopen(unsigned long *Disp) { g.Disp = (Display *)*Disp; if (!g.Opened) { if (SDL_WasInit(SDL_INIT_EVERYTHING)) { if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) { return PSE_PAD_ERR_FAILURE; } } else if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) == -1) { return PSE_PAD_ERR_FAILURE; } #if SDL_VERSION_ATLEAST(1,3,0) has_haptic = 0; if (SDL_InitSubSystem(SDL_INIT_HAPTIC) == 0) has_haptic = 1; #endif InitSDLJoy(); InitKeyboard(); g.KeyLeftOver = 0; if (g.cfg.Threaded) { TerminateThread = 0; if (pthread_create(&ThreadID, NULL, JoyThread, NULL) != 0) { // thread creation failed, fallback to polling g.cfg.Threaded = 0; } } } g.Opened = 1; return PSE_PAD_ERR_SUCCESS; }
///Initialises DirectInput. ///hDlg: The window handler for which the input is initialised. void DirectXInputHandler::InitInput(Window* w) { _window = w; _hDlg = w->GetHWND(); //Gives the window the focus so it can find the input devices. HWND WINAPI SetFocus(_hDlg); // Register with the DirectInput subsystem and get a pointer // to a IDirectInput interface we can use. if( FAILED( DirectInput8Create( GetModuleHandle( NULL ), DIRECTINPUT_VERSION, IID_IDirectInput8, ( VOID** )&_g_pDI, NULL ) ) ) { return; } //Initialises the different devices InitMouse(); InitKeyboard(); //TODO: Implement InitXBoxController(); //Writes an info message to the log. _logger->WriteLog("DirectInput initialised.", Logger::MessageType::Info); }
bool Input::Init (bool fFirstInit_/*=false*/) { bool fRet = false; Exit(true); TRACE("Input::Init(%d)\n", fFirstInit_); // If we can find DirectInput 5.0 we can have joystick support, otherwise fall back on 3.0 support for NT4 if (fRet = SUCCEEDED(pfnDirectInputCreate(__hinstance, DIRECTINPUT_VERSION, &pdi, NULL))) InitJoysticks(); else fRet = SUCCEEDED(pfnDirectInputCreate(__hinstance, 0x0300, &pdi, NULL)); if (fRet) { hkl = GetKeyboardLayout(0); InitKeyboard(); Keyboard::Init(); fMouseActive = false; } return fRet; }
VOID KeyboardInitialize ( IN OUT PDRIVER_LOOKUP_ENTRY LookupTableEntry, IN ULONG Entries ) /*++ Routine Description: This routine initializes the keyboard control registers, clears the fifo, and initializes the keyboard entry in the driver lookup table. Arguments: LookupTableEntry - Supplies a pointer to the first free location in the driver lookup table. Entries - Supplies the number of free entries in the driver lookup table. Return Value: None. --*/ { UCHAR Byte; // // Initialize the driver lookup table. // LookupTableEntry->DevicePath = FW_KEYBOARD_IN_DEVICE_PATH; LookupTableEntry->DispatchTable = &KeyboardEntryTable; // // Initialize static data. // FwLeftShift = FALSE; FwRightShift = FALSE; FwControl = FALSE; FwAlt = FALSE; FwCapsLock = FALSE; KbdBuffer.ReadIndex = KbdBuffer.WriteIndex = 0; // // Call the selftest keyboard initialization routine. If the keyboard // is OK, enable interrupts. // if (!InitKeyboard()) { // // Enable kbd interrupts in the keyboard controller. // SendKbdCommand(KBD_CTR_READ_COMMAND); GetKbdData(&Byte,100); // // Clear translation mode and enable Kbd interrupt. // Byte = (Byte & 0xBF) | KbdCommandEnableKbdInt; SendKbdCommand(KBD_CTR_WRITE_COMMAND); SendKbdData(Byte); #ifndef ALPHA // // Not needed for Alpha. // // // Enable keyboard interrupts in the interrupt enable register. // WRITE_PORT_USHORT(&((PINTERRUPT_REGISTERS)INTERRUPT_VIRTUAL_BASE)->Enable, (1 << (KEYBOARD_VECTOR - DEVICE_VECTORS - 1))); #endif } return; }
/** Perform 8042 controller and keyboard initialization which implement SIMPLE_TEXT_IN.Reset() @param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL @param ExtendedVerification Indicate that the driver may perform a more exhaustive verification operation of the device during reset, now this par is ignored in this driver **/ EFI_STATUS EFIAPI KeyboardEfiReset ( IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, IN BOOLEAN ExtendedVerification ) { EFI_STATUS Status; KEYBOARD_CONSOLE_IN_DEV *ConsoleIn; EFI_TPL OldTpl; ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This); if (ConsoleIn->KeyboardErr) { return EFI_DEVICE_ERROR; } REPORT_STATUS_CODE_WITH_DEVICE_PATH ( EFI_PROGRESS_CODE, EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_RESET, ConsoleIn->DevicePath ); // // Enter critical section // OldTpl = gBS->RaiseTPL (TPL_NOTIFY); // // Call InitKeyboard to initialize the keyboard // Status = InitKeyboard (ConsoleIn, ExtendedVerification); if (EFI_ERROR (Status)) { // // Leave critical section and return // gBS->RestoreTPL (OldTpl); return EFI_DEVICE_ERROR; } // // Clear the status of ConsoleIn.Key // ConsoleIn->Key.ScanCode = SCAN_NULL; ConsoleIn->Key.UnicodeChar = 0x0000; // // Leave critical section and return // gBS->RestoreTPL (OldTpl); // // Report the status If a stuck key was detected // if (KeyReadStatusRegister (ConsoleIn) & 0x01) { REPORT_STATUS_CODE_WITH_DEVICE_PATH ( EFI_ERROR_CODE | EFI_ERROR_MINOR, EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_EC_STUCK_KEY, ConsoleIn->DevicePath ); } // // Report the status If keyboard is locked // if ((KeyReadStatusRegister (ConsoleIn) & 0x10) == 0) { REPORT_STATUS_CODE_WITH_DEVICE_PATH ( EFI_ERROR_CODE | EFI_ERROR_MINOR, EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_EC_LOCKED, ConsoleIn->DevicePath ); } return EFI_SUCCESS; }
VOID FwEntry( IN ULONG Cause, IN PFW_PROCESSOR_INFORMATION ProcessorInfo, IN PFW_SYSTEM_INFORMATION SystemInfo ) /*++ Routine Description: This routine is the c routine called from the ROM. It must be placed at the beginning of the C code because the ROM copies the code from this point to the end and then jumps to it. This has a different calling interface than the Jazz code. Arguments: Cause 0 on a normal reset/powerup. 1 on a softreset. ProcessorInfo Pointer to processor information block. Valid only if Cause = 0. SystemInfo Pointer to system information block. Valid only if Cause = 0. Return Value: Never returns. --*/ { #if 0 // Diagnostic bits turned off in final product. CHAR Diag; #endif FwRtlStackPanic = 0; // Register exception handler with the firmware PALcode RegisterExceptionHandler(); // Reset EISA memory buffer list. EISABufferListPointer = 0; // Clear out upper EISA address bits. WRITE_PORT_UCHAR((PUCHAR)HAE, 0x0); // Announce that the NT firmware has gotten control of the horizontal. PutLedDisplay(LED_NT_BOOT_START); // We cannot rely on the static C initialization of this if we are // doing a soft-reset. FwConsoleInitialized = FALSE; // // Deposit Alpha AXP architectural values into global variables if // this is a hard reset. // if (Cause == 0) { ProcessorId = ProcessorInfo->ProcessorId; ProcessorRevision = ProcessorInfo->ProcessorRevision; ProcessorPageSize = ProcessorInfo->PageSize; NumberOfPhysicalAddressBits = ProcessorInfo->PhysicalAddressBits; MaximumAddressSpaceNumber = ProcessorInfo->MaximumAddressSpaceNumber; SystemRevisionId = SystemInfo->SystemRevisionId; switch (SystemInfo->SystemCycleClockPeriod) { // // A bad cycle clock period would cause a system hang. // case 0: case 8000: default: ProcessorCycleCounterPeriod = 8000; break; // // This is an AX04 SROM bug: the number for a 6.667ns machine is // passed in as 6600, not 6667. // case 6600: case 6667: ProcessorCycleCounterPeriod = 6667; break; } // // Load the number of machine cycles per usecond, for use by // FwStallExecution. The +1 ensures that this value is never // too optimistic, due to the float->integer truncation. // CyclesPerMicrosecond = (1000000 / ProcessorCycleCounterPeriod) + 1; MemorySize = SystemInfo->MemorySizeInBytes; } // // Set variables according to the bits in configuration register // ConfigurationBit = FALSE; DisplayOutput = FALSE; SerialOutput = FALSE; // // Look for configuration register. // #if 0 // // The ConfigurationBit is disabled in the product. // HalpWriteVti(RTC_APORT, RTC_RAM_NT_FLAGS0); Diag = HalpReadVti(RTC_DPORT); if (((PRTC_RAM_NT_FLAGS_0)(&Diag))->ConfigurationBit) { ConfigurationBit = TRUE; } #endif // // Set interrupt lines to a known state. // WRITE_PORT_UCHAR((PUCHAR)&SP1_WRITE->ModemControl,0x08); WRITE_PORT_UCHAR((PUCHAR)&SP2_WRITE->ModemControl,0x08); WRITE_PORT_UCHAR((PUCHAR)&FLOPPY_WRITE->DigitalOutput,0x08); READ_PORT_UCHAR((PUCHAR)&PARALLEL_READ->Status); // // Initialize the system parameter block. // SYSTEM_BLOCK->Signature = 0x53435241; SYSTEM_BLOCK->Length = sizeof(SYSTEM_PARAMETER_BLOCK); SYSTEM_BLOCK->Version = ARC_VERSION; SYSTEM_BLOCK->Revision = ARC_REVISION; SYSTEM_BLOCK->DebugBlock = NULL; SYSTEM_BLOCK->FirmwareVectorLength = (ULONG)MaximumRoutine * sizeof(ULONG); SYSTEM_BLOCK->FirmwareVector = (PVOID)((PUCHAR)SYSTEM_BLOCK + sizeof(SYSTEM_PARAMETER_BLOCK)); SYSTEM_BLOCK->VendorVectorLength = (ULONG)MaximumVendorRoutine * sizeof(ULONG); SYSTEM_BLOCK->VendorVector = (PVOID)((PUCHAR)SYSTEM_BLOCK->FirmwareVector + SYSTEM_BLOCK->FirmwareVectorLength); // // Always init the serial ports, because the NT Setup utility sends // diagnostics there. // PutLedDisplay(LED_SERIAL_INIT); SerialBootSetup(COMPORT1_VIRTUAL_BASE); SerialBootSetup(COMPORT2_VIRTUAL_BASE); #ifdef ALPHA_FW_KDHOOKS // // Initialize the kernel debugger stub. This can be called anytime // after the serial lines are inited. // FwInstallKd(); #endif // // If: the configuration bit is set, or // the video card initialization fails, // ...output to the serial line. Otherwise, output to video. // PutLedDisplay (LED_KEYBOARD_CTRL); if (ConfigurationBit || (DisplayBootInitialize(&VideoType) != ESUCCESS)) { SerialOutput = TRUE; PutLedDisplay(LED_BROKEN_VIDEO_OR_KB); FwClearScreen(); } else { // Video is ready to display messages. PutLedDisplay(LED_VIDEO_OK); DisplayOutput = TRUE; } // // If: the keyboard controller initialization fails, or // the keyboard initialization fails, // ...send an error message to the output device and direct future output // to the serial port. // if (InitKeyboardController() || InitKeyboard()) { FwPrint(ST_ALL_IO_TO_SERIAL_LINES_MSG); PutLedDisplay(LED_BROKEN_VIDEO_OR_KB); DisplayOutput = FALSE; SerialOutput = TRUE; } #ifdef ALPHA_FW_SERDEB #ifdef ALPHA_FW_VDB { // // Graphics debugging assistance. Print pre-init and post-init video // state. // ULONG H, I, J; SerSnapshot = TRUE; for (J = 0; J < 8; J++) { for (H = 0; H < 2; H++) { SerFwPrint("[%d:%d] = ", H, J*16); for (I = J*16; I < (J+1)*16; I++) { SerFwPrint("%x ", DebugAid[H][I]); } SerFwPrint("\r\n"); } } } #endif #endif // // Check for Alpha AXP architectural values that are obviously bad. // if (Cause == 0) { if (ProcessorInfo->PageSize != PAGE_SIZE) { FwPrint(ST_BAD_PAGE_SIZE_MSG, ProcessorInfo->PageSize); FwStallExecution(5 * 1000 * 1000); } if (SystemInfo->MemorySizeInBytes < FOUR_MB) { FwPrint(ST_BAD_MEMORY_SIZE_MSG, SystemInfo->MemorySizeInBytes); FwStallExecution(5 * 1000 * 1000); } if (SystemInfo->SystemCycleClockPeriod == 0) { FwPrint(ST_BAD_CLOCK_PERIOD_MSG, ProcessorCycleCounterPeriod); FwStallExecution(5 * 1000 * 1000); } } if (RomInitISP()) { FwPrint(ST_EISA_ISP_ERROR_MSG); } #if 0 // // This is not necessary. // // // Zero unused memory. // // This is dependent on the firmware memory map. // This could be made more independent via using #define's. // WildZeroMemory( (KSEG0_BASE | 0x0), (FW_BOTTOM_ADDRESS - 0x40000) ); WildZeroMemory( (KSEG0_BASE | FW_TOP_ADDRESS), (MemorySize - FW_TOP_ADDRESS) ); #endif FwBootSystem(); // // Hang if we come back. // for (;;) { PutLedDisplay(LED_OMEGA); } }
VOID FailSafeEntry( IN ULONG Unused0, IN PFW_PROCESSOR_INFORMATION Unused1, IN PFW_SYSTEM_INFORMATION SystemInfo ) /*++ Routine Description: This function gets control from the serial ROM if the serial ROM detects a corrupted VMS Console boot image. (In actuality, the serial ROM passes control the the linked firmware PALcode, which passes control to this function.) Arguments: Unused0, This keeps the PALcode interface identical to Unused1 the firmware. SystemInfo Contains Alpha_AXP information from the PALcode. Since this module is only executed on a hard reset, there is no need to check the "Cause" argument. Return Value: Never returns. --*/ { UNREFERENCED_PARAMETER(Unused0); UNREFERENCED_PARAMETER(Unused1); FwRtlStackPanic = 0; // Register exception handler with the firmware PALcode RegisterExceptionHandler(); // Clear out upper EISA address bits. WRITE_PORT_UCHAR((PUCHAR)HAE, 0x0); switch (SystemInfo->SystemCycleClockPeriod) { // // A bad cycle clock period would cause a system hang. // case 0: case 8000: default: CyclesPerMicrosecond = 125 + 1; break; // // This is an AX04 SROM bug: the number for a 6.667ns machine is // passed in as 6600, not 6667. // case 6600: case 6667: CyclesPerMicrosecond = 150 + 1; break; } // Initialize MemorySize to the size of memory in MegaBytes. MemorySize = SystemInfo->MemorySizeInBytes; // // Set interrupt lines to a known state. // WRITE_PORT_UCHAR((PUCHAR)&SP1_WRITE->ModemControl,0x08); WRITE_PORT_UCHAR((PUCHAR)&SP2_WRITE->ModemControl,0x08); WRITE_PORT_UCHAR((PUCHAR)&FLOPPY_WRITE->DigitalOutput,0x08); READ_PORT_UCHAR((PUCHAR)&PARALLEL_READ->Status); // // Initialize the system parameter block. // SYSTEM_BLOCK->Signature = 0x53435241; SYSTEM_BLOCK->Length = sizeof(SYSTEM_PARAMETER_BLOCK); SYSTEM_BLOCK->Version = ARC_VERSION; SYSTEM_BLOCK->Revision = ARC_REVISION; SYSTEM_BLOCK->RestartBlock = NULL; SYSTEM_BLOCK->DebugBlock = NULL; SYSTEM_BLOCK->FirmwareVectorLength = (ULONG)MaximumRoutine * sizeof(ULONG); SYSTEM_BLOCK->FirmwareVector = (PVOID)((PUCHAR)SYSTEM_BLOCK + sizeof(SYSTEM_PARAMETER_BLOCK)); SYSTEM_BLOCK->VendorVectorLength = (ULONG)MaximumVendorRoutine * sizeof(ULONG); SYSTEM_BLOCK->VendorVector = (PVOID)((PUCHAR)SYSTEM_BLOCK->FirmwareVector + SYSTEM_BLOCK->FirmwareVectorLength); SerialBootSetup(COMPORT1_VIRTUAL_BASE); SerialBootSetup(COMPORT2_VIRTUAL_BASE); // This may not be needed. // // If: the configuration bit is set, or // the video card initialization fails, // ...output to the serial line. Otherwise, output to video. // if (DisplayBootInitialize(&VideoType) != ESUCCESS) { SerialOutput = TRUE; FwClearScreen(); } else { // Video is ready to display messages. DisplayOutput = TRUE; } // // If: the keyboard controller initialization fails, or // the keyboard initialization fails, // ...send an error message to the output device and direct future output // to the serial port. // if (InitKeyboardController() || InitKeyboard()) { FwPrint(ST_ALL_IO_TO_SERIAL_LINES_MSG); DisplayOutput = FALSE; SerialOutput = TRUE; } PutLedDisplay(LED_VIDEO_OK); // // hang on error // while (RomInitISP()) { } #if 0 // // This is believed to not be necessary. // // // Zero unused memory. // // This is dependent on the firmware memory map. // This could be made more independent via using #define's. // WildZeroMemory( (KSEG0_BASE | 0x0), (FW_BOTTOM_ADDRESS - 0x40000) ); WildZeroMemory( (KSEG0_BASE | FW_TOP_ADDRESS), (MemorySize - FW_TOP_ADDRESS) ); #endif // // Now try to complete the upgrade. // JnFsUpgradeSystem(); // // Hang if we come back. // for (;;) { PutLedDisplay(LED_OMEGA); } }
void KeyboardProcess(void) { Delay_ms(5); if(!PTIH) { return; } DDRA = 0xFF; PORTA = 0x00; if (0 == Row0) { keyValue = 0; } else if (0 == Row1) { keyValue = 5; } else if (0 == Row2) { keyValue = 10; } else if (0 == Row3) { keyValue = 15; } else if (0 == Row4) { keyValue = 20; } else { //Error; } //设置PH为输出,PAD为输入,检测列号 //DisableKeyboard(); GPPort_Set(PH, PRT, 0, 0xE0); //复位相应寄存器 GPPort_Set(PH, DDR, 1, 0x1F); //设置PH[4:0]为输出 GPPort_Set(PAD1, PRT, 1, 0xFF); //复位相应寄存器 GPPort_Set(PAD1, DDR, 0, 0xF0); //设置PAD1[3:0]为输入 GPPort_Set(PAD0, PRT, 1, 0xFF); //复位相应寄存器 GPPort_Set(PAD0, DDR, 0, 0xFD); //设置PAD0[1]为输入 ATD0DIEN = 0x020F; Delay_us(10); if (0 == Column0) { //keyValue += 0; } else if (0 == Column1) { keyValue += 1; } else if (0 == Column2) { keyValue += 2; } else if (0 == Column3) { keyValue += 3; } else if (0 == Column4) { keyValue += 4; } else { //Error; } //EnableKeyboard(); InitKeyboard(); PIFH = 0xFF; //清除终端标志位 }
/******************************************************************** 函数功能:主函数。 入口参数:无。 返 回:无。 备 注:无。 ********************************************************************/ void main(void) //主函数 { uint8 i; uint16 id; uint8 InterruptSource; EA=1; //打开中断 InitKeyboard(); //初始化按键 InitUART(); //初始化串口 for(i=0;i<18;i++) //显示信息 { Prints(HeadTable[i]); } id=D12ReadID(); Prints("Your D12 chip\'s ID is: "); PrintShortIntHex(id); if(id==0x1012) { Prints(". ID is correct! Congratulations!\r\n\r\n"); } else { Prints(". ID is incorrect! What a pity!\r\n\r\n"); } UsbDisconnect(); //先断开USB连接 UsbConnect(); //将USB连接上 ConfigValue=0; //配置值初始化为0 while(1) //死循环 { if(D12GetIntPin()==0) //如果有中断发生 { D12WriteCommand(READ_INTERRUPT_REGISTER); //写读中断寄存器的命令 InterruptSource=D12ReadByte(); //读回第一字节的中断寄存器 if(InterruptSource&0x80)UsbBusSuspend(); //总线挂起中断处理 if(InterruptSource&0x40)UsbBusReset(); //总线复位中断处理 if(InterruptSource&0x01)UsbEp0Out(); //端点0输出中断处理 if(InterruptSource&0x02)UsbEp0In(); //端点0输入中断处理 if(InterruptSource&0x04)UsbEp1Out(); //端点1输出中断处理 if(InterruptSource&0x08)UsbEp1In(); //端点1输入中断处理 if(InterruptSource&0x10)UsbEp2Out(); //端点2输出中断处理 if(InterruptSource&0x20)UsbEp2In(); //端点2输入中断处理 } if(ConfigValue!=0) //如果已经设置为非0的配置,则可以返回报告数据 { LEDs=~KeyPress; //利用板上8个LED显示按键状态,按下时亮 if(!Ep1InIsBusy) //如果端点1输入没有处于忙状态,则可以发送数据 { KeyCanChange=0; //禁止按键扫描 if(KeyUp||KeyDown||KeyPress) //如果有按键事件发生 { SendReport(); //则返回报告 } KeyCanChange=1; //允许按键扫描 } } } }