The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/i386ps2/abios.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1991 Carnegie Mellon University
    4  * Copyright (c) 1991 IBM Corporation 
    5  * All Rights Reserved.
    6  * 
    7  * Permission to use, copy, modify and distribute this software and its
    8  * documentation is hereby granted, provided that both the copyright
    9  * notice and this permission notice appear in all copies of the
   10  * software, derivative works or modified versions, and any portions
   11  * thereof, and that both notices appear in supporting documentation,
   12  * and that the name IBM not be used in advertising or publicity 
   13  * pertaining to distribution of the software without specific, written
   14  * prior permission.
   15  * 
   16  * CARNEGIE MELLON AND IBM ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   17  * CONDITION.  CARNEGIE MELLON AND IBM DISCLAIM ANY LIABILITY OF ANY KIND FOR
   18  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   19  * 
   20  * Carnegie Mellon requests users of this software to return to
   21  * 
   22  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   23  *  School of Computer Science
   24  *  Carnegie Mellon University
   25  *  Pittsburgh PA 15213-3890
   26  * 
   27  * any improvements or extensions that they make and grant Carnegie Mellon
   28  * the rights to redistribute these changes.
   29  */
   30 
   31 /*
   32  * HISTORY
   33  * $Log:        abios.h,v $
   34  * Revision 2.3  93/03/11  14:08:44  danner
   35  *      u_long -> u_int
   36  *      [93/03/09            danner]
   37  * 
   38  *      [93/03/09            danner]
   39  * 
   40  * Revision 2.2  93/02/04  07:58:36  danner
   41  *      Integrate PS2 code from IBm.
   42  *      [93/01/18            prithvi]
   43  * 
   44  */
   45 
   46 #ifndef _H_ABIOS
   47 #define _H_ABIOS
   48 /*
   49  * COMPONENT_NAME: INC/SYS abios.h ABIOS Structures and Define's
   50  *
   51  * FUNCTIONS:
   52  *
   53  * ORIGINS: 27
   54  *
   55  * IBM CONFIDENTIAL -- (IBM Confidential Restricted when
   56  * combined with the aggregated modules for this product)
   57  * OBJECT CODE ONLY SOURCE MATERIALS
   58  * (C) COPYRIGHT International Business Machines Corp. 1989
   59  * All Rights Reserved
   60  *
   61  * US Government Users Restricted Rights - Use, duplication or
   62  * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
   63  */                                                                   
   64 
   65 /*
   66  * Advanced Bios data structures and defines.
   67  *
   68  * The structure looks something like this:
   69  *
   70  *       +---------------+
   71  *       | Request Block |
   72  *       +---------------+
   73  *       |       *       |
   74  *     +-+  Logical ID   |
   75  *     | |       *       |
   76  *     | +---------------+
   77  *     |                       +----------------+
   78  *     |   +-------------------+ Anchor Pointer |
   79  *     |   |                   +----------------+
   80  *     |   |  +---------------------------------+
   81  *     |   +->|      Common Data Area           |
   82  *     |      +---------------------------------+
   83  *     |   +--+      Data pointer 0 Offset      |            +-----------------+
   84  *     |   |  |      Number Logical ID's        |     +----->|  Device Block n |
   85  *     |   |  |                *                |     |      +-----------------+
   86  *     +---+->|      Device Block Pointer n     |-----+      |        *        |
   87  *     +---+--+ Function Transfer Table Pointer |            |   Device Data   |
   88  *     |   |  |       for logial device n       |            |        *        |
   89  *     |   |  |                *                |            +-----------------+
   90  *     |   |  |                *                |            +-----------------+
   91  *     |   |  |         Data Pointer 'p'        |----------->|  Device Memory  |
   92  *     |   |  |                *                |            +-----------------+
   93  *     |   +->|         Data Pointer 0          |
   94  *     |      +---------------------------------+
   95  *     |      +---------------------------------+            +-----------------+
   96  *     +----->|     Function Transfer Table     |            | ABIOS Functions |
   97  *            +---------------------------------+            +-----------------+
   98  *            |                *                |            |        *        |
   99  *            |        Function 1 Pointer       |----------->|   Function 1    |
  100  *            |        Function 2 Pointer       |----------->|   Function 2    |
  101  *            |        Function 3 Pointer       |----------->|   Function 3    |
  102  *            |                *                |            |        *        |
  103  *            +---------------------------------+            +-----------------+
  104  *
  105  * This diagram is from Chapter 2 of the "Advanced BIOS Supplement for the IBM 
  106  * Personal System/2 and Personal Computer BIOS Interface Technical Reference"
  107  * P/N 68X2288.
  108  */
  109 
  110 /*
  111  * unix uses 32 bit addressing model.
  112  * NOTE: this does not change the size of the data structures.
  113  * Also note that all pointers MUST be far pointers. "Near pointers"
  114  * must be declared as u_short.
  115  */
  116 #define  far
  117 #define BOOTSEG_OFF     0x0
  118 #define FP_SEG(address) ((0xf8000 & ((u_int)(address)+BOOTSEG_OFF)) >> 4)
  119 #define FP_OFF(address) (0x7fff & ((u_int)(address)+BOOTSEG_OFF))
  120 #define TOFAR(address)  ((FP_SEG(address)<<16)|(FP_OFF(address)))
  121 
  122 #ifndef MACH
  123 /* MACH will have defined these types in sys/types.h */
  124 typedef unsigned long   u_int;
  125 typedef unsigned short  u_short;
  126 typedef unsigned char   u_char;
  127 #endif
  128 
  129 #define BIOS2BYTE(address) (((u_int)(address)*1024)-BOOTSEG_OFF)
  130 
  131 /*
  132  * the function transfer table contains
  133  * calls to the ABIOS start, interrupt, and timeout
  134  * routines. Each logical device also has a number of
  135  * function call routines. The number of this are specified
  136  * by the function_count field.
  137  */
  138 struct Function_call    {
  139         void    (far *x)();
  140 };
  141 
  142 struct  Function_transfer_table {
  143         void    (far *start)();
  144         void    (far *interrupt)();
  145         void    (far *timeout)();
  146         u_short function_count;
  147         u_short Reserved1;
  148         struct Function_call    fun_call[1]; /* unknown size... */
  149 };
  150 #define function_call(n)        fun_call[n].x
  151 
  152 /*
  153  * the device block contains internal state information
  154  * about the device running. All fields fall under 2 catagories:
  155  * public (read-only areas which the OS may read), and private 
  156  * (data areas which the OS may never read data format veries between
  157  * different ABOIS implementations). Only the pulic areas of the structure
  158  * is defined in this .h file.
  159  */
  160 struct Port_pairs {
  161         u_short start;
  162         u_short end;
  163 };
  164 
  165 struct Device_block {
  166         u_short device_block_length;
  167         u_char  revision;
  168         u_char  secondary_device_id;    /* additional revision info */
  169         u_short logical_id;
  170         u_short device_id;
  171         u_short count_of_exclusive_ids;
  172         u_short count_of_common_ids;
  173         struct  Port_pairs      excl_ports[1]; /* unknown size */
  174 };
  175 #define exclusive_ports(n)      excl_ports[(n)]
  176 #define common_ports(n)         excl_ports[(n)+count_of_exclusive_ids]
  177 /*
  178  * The common block consists of a 1) header with the pointer to data '',
  179  * and the number of logical ids, 2) an array of logical devices, 3) an
  180  * inverted array of data pointers.
  181  */
  182 #define MAKE_POINTER(seg,data)  ((char far *)((char far *)seg + \
  183                                                         (u_short)data))
  184 #define ALIGN_SEGMENT(pointer) (((unsigned long)(pointer) +0xf) & ~0xf)
  185 #define ANCHOR_SEG(pointer)     (((unsigned long)(pointer)+BOOTSEG_OFF) >> 4)
  186 
  187 struct  Logical_device {
  188         struct Device_block far *device_block;
  189         struct Function_transfer_table far *function_transfer_table;
  190 };
  191 
  192 struct Data_pointer {
  193         u_short         dp_length;
  194         u_short         dp_offset;
  195         u_short         dp_segment;
  196 };
  197 
  198 struct Common_data_area_head {
  199         u_short         data_ptr_0;
  200         u_short         number_logical_ids;
  201         u_short         Reserved1[2];
  202         struct  Logical_device  log_device[1]; /* unknown size */
  203 } far *anchor_pointer;
  204 
  205 u_short anchor_seg;
  206 
  207 #define ABIOS_HEAD      10
  208 
  209 
  210 #define logical_device(n)       (anchor_pointer->log_device[(n)-1])
  211 #define datapointer ((struct Data_pointer far *)(&anchor_pointer->log_device \
  212         [anchor_pointer->number_logical_ids]))
  213 #define data_pointer0 ((struct Data_pointer far *)MAKE_POINTER( \
  214                                  anchor_pointer,anchor_pointer->data_ptr_0))
  215 #define data_pointer(n) (datapointer[(data_pointer0 - &datapointer[n])])
  216 
  217 /*
  218  * Initialization structures.
  219  */
  220 
  221 /*
  222  * system parameter table. Contains the entry points into ABIOS.
  223  */
  224 struct System_parameter_table {
  225         void    (far *common_start)();
  226         void    (far *common_interrupt)();
  227         void    (far *common_timeout)();
  228         u_short min_stack;
  229         u_short Reserved[8];
  230 #ifdef notdef
  231         void    (far *common_32_start)();
  232         void    (far *common_32_interrupt)();
  233         void    (far *common_32_timeout)();
  234         u_int   Reserved;
  235 #endif
  236         u_short number_of_entries;
  237 };
  238 
  239 /*
  240  * system init table. Temparary table used in ABIOS init and thrown away
  241  */
  242 struct System_init_table {
  243         u_short         device_id;
  244         u_short         number_logical_ids;
  245         u_short         device_block_length;
  246         u_short         log_device_init[2];
  247         u_short         request_block_length;
  248         u_short         function_transfer_table_length;
  249         u_short         data_pointer_length;
  250         u_char          secondary_device_id;
  251         u_char          revision;
  252         u_short         Reserved[3];
  253 };
  254 
  255 /*
  256  * Request block defines.
  257  */
  258 /* Function Parametes */
  259 struct Request_header {
  260         u_short Current_req_blck_len;   /* IN */
  261         u_short Logical_id;             /* IN */
  262         u_short Unit;                   /* IN */
  263         u_short Function;               /* IN */
  264         u_short Request_Block_Flags;    /* IN ABIOS32 */
  265         u_short ELA_Offset;             /* IN ABIOS32 */
  266         u_short Return_code;            /* IN/OUT */
  267         u_short Time_out;               /* OUT */
  268 };
  269 #define r_current_req_blck_len  request_header.Current_req_blck_len
  270 #define r_logical_id            request_header.Logical_id
  271 #define r_unit                  request_header.Unit
  272 #define r_function              request_header.Function
  273 #define r_return_code           request_header.Return_code
  274 #define r_time_out              request_header.Time_out
  275 
  276 /* service specific info */
  277 struct Logical_id_params {
  278         u_char  Hardware_intr;          /* OUT */
  279 #define ABIOS_NO_INT    0xff    /* device doesn't interrupt */
  280 #define ABIOS_NMI_INT   0xfe    /* interrupts on the NMI line */
  281         u_char  Arbitration_level;      /* OUT */
  282 #define ABIOS_NO_ARB    0xff
  283         u_short Device_id;              /* OUT */
  284         u_short Number_units;           /* OUT */
  285         u_short Logical_id_flags;       /* OUT */
  286 #define OVERLAP_IO      0x08
  287 #define OFFSET_32_BITS  0x04
  288 #define POINTER_TYPES   0x03
  289 #define NO_POINTERS     0x00
  290 #define LOG_POINTER     0x01
  291 #define PHYS_POINTER    0x02
  292 #define BOTH_POINTER    0x03
  293 #define GET_POINTER_TYPE(x) ((x) & POINTER_TYPES)
  294         u_short Request_block_length;   /* OUT */
  295         u_char  Secondary_id;           /* OUT */
  296         u_char  Revision_level;         /* OUT */
  297         u_short Reserved2[2];
  298 }; 
  299 #define r_hardware_intr         un.logical_id_params.Hardware_intr
  300 #define r_arbitration_level     un.logical_id_params.Arbitration_level
  301 #define r_device_id             un.logical_id_params.Device_id
  302 #define r_number_units          un.logical_id_params.Number_units
  303 #define r_logical_id_flags      un.logical_id_params.Logical_id_flags
  304 #define r_request_block_length  un.logical_id_params.Request_block_length
  305 #define r_secondary_id          un.logical_id_params.Secondary_id
  306 #define r_revision_level        un.logical_id_params.Revision_level
  307 #define r_reserve_1             un.logical_id_params.Reserved2[0]
  308 #define r_reserve_2             un.logical_id_params.Reserved2[1]
  309 
  310 #define ABIOS_MIN_REQ_SIZE      0x20
  311 
  312 struct  Generic_parameters {
  313         u_short         reserved;
  314         u_short         data_pointer_offset;
  315         u_short         data_pointer_selector;
  316 };
  317 
  318 struct  generic_request {
  319         struct Request_header   request_header;
  320         union {
  321                 struct  Logical_id_params       logical_id_params;
  322                 struct  Generic_parameters      generic_parameters;
  323                 u_char  _Dummy[ABIOS_MIN_REQ_SIZE];
  324         } un;
  325 };
  326 
  327 #define g_data_offset   un.generic_parameters.data_pointer_offset
  328 #define g_data_selector un.generic_parameters.data_pointer_selector
  329 
  330 /* fake 32 bit abios common area */
  331 u_int   abios_common[512];
  332 struct System_parameter_table *system_param_p;
  333 
  334 
  335 
  336 /*
  337  * Function codes.
  338  */
  339 #define ABIOS_DEFAULT_INTERRUPT 0
  340 #define ABIOS_DEFAULT_INTERUPT  ABIOS_DEFAULT_INTERRUPT
  341 #define ABIOS_LOGICAL_PARAMETER 1
  342 #define ABIOS_RESERVED_2        2
  343 #define ABIOS_READ_PARAMETER    3
  344 #define ABIOS_WRITE_PARAMETER   4
  345 #define ABIOS_RESET             5
  346 #define ABIOS_ENABLE_INTR       6
  347 #define ABIOS_DISABLE_INTR      7
  348 #define ABIOS_READ              8
  349 #define ABIOS_WRITE             9
  350 #define ABIOS_ADDITIONAL_XFER   0xa
  351 
  352 /*
  353  * return codes, valid only if bit 15 is 0
  354  */
  355 #define ABIOS_DONE                      0x0000
  356 #define ABIOS_STAGE_ON_INT      0x0001
  357 #define ABIOS_STAGE_ON_TIME     0x0002
  358 #define ABIOS_NOT_MY_INT        0x0004
  359 #define ABIOS_ATTENTION         0x0008
  360 #define ABIOS_INT_RESET         0x0080
  361 
  362 /*
  363  * return codes, valid only if bit 15 is 1
  364  */
  365 #define ABIOS_FAILED_OP         0x8000
  366 #define ABIOS_BAD_PARAM         0x4000
  367 #define ABIOS_TIME_OUT          0x2000
  368 #define ABIOS_DEV_ERROR         0x1000
  369 #define ABIOS_RETRYABLE         0x0100
  370 
  371 /*
  372  * the following is the undefined return code
  373  */
  374 #define ABIOS_UNDEFINED         0xffff
  375 
  376 /*
  377  * macros to decipher ABIOS return codes
  378  */
  379 #define ABIOS_STAGED(x)         ((((x) & ABIOS_FAILED_OP)==0) && \
  380         ((x) & (ABIOS_STAGE_ON_INT|ABIOS_STAGE_ON_TIME)))
  381 #define ABIOS_RETRY(x)          ((x) & ABIOS_RETRYABLE)
  382 
  383 /*
  384  * the first valid abios lid
  385  */
  386 #define ABIOS_FIRST_LID 2
  387 
  388 /*
  389  * ABIOS ID's
  390  */
  391 #define ABIOS_ID        0       /* ABIOS internal calls */
  392 #define FD_ID           1       /* floppy */
  393 #define HD_ID           2       /* hard disk */
  394 #define VIDEO_ID        3       /* display */
  395 #define KBD_ID          4       /* keyboard */
  396 #define LP_ID           5       /* parallel port */
  397 #define ASY_ID          6       /* async port */
  398 #define SYSTIME_ID      7       /* system timer */
  399 #define CLOCK_ID        8       /* real time clock */
  400 #define SS_ID           9       /* system services */
  401 #define NMI_ID          0xa     /* non-mask interrupt */
  402 #define MS_ID           0xb     /* mouse */
  403 #define NVR_ID          0xe     /* Non-volatile ram */
  404 #define DMA_ID          0xf     /* dma */
  405 #define POS_ID          0x10    /* programable option select */
  406 #define KBDS_ID         0x16    /* keyboard security */
  407 
  408 /*
  409  * local abios structure to pass stuff from real mode to protected mode init
  410  */
  411 
  412 struct Abios_header  {
  413         u_int sys_table;
  414         u_int common_block;
  415         u_int end_data;
  416         u_int sys_conf_param;
  417         u_int bios_ext_data;
  418         u_int bios_mem_map;
  419         u_short logical_ids;
  420         u_short cpu_ids;
  421 } *abios_info;
  422 
  423 #define REALTOPHYS(value)       ((((value) >> 12) & ~0xf) + ((value) & 0xffff))
  424 
  425 struct selector_array {
  426         u_short selector;
  427         u_short segment;
  428 };
  429 
  430 #endif /* _H_ABIOS */

Cache object: db5e6a7d3187fcf1be83e206e61983cd


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.