Annotation of OSKit-Mach/oskit/ds_oskit.h, revision 1.1

1.1     ! root        1: #ifndef        _DS_OSKIT_H_
        !             2: #define        _DS_OSKIT_H_
        !             3: 
        !             4: #include <device/device_types.h>
        !             5: #include <device/net_status.h>
        !             6: #include <device/if_hdr.h>
        !             7: #include "device_interface.h"
        !             8: #include "ds_routines.h"
        !             9: 
        !            10: #include <oskit/dev/error.h>
        !            11: #include <oskit/dev/osenv.h>
        !            12: 
        !            13: #include <mach/port.h>
        !            14: #include <mach/message.h>
        !            15: #include <kern/lock.h>
        !            16: #include <kern/queue.h>
        !            17: 
        !            18: #include <cpus.h>
        !            19: 
        !            20: struct device_ops {
        !            21:   io_return_t (*write) (device_t, ipc_port_t, mach_msg_type_name_t,
        !            22:                        dev_mode_t, recnum_t, io_buf_ptr_t, unsigned, int *);
        !            23:   io_return_t (*write_inband) (device_t, ipc_port_t, mach_msg_type_name_t,
        !            24:                               dev_mode_t, recnum_t, io_buf_ptr_inband_t,
        !            25:                               unsigned, int *);
        !            26:   io_return_t (*read) (device_t, ipc_port_t, mach_msg_type_name_t,
        !            27:                       dev_mode_t, recnum_t, int, io_buf_ptr_t *, unsigned *);
        !            28:   io_return_t (*read_inband) (device_t, ipc_port_t, mach_msg_type_name_t,
        !            29:                              dev_mode_t, recnum_t, int, char *, unsigned *);
        !            30:   io_return_t (*set_status) (device_t, dev_flavor_t, dev_status_t,
        !            31:                             mach_msg_type_number_t);
        !            32:   io_return_t (*get_status) (device_t, dev_flavor_t, dev_status_t,
        !            33:                             mach_msg_type_number_t *);
        !            34:   io_return_t (*set_filter) (device_t, ipc_port_t, int, filter_t [], unsigned);
        !            35: 
        !            36:   io_return_t (*write_trap) (device_t, dev_mode_t,
        !            37:                             recnum_t, vm_offset_t, vm_size_t);
        !            38:   io_return_t (*writev_trap) (device_t, dev_mode_t,
        !            39:                              recnum_t, io_buf_vec_t *, vm_size_t);
        !            40: 
        !            41:   /* Called with PA == 0 to check if mapping is allowed,
        !            42:      and with PA != 0 to get an actual physical address.  */
        !            43:   io_return_t (*map) (device_t, vm_prot_t, vm_offset_t, vm_size_t,
        !            44:                      oskit_addr_t *pa);
        !            45: 
        !            46:   void (*close) (device_t);
        !            47: };
        !            48: 
        !            49: 
        !            50: #include <oskit/dev/device.h>
        !            51: #include <oskit/io/blkio.h>
        !            52: #include <oskit/diskpart/diskpart.h>
        !            53: #include <oskit/com/stream.h>
        !            54: #include <oskit/io/asyncio.h>
        !            55: #include <oskit/dev/net.h>
        !            56: #include <oskit/io/netio.h>
        !            57: #if defined(__i386__)
        !            58: #include <machine/io_perm.h>
        !            59: #endif
        !            60: 
        !            61: struct device {
        !            62:   const struct device_ops *ops;
        !            63: 
        !            64:   decl_simple_lock_data(,ref_lock) /* lock for reference count */
        !            65:   int ref_count;               /* reference count */
        !            66:   decl_simple_lock_data(, lock) /* lock for rest of state */
        !            67: 
        !            68:   struct ipc_port *port;       /* open port */
        !            69:   dev_mode_t mode;             /* D_READ and/or D_WRITE */
        !            70: 
        !            71:   /* This COM object is the generic handle on the device.  We never use
        !            72:      this object after device_open, but its pointer serves as our unique
        !            73:      identifier for the device so we can detect a second open.  To be sure
        !            74:      the pointer remains unique, we keep the COM object alive as long as
        !            75:      this device port lives.  */
        !            76:   oskit_device_t *com_device;
        !            77:   queue_chain_t hash_chain;
        !            78: 
        !            79:   union {
        !            80:     struct {
        !            81:       oskit_blkio_t *io;
        !            82:       oskit_u32_t size;                /* block size */
        !            83: #define MAX_PARTS 30
        !            84:       diskpart_t *parts;
        !            85:     } blk;
        !            86:     struct {
        !            87:       device_t blk;            /* underlying device_t, which is blk type */
        !            88:       diskpart_t *part;                /* which partition this is */
        !            89:     } blkpart;
        !            90:     struct {
        !            91:       oskit_stream_t *io;
        !            92:       oskit_asyncio_t *aio;
        !            93:       oskit_s32_t listening;   /* OSKIT_ASYNCIO_* */
        !            94:       queue_head_t read_queue, write_queue; /* queued requests */
        !            95:       queue_chain_t ready_queue; /* when on device_ready_queue */
        !            96:       oskit_listener_t listener; /* my life as a COM object */
        !            97:     } stream;
        !            98:     struct {
        !            99:       char *contents;
        !           100:       oskit_size_t size;
        !           101:     } bus;
        !           102:     struct {
        !           103:       vm_offset_t pa;
        !           104:       vm_size_t size, recsize;
        !           105:     } mem;
        !           106:     struct {
        !           107:       oskit_netio_t *sendi;
        !           108:       oskit_netio_t recvi;     /* my life as a COM object: incoming packets */
        !           109:       struct ifnet ifnet;      /* cruft for net_io.c */
        !           110:     } net;
        !           111: #if defined(__i386__)
        !           112:     struct
        !           113:     {
        !           114:       io_port_t from, to;
        !           115:     } io_perm;
        !           116: #endif
        !           117:   } com;
        !           118: };
        !           119: 
        !           120: /*
        !           121:  * To lock and unlock state and open-count
        !           122:  */
        !           123: #define        device_lock(device)     simple_lock(&(device)->lock)
        !           124: #define        device_unlock(device)   simple_unlock(&(device)->lock)
        !           125: 
        !           126: /* These macros are used to take a global lock around entering
        !           127:    any oskit driver code.  */
        !           128: #if ! MULTIPROCESSOR
        !           129: #else
        !           130: # warning SMP support in oskit-mach is incomplete
        !           131: #endif
        !           132: #define DEV_LOCK_INIT  ((void)0)
        !           133: #define DEV_LOCK(dev)  ((void)0)
        !           134: #define DEV_UNLOCK(dev)        ((void)0)
        !           135: 
        !           136: extern const struct device_ops no_device_ops;
        !           137: extern const struct device_ops stream_device_ops;
        !           138: extern const struct device_ops asyncio_device_ops;
        !           139: extern const struct device_ops block_device_ops;
        !           140: extern const struct device_ops block_partition_device_ops;
        !           141: extern const struct device_ops net_device_ops;
        !           142: extern const struct device_ops mem_device_ops;
        !           143: extern const struct device_ops bus_device_ops;
        !           144: 
        !           145: extern oskit_error_t ds_netdev_open (device_t dev, oskit_netdev_t *netdev);
        !           146: 
        !           147: 
        !           148: /* #define INVALOP while (1) asm volatile ("int $3") */
        !           149: /* #define INVALSZ while (1) asm volatile ("int $3") */
        !           150: #define INVALOP return D_INVALID_OPERATION
        !           151: #define INVALSZ return D_INVALID_SIZE
        !           152: #define INVALREC return D_INVALID_RECNUM
        !           153: /*#define INVALREC ({dump_stack_trace();panic("invalid record");})*/
        !           154: 
        !           155: 
        !           156: static inline io_return_t
        !           157: oskit_to_mach_error (oskit_error_t rc)
        !           158: {
        !           159:   switch (rc)
        !           160:     {
        !           161:     case 0:                            return D_SUCCESS;
        !           162:     case OSKIT_E_DEV_NOSUCH_DEV:       return D_NO_SUCH_DEVICE;
        !           163:     case OSKIT_E_DEV_NOSUCH_CHILD:     return D_NO_SUCH_DEVICE;
        !           164:     case OSKIT_E_DEV_NOMORE_CHILDREN:  return D_NO_SUCH_DEVICE;
        !           165:     case OSKIT_E_DEV_BADOP:            INVALOP;
        !           166:     case OSKIT_E_DEV_BADPARAM:         INVALOP;
        !           167:     case OSKIT_E_OUTOFMEMORY:          return D_NO_MEMORY;
        !           168:     case OSKIT_EWOULDBLOCK:            return D_WOULD_BLOCK;
        !           169:     default:
        !           170:       assert (OSKIT_FAILED (rc));
        !           171:       return D_IO_ERROR;
        !           172:     }
        !           173: }
        !           174: 
        !           175: 
        !           176: extern oskit_osenv_t *mach_osenv;
        !           177: extern oskit_stream_t *ds_console_stream;
        !           178: extern oskit_stream_t *kmsg_stream;
        !           179: extern unsigned int kmsg_readers;
        !           180: extern void kmsg_init (void);
        !           181: 
        !           182: 
        !           183: #define splio  spltty          /* XXX */
        !           184: #define SPLIO  SPLTTY          /* XXX */
        !           185: 
        !           186: #define        sploskit splio
        !           187: #define        SPLOSKIT SPLIO
        !           188: 
        !           189: 
        !           190: extern zone_t io_inband_zone; /* for inband reads */
        !           191: 
        !           192: extern void oskit_softint (void); /* osenv_softirq.c */
        !           193: 
        !           194: 
        !           195: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.