mirror of
https://github.com/Stichting-MINIX-Research-Foundation/pkgsrc-ng.git
synced 2025-09-10 21:09:31 -04:00
503 lines
12 KiB
Plaintext
503 lines
12 KiB
Plaintext
$NetBSD: patch-aj,v 1.1 2003/09/30 17:47:44 tron Exp $
|
|
|
|
--- mc68k/fab_custom.c.orig 1998-07-29 01:08:48.000000000 +0200
|
|
+++ mc68k/fab_custom.c 2003-09-30 19:22:12.000000000 +0200
|
|
@@ -1027,252 +1027,251 @@
|
|
* Max Okumoto
|
|
*---------------------------------------------------------------------------*/
|
|
static char *HACK[] = {
|
|
-"
|
|
-/****************************************
|
|
- * Handle a key event. The fields *
|
|
- * keydown and key of the shared image *
|
|
- * are interpreted, and the dragonball *
|
|
- * registers updated *
|
|
- ****************************************/
|
|
-static void
|
|
-dokey(void)
|
|
-{
|
|
- UBYTE d;
|
|
- d = db_PDDATA.x;
|
|
- if (CustShptr->keydown) {
|
|
- db_PDDATA.x |= (1 << CustShptr->key);
|
|
- CustShptr->keydown = 0;
|
|
- CustShptr->key = -1;
|
|
- } else if (CustShptr->key >= 0) {
|
|
- db_PDDATA.x &= ~(1 << CustShptr->key);
|
|
- CustShptr->key = -1;
|
|
- }
|
|
- db_PDDATA_edge |= db_PDDATA.x & ~d;
|
|
- db_IPR.anon.PEN = CustShptr->pen;
|
|
- db_IPR.x = (db_IPR.x & 0xffff00ff) |
|
|
- ((((db_PDDATA_edge & db_PDIRQEDGE.x) |
|
|
- (db_PDDATA.x & ~db_PDIRQEDGE.x)) & db_PDIRQEN.x) << 8);
|
|
-}
|
|
-
|
|
-void
|
|
-updateisr()
|
|
-{
|
|
- db_IPR.anon.PEN = CustShptr->pen;
|
|
- db_ISR.x = db_IPR.x & ~db_IMR.x;
|
|
- if (db_ISR.x) {
|
|
- specialflags |= SPCFLAG_INT;
|
|
- }
|
|
- CustShptr->run_updateisr = 0;
|
|
-}
|
|
-
|
|
-void
|
|
-maybe_updateisr()
|
|
-{
|
|
- if (CustShptr->run_updateisr) {
|
|
- dokey();
|
|
- updateisr();
|
|
- }
|
|
-}
|
|
-
|
|
-int
|
|
-intbase()
|
|
-{
|
|
- return db_IVR.anon.VECTOR << 3;
|
|
-}
|
|
-
|
|
-int
|
|
-intlev()
|
|
-{
|
|
- if (db_ISR.anon.IRQ7) return 7;
|
|
- if (db_ISR.anon.SPIS) return 6;
|
|
- if (db_ISR.anon.TMR1) return 6;
|
|
- if (db_ISR.anon.IRQ6) return 6;
|
|
- if (db_ISR.anon.PEN) return 5;
|
|
- if (db_ISR.anon.SPIM) return 4;
|
|
- if (db_ISR.anon.TMR2) return 4;
|
|
- if (db_ISR.anon.UART) return 4;
|
|
- if (db_ISR.anon.WDT) return 4;
|
|
- if (db_ISR.anon.RTC) return 4;
|
|
- if (db_ISR.anon.KB) return 4;
|
|
- if (db_ISR.anon.PWM) return 4;
|
|
- if (db_ISR.anon.INT0) return 4;
|
|
- if (db_ISR.anon.INT1) return 4;
|
|
- if (db_ISR.anon.INT2) return 4;
|
|
- if (db_ISR.anon.INT3) return 4;
|
|
- if (db_ISR.anon.INT4) return 4;
|
|
- if (db_ISR.anon.INT5) return 4;
|
|
- if (db_ISR.anon.INT6) return 4;
|
|
- if (db_ISR.anon.INT7) return 4;
|
|
- if (db_ISR.anon.IRQ3) return 3;
|
|
- if (db_ISR.anon.IRQ2) return 2;
|
|
- if (db_ISR.anon.IRQ1) return 1;
|
|
- return -1;
|
|
-}
|
|
-
|
|
-static void
|
|
-pen(int down, int x, int y)
|
|
-{
|
|
- if (!pendown && down) {
|
|
- db_IPR.anon.PEN = 1;
|
|
- updateisr();
|
|
- } else if (pendown && !down) {
|
|
- db_IPR.anon.PEN = 0;
|
|
- updateisr();
|
|
- }
|
|
- pendown = down;
|
|
- penx = x;
|
|
- peny = y;
|
|
-}
|
|
-
|
|
-static void
|
|
-hotsync(int down)
|
|
-{
|
|
- if (down) {
|
|
- db_IPR.anon.IRQ1 = 1;
|
|
- } else {
|
|
- db_IPR.anon.IRQ1 = 0;
|
|
- }
|
|
- updateisr();
|
|
-}
|
|
-
|
|
-/*
|
|
- * custptr is a pointer to a shared memory block which will \"back-up\"
|
|
- * the register values of the custom circuits, allowing other processes
|
|
- * to look at register values
|
|
- */
|
|
-void
|
|
-custom_init(shared_img * shptr)
|
|
-{
|
|
- CustShptr = shptr;
|
|
- CustShptr->PICF = 0;
|
|
- CustShptr->VPW = 0xff;
|
|
- CustShptr->POSR = 0;
|
|
- CustShptr->grpalette[0] = 1;
|
|
- CustShptr->grpalette[1] = 0;
|
|
- CustShptr->grpalette[2] = 3;
|
|
- CustShptr->grpalette[3] = 7;
|
|
- CustShptr->quit = 0;
|
|
- CustShptr->run_updateisr = 0;
|
|
- CustShptr->LcdPower = lcdOn;
|
|
- CustShptr->Backlight = 0;
|
|
- customreset();
|
|
-}
|
|
-
|
|
-void
|
|
-do_cycles(int longtime)
|
|
-{
|
|
- if (db_TCTL2.anon.TEN) {
|
|
- db_TCN2.anon.COUNT++;
|
|
- if (db_TCN2.anon.COUNT > db_TCMP2.anon.COMPARE || longtime) {
|
|
- db_TSTAT2.anon.COMP = 1;
|
|
- if (db_TCTL2.anon.FRR == 0) {
|
|
- db_TCN2.anon.COUNT = 0;
|
|
- }
|
|
- if (db_TCTL2.anon.IRQEN) {
|
|
- db_IPR.anon.TMR2 = 1;
|
|
- updateisr();
|
|
- }
|
|
- }
|
|
- }
|
|
- /*
|
|
- * Determine if there are any chars to read from the serial port or
|
|
- * debugger
|
|
- */
|
|
-
|
|
- /*
|
|
- * WARNING: This uses a shared memory data structure to store the
|
|
- * FIFO. The producer is adding things to this _at the same time_ as
|
|
- * this is consuming. Examine main.c and take a course in concurrent
|
|
- * programming before modifying this. :-) - Ian
|
|
- */
|
|
-
|
|
- if (CustShptr->serial.head != CustShptr->serial.tail &&
|
|
- db_USTCNT.anon.UART_ENABLE && !db_URX.anon.DATA_READY) {
|
|
- int curhead = CustShptr->serial.head;
|
|
- db_URX.anon.DATA = CustShptr->serial.fifo[curhead];
|
|
- curhead += 1;
|
|
- if (curhead == FIFO_SIZE) {
|
|
- curhead = 0;
|
|
- }
|
|
- CustShptr->serial.head = curhead;
|
|
- db_URX.anon.DATA_READY = 1;
|
|
- if (db_USTCNT.anon.RX_READY_ENABLE) {
|
|
- db_IPR.anon.UART = 1;
|
|
- updateisr();
|
|
- }
|
|
- }
|
|
- if (CustShptr->gdb.head != CustShptr->gdb.tail &&
|
|
- db_USTCNT.anon.UART_ENABLE && !db_URXdb.anon.DATA_READY) {
|
|
- int curhead = CustShptr->gdb.head;
|
|
- db_URXdb.anon.DATA = CustShptr->gdb.fifo[curhead];
|
|
- curhead += 1;
|
|
- if (curhead == FIFO_SIZE) {
|
|
- curhead = 0;
|
|
- }
|
|
- CustShptr->gdb.head = curhead;
|
|
- db_URXdb.anon.DATA_READY = 1;
|
|
- }
|
|
-}
|
|
-
|
|
-struct EventType {
|
|
- UWORD eType;
|
|
- UWORD penDown;
|
|
- UWORD screenX;
|
|
- UWORD screenY;
|
|
- UWORD data[8];
|
|
-};
|
|
-
|
|
-struct SndCommandType {
|
|
- UWORD cmd;
|
|
- UWORD param1hi;
|
|
- UWORD param1lo;
|
|
- UWORD param2;
|
|
- UWORD param3;
|
|
-};
|
|
-
|
|
-#define keyDownEvent 4
|
|
-#define sysTrapEvtGetEvent 41245
|
|
-#define sysTrapSndDoCmd 41523
|
|
-
|
|
-int
|
|
-do_api(int api)
|
|
-{
|
|
- switch (api) {
|
|
- case sysTrapEvtGetEvent:
|
|
- if (CustShptr->kbin != CustShptr->kbout) {
|
|
-
|
|
- struct EventType *ev;
|
|
- int out;
|
|
-
|
|
- out = CustShptr->kbout;
|
|
- ev = (struct EventType *) get_real_address(get_long(CustShptr->regs.a[7]));
|
|
-
|
|
- ev->eType = keyDownEvent;
|
|
- ev->data[0] = CustShptr->kb[out];
|
|
- ev->data[1] = 0;
|
|
- ev->data[2] = 0;
|
|
- CustShptr->kbout = (out + 1) & 7;
|
|
- return 1;
|
|
- }
|
|
- break;
|
|
- case sysTrapSndDoCmd:
|
|
- {
|
|
- struct SndCommandType *sc;
|
|
- sc = (struct SndCommandType *)
|
|
- get_real_address(get_long(CustShptr->regs.a[7] + 4));
|
|
- if ((sc->cmd >> 8) == 1) {
|
|
- CustShptr->BellFreq = (sc->param1hi << 16) + sc->param1lo;
|
|
- CustShptr->BellDur = sc->param2;
|
|
- CustShptr->BellAmp = sc->param3;
|
|
- CustShptr->LcdReq = lcdBell;
|
|
- return 1;
|
|
- }
|
|
- }
|
|
- break;
|
|
- }
|
|
- return 0;
|
|
-}
|
|
-"
|
|
+"\n"
|
|
+"/****************************************\n"
|
|
+" * Handle a key event. The fields *\n"
|
|
+" * keydown and key of the shared image *\n"
|
|
+" * are interpreted, and the dragonball *\n"
|
|
+" * registers updated *\n"
|
|
+" ****************************************/\n"
|
|
+"static void\n"
|
|
+"dokey(void)\n"
|
|
+"{\n"
|
|
+" UBYTE d;\n"
|
|
+" d = db_PDDATA.x;\n"
|
|
+" if (CustShptr->keydown) {\n"
|
|
+" db_PDDATA.x |= (1 << CustShptr->key);\n"
|
|
+" CustShptr->keydown = 0;\n"
|
|
+" CustShptr->key = -1;\n"
|
|
+" } else if (CustShptr->key >= 0) {\n"
|
|
+" db_PDDATA.x &= ~(1 << CustShptr->key);\n"
|
|
+" CustShptr->key = -1;\n"
|
|
+" }\n"
|
|
+" db_PDDATA_edge |= db_PDDATA.x & ~d;\n"
|
|
+" db_IPR.anon.PEN = CustShptr->pen;\n"
|
|
+" db_IPR.x = (db_IPR.x & 0xffff00ff) |\n"
|
|
+" ((((db_PDDATA_edge & db_PDIRQEDGE.x) |\n"
|
|
+" (db_PDDATA.x & ~db_PDIRQEDGE.x)) & db_PDIRQEN.x) << 8);\n"
|
|
+"}\n"
|
|
+"\n"
|
|
+"void\n"
|
|
+"updateisr()\n"
|
|
+"{\n"
|
|
+" db_IPR.anon.PEN = CustShptr->pen;\n"
|
|
+" db_ISR.x = db_IPR.x & ~db_IMR.x;\n"
|
|
+" if (db_ISR.x) {\n"
|
|
+" specialflags |= SPCFLAG_INT;\n"
|
|
+" }\n"
|
|
+" CustShptr->run_updateisr = 0;\n"
|
|
+"}\n"
|
|
+"\n"
|
|
+"void\n"
|
|
+"maybe_updateisr()\n"
|
|
+"{\n"
|
|
+" if (CustShptr->run_updateisr) {\n"
|
|
+" dokey();\n"
|
|
+" updateisr();\n"
|
|
+" }\n"
|
|
+"}\n"
|
|
+"\n"
|
|
+"int\n"
|
|
+"intbase()\n"
|
|
+"{\n"
|
|
+" return db_IVR.anon.VECTOR << 3;\n"
|
|
+"}\n"
|
|
+"\n"
|
|
+"int\n"
|
|
+"intlev()\n"
|
|
+"{\n"
|
|
+" if (db_ISR.anon.IRQ7) return 7;\n"
|
|
+" if (db_ISR.anon.SPIS) return 6;\n"
|
|
+" if (db_ISR.anon.TMR1) return 6;\n"
|
|
+" if (db_ISR.anon.IRQ6) return 6;\n"
|
|
+" if (db_ISR.anon.PEN) return 5;\n"
|
|
+" if (db_ISR.anon.SPIM) return 4;\n"
|
|
+" if (db_ISR.anon.TMR2) return 4;\n"
|
|
+" if (db_ISR.anon.UART) return 4;\n"
|
|
+" if (db_ISR.anon.WDT) return 4;\n"
|
|
+" if (db_ISR.anon.RTC) return 4;\n"
|
|
+" if (db_ISR.anon.KB) return 4;\n"
|
|
+" if (db_ISR.anon.PWM) return 4;\n"
|
|
+" if (db_ISR.anon.INT0) return 4;\n"
|
|
+" if (db_ISR.anon.INT1) return 4;\n"
|
|
+" if (db_ISR.anon.INT2) return 4;\n"
|
|
+" if (db_ISR.anon.INT3) return 4;\n"
|
|
+" if (db_ISR.anon.INT4) return 4;\n"
|
|
+" if (db_ISR.anon.INT5) return 4;\n"
|
|
+" if (db_ISR.anon.INT6) return 4;\n"
|
|
+" if (db_ISR.anon.INT7) return 4;\n"
|
|
+" if (db_ISR.anon.IRQ3) return 3;\n"
|
|
+" if (db_ISR.anon.IRQ2) return 2;\n"
|
|
+" if (db_ISR.anon.IRQ1) return 1;\n"
|
|
+" return -1;\n"
|
|
+"}\n"
|
|
+"\n"
|
|
+"static void\n"
|
|
+"pen(int down, int x, int y)\n"
|
|
+"{\n"
|
|
+" if (!pendown && down) {\n"
|
|
+" db_IPR.anon.PEN = 1;\n"
|
|
+" updateisr();\n"
|
|
+" } else if (pendown && !down) {\n"
|
|
+" db_IPR.anon.PEN = 0;\n"
|
|
+" updateisr();\n"
|
|
+" }\n"
|
|
+" pendown = down;\n"
|
|
+" penx = x;\n"
|
|
+" peny = y;\n"
|
|
+"}\n"
|
|
+"\n"
|
|
+"static void\n"
|
|
+"hotsync(int down)\n"
|
|
+"{\n"
|
|
+" if (down) {\n"
|
|
+" db_IPR.anon.IRQ1 = 1;\n"
|
|
+" } else {\n"
|
|
+" db_IPR.anon.IRQ1 = 0;\n"
|
|
+" }\n"
|
|
+" updateisr();\n"
|
|
+"}\n"
|
|
+"\n"
|
|
+"/*\n"
|
|
+" * custptr is a pointer to a shared memory block which will \"back-up\"\n"
|
|
+" * the register values of the custom circuits, allowing other processes\n"
|
|
+" * to look at register values\n"
|
|
+" */\n"
|
|
+"void\n"
|
|
+"custom_init(shared_img * shptr)\n"
|
|
+"{\n"
|
|
+" CustShptr = shptr;\n"
|
|
+" CustShptr->PICF = 0;\n"
|
|
+" CustShptr->VPW = 0xff;\n"
|
|
+" CustShptr->POSR = 0;\n"
|
|
+" CustShptr->grpalette[0] = 1;\n"
|
|
+" CustShptr->grpalette[1] = 0;\n"
|
|
+" CustShptr->grpalette[2] = 3;\n"
|
|
+" CustShptr->grpalette[3] = 7;\n"
|
|
+" CustShptr->quit = 0;\n"
|
|
+" CustShptr->run_updateisr = 0;\n"
|
|
+" CustShptr->LcdPower = lcdOn;\n"
|
|
+" CustShptr->Backlight = 0;\n"
|
|
+" customreset();\n"
|
|
+"}\n"
|
|
+"\n"
|
|
+"void\n"
|
|
+"do_cycles(int longtime)\n"
|
|
+"{\n"
|
|
+" if (db_TCTL2.anon.TEN) {\n"
|
|
+" db_TCN2.anon.COUNT++;\n"
|
|
+" if (db_TCN2.anon.COUNT > db_TCMP2.anon.COMPARE || longtime) {\n"
|
|
+" db_TSTAT2.anon.COMP = 1;\n"
|
|
+" if (db_TCTL2.anon.FRR == 0) {\n"
|
|
+" db_TCN2.anon.COUNT = 0;\n"
|
|
+" }\n"
|
|
+" if (db_TCTL2.anon.IRQEN) {\n"
|
|
+" db_IPR.anon.TMR2 = 1;\n"
|
|
+" updateisr();\n"
|
|
+" }\n"
|
|
+" }\n"
|
|
+" }\n"
|
|
+" /*\n"
|
|
+" * Determine if there are any chars to read from the serial port or\n"
|
|
+" * debugger\n"
|
|
+" */\n"
|
|
+"\n"
|
|
+" /*\n"
|
|
+" * WARNING: This uses a shared memory data structure to store the\n"
|
|
+" * FIFO. The producer is adding things to this _at the same time_ as\n"
|
|
+" * this is consuming. Examine main.c and take a course in concurrent\n"
|
|
+" * programming before modifying this. :-) - Ian\n"
|
|
+" */\n"
|
|
+"\n"
|
|
+" if (CustShptr->serial.head != CustShptr->serial.tail &&\n"
|
|
+" db_USTCNT.anon.UART_ENABLE && !db_URX.anon.DATA_READY) {\n"
|
|
+" int curhead = CustShptr->serial.head;\n"
|
|
+" db_URX.anon.DATA = CustShptr->serial.fifo[curhead];\n"
|
|
+" curhead += 1;\n"
|
|
+" if (curhead == FIFO_SIZE) {\n"
|
|
+" curhead = 0;\n"
|
|
+" }\n"
|
|
+" CustShptr->serial.head = curhead;\n"
|
|
+" db_URX.anon.DATA_READY = 1;\n"
|
|
+" if (db_USTCNT.anon.RX_READY_ENABLE) {\n"
|
|
+" db_IPR.anon.UART = 1;\n"
|
|
+" updateisr();\n"
|
|
+" }\n"
|
|
+" }\n"
|
|
+" if (CustShptr->gdb.head != CustShptr->gdb.tail &&\n"
|
|
+" db_USTCNT.anon.UART_ENABLE && !db_URXdb.anon.DATA_READY) {\n"
|
|
+" int curhead = CustShptr->gdb.head;\n"
|
|
+" db_URXdb.anon.DATA = CustShptr->gdb.fifo[curhead];\n"
|
|
+" curhead += 1;\n"
|
|
+" if (curhead == FIFO_SIZE) {\n"
|
|
+" curhead = 0;\n"
|
|
+" }\n"
|
|
+" CustShptr->gdb.head = curhead;\n"
|
|
+" db_URXdb.anon.DATA_READY = 1;\n"
|
|
+" }\n"
|
|
+"}\n"
|
|
+"\n"
|
|
+"struct EventType {\n"
|
|
+" UWORD eType;\n"
|
|
+" UWORD penDown;\n"
|
|
+" UWORD screenX;\n"
|
|
+" UWORD screenY;\n"
|
|
+" UWORD data[8];\n"
|
|
+"};\n"
|
|
+"\n"
|
|
+"struct SndCommandType {\n"
|
|
+" UWORD cmd;\n"
|
|
+" UWORD param1hi;\n"
|
|
+" UWORD param1lo;\n"
|
|
+" UWORD param2;\n"
|
|
+" UWORD param3;\n"
|
|
+"};\n"
|
|
+"\n"
|
|
+"#define keyDownEvent 4\n"
|
|
+"#define sysTrapEvtGetEvent 41245\n"
|
|
+"#define sysTrapSndDoCmd 41523\n"
|
|
+"\n"
|
|
+"int\n"
|
|
+"do_api(int api)\n"
|
|
+"{\n"
|
|
+" switch (api) {\n"
|
|
+" case sysTrapEvtGetEvent:\n"
|
|
+" if (CustShptr->kbin != CustShptr->kbout) {\n"
|
|
+"\n"
|
|
+" struct EventType *ev;\n"
|
|
+" int out;\n"
|
|
+"\n"
|
|
+" out = CustShptr->kbout;\n"
|
|
+" ev = (struct EventType *) get_real_address(get_long(CustShptr->regs.a[7]));\n"
|
|
+"\n"
|
|
+" ev->eType = keyDownEvent;\n"
|
|
+" ev->data[0] = CustShptr->kb[out];\n"
|
|
+" ev->data[1] = 0;\n"
|
|
+" ev->data[2] = 0;\n"
|
|
+" CustShptr->kbout = (out + 1) & 7;\n"
|
|
+" return 1;\n"
|
|
+" }\n"
|
|
+" break;\n"
|
|
+" case sysTrapSndDoCmd:\n"
|
|
+" {\n"
|
|
+" struct SndCommandType *sc;\n"
|
|
+" sc = (struct SndCommandType *)\n"
|
|
+" get_real_address(get_long(CustShptr->regs.a[7] + 4));\n"
|
|
+" if ((sc->cmd >> 8) == 1) {\n"
|
|
+" CustShptr->BellFreq = (sc->param1hi << 16) + sc->param1lo;\n"
|
|
+" CustShptr->BellDur = sc->param2;\n"
|
|
+" CustShptr->BellAmp = sc->param3;\n"
|
|
+" CustShptr->LcdReq = lcdBell;\n"
|
|
+" return 1;\n"
|
|
+" }\n"
|
|
+" }\n"
|
|
+" break;\n"
|
|
+" }\n"
|
|
+" return 0;\n"
|
|
+"}\n\n"
|
|
};
|
|
|
|
/*---------------------------------------------------------------------------*
|