"Fossies" - the Fresh Open Source Software Archive

Member "dosemu-1.4.0/src/include/pic.h" (4 May 2007, 6064 Bytes) of package /linux/misc/old/dosemu-1.4.0.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "pic.h" see the Fossies "Dox" file reference documentation.

    1 /* 
    2  * All modifications in this file to the original code are
    3  * (C) Copyright 1992, ..., 2007 the "DOSEMU-Development-Team".
    4  *
    5  * for details see file COPYING.DOSEMU in the DOSEMU distribution
    6  */
    7 
    8 #ifndef PIC_H
    9 #define PIC_H
   10 
   11 /* Priority Interrupt Controller Emulation 
   12    Copyright (C) 1994, J. Lawrence Stephan  jlarry@delanet.com
   13 
   14    This software is distributed under the terms of the GNU General Public 
   15    License, there are NO WARRANTIES, expressed or implied.  Use at your own 
   16    risk.  Use of this software as a part of any product is permitted only 
   17    if that  product is also distributed under the terms of the GNU General 
   18    Public  License.  
   19    
   20 
   21 
   22  Definitions for 8259A programmable Interrupt Controller Emulation 
   23   
   24 
   25   IRQ priority levels.  These are in order of priority, lowest number has
   26    highest priority.  Levels 16 - 30 are available for use, but currently
   27    have no fixed assignment.  They are extras for the convenience of dosemu.
   28    31 is tentatively reserved for a watchdog timer  (stall alarm).  
   29    
   30    IRQ2 does not exist.  A PCs IRQ2 line is actually connected to IRQ9.  The
   31    bios for IRQ9 does an int1a, then sends an EOI to the second PIC. ( This
   32    is simulated in the PIC code if IRQ9 points to the bios segment.)  For
   33    this reason there is no PIC_IRQ2.
   34   
   35 */
   36    
   37 /* Values from 16 - 31 are available for assignment if not already 
   38  * assigned below.  They can be used to activate dos interrupts not
   39  * associated to the hardware pic controllers, or simply to activate
   40  * other dosemu code.  This is best used to initiate non-signal dosemu
   41  * code from within a signal handler.
   42  */
   43 
   44 
   45 #include "extern.h"
   46 #include "types.h"
   47 #define NEVER 0x8000000000000000ULL
   48 #define PIC_NMI   0        /*  non-maskable interrupt 0x02 */
   49 #define PIC_IRQ0  1        /*  timer -    usually int 0x08 */
   50 #define PIC_IRQ1  2        /*  keyboard - usually int 0x09 */
   51 #define PIC_IRQ8  3        /*  real-time clock "  int 0x70 */
   52 #define PIC_IRQ9  4        /*  int 0x71 revectors to  0x0a */
   53 #define PIC_IRQ10 5        /*             usually int 0x72 */
   54 #define PIC_IRQ11 6        /*             usually int 0x73 */
   55 #define PIC_IRQ12 7        /*  PS/2 mouse,usually int 0x74 */
   56 #define PIC_IRQ13 8        /*             usually int 0x75 */
   57 #define PIC_IRQ14 9        /*  disk       usually int 0x76 */
   58 #define PIC_IRQ15 10       /*             usually int 0x77 */
   59 #define PIC_IRQ3  11       /*  COM 2      usually int 0x0b */
   60 #define PIC_IRQ4  12       /*  COM 1      usually int 0x0c */
   61 #define PIC_IRQ5  13       /*  LPT 2      usually int 0x0d */
   62 #define PIC_IRQ6  14       /*  floppy     usually int 0x0e */
   63 #define PIC_IRQ7  15       /*  LPT 1      usually int 0x0f */
   64 #define PIC_NET   16       /*  packet receive check - no dos equivalent */
   65 #define PIC_IPX    17      /*  IPX Signal */
   66 #define PIC_IPX_AES 18     /*  IPX AES Signal */
   67 
   68 #define PIC_IMOUSE PIC_IRQ12 /*  internal mouse driver       */
   69 
   70 /* pic_irq_list translates irq numbers to pic_ilevels.  This is not used
   71    by pic routines; it is simply made available for configuration ease */
   72 EXTERN unsigned long pic_irq_list[] INIT({PIC_IRQ0,  PIC_IRQ1,  PIC_IRQ9,  PIC_IRQ3,
   73                                PIC_IRQ4,  PIC_IRQ5,  PIC_IRQ6,  PIC_IRQ7,
   74                                PIC_IRQ8,  PIC_IRQ9,  PIC_IRQ10, PIC_IRQ11,
   75                                PIC_IRQ12, PIC_IRQ13, PIC_IRQ14, PIC_IRQ15});
   76 
   77 /* pic_level_list translates  pic_ilevels to irq numbers.  This is not used
   78    by pic routines; it is simply made available for configuration ease */
   79 EXTERN unsigned long pic_level_list[] INIT({
   80                  -1, 0, 1, 8, 9, 10, 11, 12, 13, 14, 15, 3, 4, 5, 6, 7 });
   81 
   82 EXTERN hitimer_t pic_dos_time;     /* dos time of last interrupt,1193047/sec.*/
   83 EXTERN hitimer_t pic_sys_time INIT(NEVER);     /* system time set by pic_watch */
   84 extern hitimer_t pic_itime[33];
   85 
   86 /* IRQ definitions.  Each entry specifies the emulator routine to call, and
   87    the dos interrupt vector to use.  pic_iinfo.func is set by pic_seti(),
   88    as are the interrupt vectors for all but [1] through [15], which  may be
   89    changed by the ICW2 command from dos. (Some dos extenders do this.) */
   90    
   91 struct lvldef {
   92        int (*func)(int);
   93        void (*callback)(void);
   94        int    ivec;
   95 };
   96 
   97 /* function definitions - level refers to irq priority level defined above  */
   98 /* port = 0 or 1     value = 0 - 0xff   level = 0 - 31    ivec = 0 - 0xff   */
   99 
  100 void write_pic0(ioport_t port, Bit8u value); /* write to PIC 0 */
  101 void write_pic1(ioport_t port, Bit8u value); /* write to PIC 1 */
  102 Bit8u read_pic0(ioport_t port);             /* read from PIC 0 */
  103 Bit8u read_pic1(ioport_t port);             /* read from PIC 1 */
  104 void pic_seti(unsigned int, int (*)(int), unsigned int, void (*)(void)); 
  105                                        /* set function and interrupt vector */
  106 void run_irqs(void);                                  /* run requested irqs */
  107 #define pic_run() run_irqs()   /* the right way to call run_irqs */
  108 
  109 #define PIC_REQ_NOP 0
  110 #define PIC_REQ_OK  1
  111 #define PIC_REQ_LOST    (-2)
  112 #define PIC_REQ_PEND    (-1)
  113 int pic_request(int inum);                            /* interrupt trigger */
  114 void pic_untrigger(int inum);                          /* interrupt untrigger */
  115 
  116 void pic_set_callback(Bit16u cs, Bit16u ip);
  117 
  118 void pic_iret(void);                         /* interrupt completion notify */
  119 void pic_iret_dpmi(void);                    /* interrupt completion notify */
  120 void pic_resched(void);
  121 inline void pic_watch(hitimer_u *s_time);    /* interrupt pending watchdog timer */
  122 void do_irq0(void);             /* timer interrupt */
  123 int pic_pending(void);          /* inform caller if interrupt is pending */
  124 int pic_irq_active(int num);
  125 int pic_irq_masked(int num);
  126 void pic_sched(int ilevel, int interval);          /* schedule an interrupt */
  127 /* The following are too simple to be anything but in-line */
  128 
  129 #define pic_set_mask pic_imr=(pic0_imr|pic1_imr|pic_iflag)
  130 void pic_sti(void);
  131 void pic_cli(void);
  132 
  133 int CAN_SLEEP(void);
  134 
  135 extern void pic_reset(void);
  136 extern void pic_init(void);
  137 
  138 #endif  /* PIC_H */