types.h


#ifndef _TYPES_H
#define _TYPES_H

#include "const.h"            /* include needed due to a bug
                       in pcc                      */

typedef int void;           

/* virtual address */
typedef struct {
    unsigned v_offset :9,       /* byte offset in page */
         v_page   :5,       /* page number */
         v_seg    :2;       /* segment number */
} vad_t;

/* page descriptor */
typedef struct {
    unsigned pd_frame :7,       /* page frame number */
              :6,       /* unused */
         pd_r     :1,       /* reference bit */
         pd_m     :1,       /* modified bit */
         pd_p     :1;       /* presence bit */
} pd_t;

/* segment descriptor */
typedef struct {
    unsigned sd_len  :5,        /* page table length */
         sd_prot :3,        /* access protection bits */
         sd_p    :1,        /* presence bit */
             :7;        /* unused */
    pd_t     *sd_pta;       /* address of the page table */
} sd_t;

/* processor status word1 */
typedef struct {
    unsigned ps_c   :1,     /* carry */
         ps_o   :1,     /* overflow */
         ps_z   :1,     /* zero */
         ps_n   :1,     /* negative */
            :1,     /* not used */
         ps_w   :1,     /* wait */
         ps_m   :1,     /* translation */
         ps_ku  :1,     /* processor mode */
         ps_int :8;     /* interrupt mask */
} ps1_t;

/* processor status word2 */
typedef union {
    struct {
        unsigned in_dno :3,     /* device number */
             in_dev :3,     /* device type */
                :10;        /* not used */
    } p2_int;
    struct {
        unsigned mm_pg  :5,     /* page number */
             mm_seg :2,     /* segment number */
                :1,     /* not used */
             mm_typ :8;     /* type of mm trap */
    } p2_mm;
    struct {
        unsigned pr_typ :8,     /* type of prog trap */
                :8;     /* not used */
    } p2_pr;
    struct {
        unsigned sys_no :8,     /* number of sys trap */
                :8;     /* not used */
    } p2_sys;
} ps2_t;

/* processor state */
typedef struct {
    int  s_r[8];        /* general registers r0-r5 */
#define s_sp     s_r[6]         /* stack pointer */
#define s_pc     s_r[7]         /* program counter */
    ps1_t   s_ps1;         /* processor status word 1 */
    ps2_t   s_ps2;         /* processor status word 2 */
    sd_t     *s_sta;        /* segment table address register */
    unsigned s_stl;         /* stack limit register */
} state_t;

/* Device registers */
typedef struct {
    unsigned d_op,      /* operation register */
         d_dadd;    /* address, amount, track or sector number */
#define d_amnt  d_dadd      /* synonyms for the above */
#define d_track d_dadd
#define d_sect  d_dadd
    char     *d_badd;   /* buffer address register */
    unsigned d_stat,    /* status register */
         d_notused[4];  /* force alignment at each 8th word */
} devreg_t;


typedef union {
    long    l;
    struct  {
        unsigned int    whigh,
                wlow;
    } w;
} double_t;


#ifdef SUPPORT
typedef struct {
    int io_sta;
    int io_len;
} iores_t;
#else
typedef struct {
    int io_len;
    int io_sta;
} iores_t;
#endif

#endif


[INDICE CODICE]