mirror of
https://github.com/QuantumLeaps/qpcpp.git
synced 2025-01-28 06:02:56 +08:00
98 lines
3.9 KiB
C++
98 lines
3.9 KiB
C++
|
//////////////////////////////////////////////////////////////////////////////
|
||
|
// Product: DOS console-based BSP, Open Eatcom
|
||
|
// Last Updated for Version: 4.2.00
|
||
|
// Date of the Last Update: Nov 02, 2011
|
||
|
//
|
||
|
// Q u a n t u m L e a P s
|
||
|
// ---------------------------
|
||
|
// innovating embedded systems
|
||
|
//
|
||
|
// Copyright (C) 2002-2011 Quantum Leaps, LLC. All rights reserved.
|
||
|
//
|
||
|
// This software may be distributed and modified under the terms of the GNU
|
||
|
// General Public License version 2 (GPL) as published by the Free Software
|
||
|
// Foundation and appearing in the file GPL.TXT included in the packaging of
|
||
|
// this file. Please note that GPL Section 2[b] requires that all works based
|
||
|
// on this software must also be made publicly available under the terms of
|
||
|
// the GPL ("Copyleft").
|
||
|
//
|
||
|
// Alternatively, this software may be distributed and modified under the
|
||
|
// terms of Quantum Leaps commercial licenses, which expressly supersede
|
||
|
// the GPL and are specifically designed for licensees interested in
|
||
|
// retaining the proprietary status of their code.
|
||
|
//
|
||
|
// Contact information:
|
||
|
// Quantum Leaps Web site: http://www.quantum-leaps.com
|
||
|
// e-mail: info@quantum-leaps.com
|
||
|
//////////////////////////////////////////////////////////////////////////////
|
||
|
#include "qp_port.h"
|
||
|
#include "bsp.h"
|
||
|
|
||
|
#include <dos.h> // for _dos_setvect()/_dos_getvect()
|
||
|
#include <conio.h> // for inp()/outp()
|
||
|
#include <stdlib.h> // for _exit()
|
||
|
#include <stdio.h>
|
||
|
|
||
|
// Local-scope objects -------------------------------------------------------
|
||
|
static void interrupt (*l_dosTmrISR)();
|
||
|
static void interrupt (*l_dosKbdISR)();
|
||
|
|
||
|
#define TMR_VECTOR 0x08
|
||
|
#define KBD_VECTOR 0x09
|
||
|
|
||
|
//............................................................................
|
||
|
static void interrupt ISR_tmr() {
|
||
|
QF_ISR_ENTRY();
|
||
|
|
||
|
QF::tick(); //<-- process the QF clock tick
|
||
|
|
||
|
QF_ISR_EXIT();
|
||
|
}
|
||
|
//............................................................................
|
||
|
static void interrupt ISR_kbd() {
|
||
|
QF_ISR_ENTRY();
|
||
|
|
||
|
uint8_t key = inp(0x60); // key scan code from 8042 kbd controller
|
||
|
uint8_t kcr = inp(0x61); // get keyboard control register
|
||
|
outp(0x61, (uint8_t)(kcr | 0x80)); // toggle acknowledge bit high
|
||
|
outp(0x61, kcr); // toggle acknowledge bit low
|
||
|
|
||
|
BSP_onKeyboardInput(key); // process the key (application specific)
|
||
|
|
||
|
QF_ISR_EXIT();
|
||
|
}
|
||
|
//............................................................................
|
||
|
void BSP_init(int, char *[]) {
|
||
|
}
|
||
|
//............................................................................
|
||
|
void QF::onStartup(void) {
|
||
|
// save the origingal DOS vectors ...
|
||
|
l_dosTmrISR = _dos_getvect(TMR_VECTOR);
|
||
|
l_dosKbdISR = _dos_getvect(KBD_VECTOR);
|
||
|
|
||
|
QF_INT_DISABLE();
|
||
|
_dos_setvect(TMR_VECTOR, &ISR_tmr);
|
||
|
_dos_setvect(KBD_VECTOR, &ISR_kbd);
|
||
|
QF_INT_ENABLE();
|
||
|
}
|
||
|
//............................................................................
|
||
|
void QF::onCleanup(void) {
|
||
|
// restore the original DOS vectors ...
|
||
|
QF_INT_DISABLE();
|
||
|
_dos_setvect(TMR_VECTOR, l_dosTmrISR);
|
||
|
_dos_setvect(KBD_VECTOR, l_dosKbdISR);
|
||
|
QF_INT_ENABLE();
|
||
|
|
||
|
_exit(0); // exit to DOS
|
||
|
}
|
||
|
//............................................................................
|
||
|
void QF::onIdle(void) { // NOTE: entered with interrupts DISABLED
|
||
|
QF_INT_ENABLE(); // must at least enable interrupts
|
||
|
}
|
||
|
//............................................................................
|
||
|
extern "C" void Q_onAssert(char const Q_ROM *const Q_ROM_VAR file, int line) {
|
||
|
fprintf(stderr, "Assertion failed in %s, line %d", file, line);
|
||
|
QF::stop();
|
||
|
}
|
||
|
|