hd.h
3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* 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 */