hd.h 3.35 KB
/*
 * Copyright (C) 1996-1998 by the Board of Trustees
 *    of Leland Stanford Junior University.
 * 
 * This file is part of the SimOS distribution. 
 * See LICENSE file for terms of the license. 
 *
 */


/*****************************************************************
 * sim_disk.h
 *
 * Simple SCSI disk device emulation. Emulates a number of
 * independent disks. Correctly models disk latencies and
 * DMA transfers, but does not model disk controller contention.
 *
 * Created by: ??
 * Revised by: Dan Teodosiu, 07/96
 *
 * Attention: this file is also included by the remote access
 * server. Avoid dependencies.
 ****************************************************************/
 
#ifndef _SIM_DISK_H
#define _SIM_DISK_H
#if 0
#include "simtypes.h"
#endif
#define SectorSize		      512          /* disk sector size */

/* Note: the constant below determines the maximum number of
 * disks we can simulate in SimOS.
 */
#define SIM_MAX_DISKS                 512          /* max. disks / system */

/* Note: the following constants are related to the OS's view
 * of the disk controllers/units. The OS starts using a certain
 * disk by issuing a command to it.
 */
#define SIM_DISK_CMD_SIZE	      12           /* SCSI command size */
#define SIM_DISK_MAX_DMA_LENGTH       1024         /* max. DMA'ed pages */

#define SIM_DISK_SHADOW_BLKSIZE 4096    /* size of blocks in the shadow file */

#define ENCODE(_NODE,_CTRL,_UNIT) \
  ( ( ((_UNIT) & 0xff) << 0 ) |   \
    ( ((_CTRL) & 0xff) << 8 ) |   \
    ( ((_NODE) & 0xff) << 16 ) )
#define DECODE_NODE(_E) ( ((_E) >> 16) & 0xff )
#define DECODE_CTRL(_E) ( ((_E) >> 8)  & 0xff )
#define DECODE_UNIT(_E) ( ((_E) >> 0)  & 0xff )

/*** SimOS interface ***/

/* Initialize disk data structures for all nodes in the system.
 * When a controller wishes to interrupt, int_f will be called.
 * NOTE: this doesn't fully allocate storage yet, since doing so might
 *       be very wasteful at this point. Instead, sim_disk_touch() below
 *       should be called whenever accessing a disk for the first time.
 */
extern void sim_disk_init(int nodes, /* total number of nodes in system */
			  int uc,    /* units per controller */
			  void (*int_f)(int node, int ctrl, int unit, int on),
			  int restoreFromChkpt);

/* Signals that a disk is to start being accessed. This will complete
 * storage allocation and initialization for the specified disk.
 * It is an error to call this routine more than once for a given
 * disk.
 */
extern void sim_disk_touch(int node, int ctrl, int unit);


/*** OS interface ***/

/* Get status for disk number (ctrl, unit). "done" will be set to 0 for a disk
 * with a pending i/o operation.
 */
extern void sim_disk_status(int node, int ctrl, int unit,
			    int* done, int* bytes_tr, int* errno_val);

/* Start an i/o operation on the specified disk number (ctrl, unit).
 * This routine returns quickly, and schedules the transfer to take
 * place at the correct simulated time.
 */
extern void sim_disk_startio(int node, int ctrl, int unit,
			     unsigned char cmd[SIM_DISK_CMD_SIZE], /*SCSI cmd*/
			     PA            pages[SIM_DISK_MAX_DMA_LENGTH],
			     int           offset);

/* Tell "controller" that an i/o operation on specified unit is complete.
 */
extern void sim_disk_iodone(int node, int ctrl, int unit);

extern void sim_disk_simpleIO(long op,long unit,long count,long pAddr,long block);


#endif /* _SIM_DISK_H */