1: /* The object file of "table.c" contains all the data.  In the *.h files, 
   2:  * declared variables appear with EXTERN in front of them, as in
   3:  *
   4:  *    EXTERN int x;
   5:  *
   6:  * Normally EXTERN is defined as extern, so when they are included in another
   7:  * file, no storage is allocated.  If the EXTERN were not present, but just
   8:  * say,
   9:  *
  10:  *    int x;
  11:  *
  12:  * then including this file in several source files would cause 'x' to be
  13:  * declared several times.  While some linkers accept this, others do not,
  14:  * so they are declared extern when included normally.  However, it must
  15:  * be declared for real somewhere.  That is done here, by redefining
  16:  * EXTERN as the null string, so the inclusion of all the *.h files in
  17:  * table.c actually generates storage for them.  All the initialized
  18:  * variables are also declared here, since
  19:  *
  20:  * extern int x = 4;
  21:  *
  22:  * is not allowed.  If such variables are shared, they must also be declared
  23:  * in one of the *.h files without the initialization.
  24:  */
  25: 
  26: #define _TABLE
  27: 
  28: #include "kernel.h"
  29: #include <stdlib.h>
  30: #include <termios.h>
  31: #include <minix/com.h>
  32: #include "proc.h"
  33: #include "tty.h"
  34: #include <ibm/int86.h>
  35: 
  36: /* The startup routine of each task is given below, from -NR_TASKS upwards.
  37:  * The order of the names here MUST agree with the numerical values assigned to
  38:  * the tasks in <minix/com.h>.
  39:  */
  40: #define SMALL_STACK     (128 * sizeof(char *))
  41: 
  42: #define TTY_STACK       (3 * SMALL_STACK)
  43: #define SYN_ALRM_STACK  SMALL_STACK
  44: 
  45: #define DP8390_STACK    (2 * SMALL_STACK * ENABLE_DP8390)
  46: #define RTL8139_STACK   (2 * SMALL_STACK * ENABLE_RTL8139)
  47: 
  48: #if (CHIP == INTEL)
  49: #define IDLE_STACK      ((3+3+4) * sizeof(char *))  /* 3 intr, 3 temps, 4 db */
  50: #else
  51: #define IDLE_STACK      SMALL_STACK
  52: #endif
  53: 
  54: #define PRINTER_STACK   (SMALL_STACK * ENABLE_PRINTER)
  55: 
  56: #define CTRLR_STACK     (2 * SMALL_STACK)
  57: 
  58: #define SB16_STACK      (4 * SMALL_STACK * ENABLE_SB16)
  59: #define SB16MIXER_STACK (4 * SMALL_STACK * ENABLE_SB16)
  60: 
  61: #define FLOP_STACK      (3 * SMALL_STACK)
  62: #define MEM_STACK       SMALL_STACK
  63: #define CLOCK_STACK     SMALL_STACK
  64: #define SYS_STACK       SMALL_STACK
  65: #define HARDWARE_STACK  0               /* dummy task, uses kernel stack */
  66: 
  67: 
  68: #define TOT_STACK_SPACE         (TTY_STACK + DP8390_STACK + RTL8139_STACK + \
  69:         SYN_ALRM_STACK + IDLE_STACK + HARDWARE_STACK + PRINTER_STACK + \
  70:         NR_CTRLRS * CTRLR_STACK + FLOP_STACK + MEM_STACK + CLOCK_STACK + \
  71:         SYS_STACK + SB16_STACK + SB16MIXER_STACK)
  72: 
  73: 
  74: /*
  75:  * Some notes about the following table:
  76:  *  1) The tty_task should always be first so that other tasks can use printf
  77:  *     if their initialisation has problems.
  78:  *  2) If you add a new kernel task, add it before the printer task.
  79:  *  3) The task name is used for the process name (p_name).
  80:  */
  81: 
  82: PUBLIC struct tasktab tasktab[] = {
  83:         { tty_task,             TTY_STACK,      "TTY"             },
  84: #if ENABLE_DP8390
  85:         { dp8390_task,          DP8390_STACK,   "DP8390"  },
  86: #endif
  87: #if ENABLE_RTL8139
  88:         { rtl8139_task,         RTL8139_STACK,  "RTL8139" },
  89: #endif
  90: #if ENABLE_SB16
  91:         { sb16_task,            SB16_STACK,     "SB16"            },
  92:         { sb16mixer_task,       SB16MIXER_STACK,"SB16MIX" },
  93: #endif
  94: #if ENABLE_PRINTER
  95:         { printer_task,         PRINTER_STACK,  "PRINTER" },
  96: #endif
  97: #if NR_CTRLRS >= 4
  98:         { nop_task,             CTRLR_STACK,    "(C3)"            },
  99: #endif
 100: #if NR_CTRLRS >= 3
 101:         { nop_task,             CTRLR_STACK,    "(C2)"            },
 102: #endif
 103: #if NR_CTRLRS >= 2
 104:         { nop_task,             CTRLR_STACK,    "(C1)"            },
 105: #endif
 106: #if NR_CTRLRS >= 1
 107:         { nop_task,             CTRLR_STACK,    "(C0)"            },
 108: #endif
 109:         { syn_alrm_task,        SYN_ALRM_STACK, "SYN_AL"  },
 110:         { idle_task,            IDLE_STACK,     "IDLE"            },
 111:         { floppy_task,          FLOP_STACK,     "FLOPPY"  },
 112:         { mem_task,             MEM_STACK,      "MEMORY"  },
 113:         { clock_task,           CLOCK_STACK,    "CLOCK"           },
 114:         { sys_task,             SYS_STACK,      "SYS"             },
 115:         { 0,                    HARDWARE_STACK, "HARDWAR" },
 116:         { 0,                    0,              "MM"              },
 117:         { 0,                    0,              "FS"              },
 118:         { 0,                    0,              "INIT"            },
 119: };
 120: 
 121: /* Mapping from driver names to driver functions, e.g. "bios" -> bios_wini. */
 122: PRIVATE struct drivertab {
 123:         char drivername[8];
 124:         task_t *driver;
 125: } drivertab[] = {
 126: 
 127: #if ENABLE_AT_WINI
 128:         { "at",           at_winchester_task      },
 129: #endif
 130: 
 131: #if ENABLE_BIOS_WINI
 132:         { "bios", bios_winchester_task    },
 133: #endif
 134: 
 135: #if ENABLE_ESDI_WINI
 136:         { "esdi", esdi_winchester_task    },
 137: #endif
 138: 
 139: #if ENABLE_XT_WINI
 140:         { "xt",           xt_winchester_task      },
 141: #endif
 142: 
 143: #if ENABLE_AHA1540_SCSI
 144:         { "aha1540",      aha1540_scsi_task       },
 145: #endif
 146: 
 147: #if ENABLE_DOSFILE
 148:         { "dosfile",      dosfile_task            },
 149: #endif
 150: 
 151: #if ENABLE_FATFILE
 152:         { "fatfile",      fatfile_task            },
 153: #endif
 154: 
 155: };
 156: 
 157: /*===========================================================================*
 158:  *                              mapdrivers                                   *
 159:  *===========================================================================*/
 160: PUBLIC void mapdrivers()
 161: {
 162:   /* Map drivers to controllers and update the task table to that selection. */
 163:   static char name[] = "c0";
 164:   int c;
 165:   struct drivertab *dp;
 166:   char *drivername;
 167:   struct tasktab *tp;
 168: 
 169:   for (c= 0; c < NR_CTRLRS; c++) {
 170:         name[1] = '0' + c;
 171:         if ((drivername = getenv(name)) == NULL) continue;
 172:         for (dp = drivertab;
 173:              dp < drivertab + sizeof(drivertab)/sizeof(drivertab[0]); dp++) {
 174:                 if (strcmp(drivername, dp->drivername) == 0) {
 175:                         tp = &tasktab[CTRLR(c) + NR_TASKS];
 176:                         tp->initial_pc = dp->driver;
 177:                         strcpy(tp->name, drivername);
 178:                 }
 179:         }
 180:   }
 181: }
 182: 
 183: /* Stack space for all the task stacks.  (Declared as (char *) to align it.) */
 184: PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)];
 185: 
 186: /*
 187:  * The number of kernel tasks must be the same as NR_TASKS.
 188:  * If NR_TASKS is not correct then you will get the compile error:
 189:  *   "array size is negative"
 190:  */
 191: 
 192: #define NKT (sizeof tasktab / sizeof (struct tasktab) - (INIT_PROC_NR + 1))
 193: 
 194: extern int dummy_tasktab_check[NR_TASKS == NKT ? 1 : -1];