1/* 2 * X680x0 ROM IOCS access definitions. 3 * based on Project C Library X68000 Programing Interface Definition 4 * /usr/include/sys/scsi.h 5 * $Id: scsi.h,v 1.2 2005/12/24 20:07:41 perry Exp $ 6 */ 7/* 8 * PROJECT C Library, X68000 PROGRAMMING INTERFACE DEFINITION 9 * -------------------------------------------------------------------- 10 * This file is written by the Project C Library Group, and completely 11 * in public domain. You can freely use, copy, modify, and redistribute 12 * the whole contents, without this notice. 13 * -------------------------------------------------------------------- 14 * from RCS Id: scsi.h,v 1.3 1994/07/31 17:21:50 mura Exp 15 */ 16 17#ifndef __INLINE_SCSI_H__ 18#define __INLINE_SCSI_H__ 19 20struct _readcap { 21 unsigned long block; 22 unsigned long size; 23}; 24 25struct _inquiry { 26 unsigned char unit; 27 unsigned char info; 28 unsigned char ver; 29 unsigned char reserve; 30 unsigned char size; 31 unsigned char buff[0]; 32}; 33 34static inline int _scsi_inquiry (int n, int id, struct _inquiry *buf) 35{ 36 register int reg_d0 __asm ("%d0"); 37 38 __asm volatile ("moveml %%d3-%%d4,%%sp@-\n\t" 39 "movel %2,%%d3\n\t" 40 "movel %3,%%d4\n\t" 41 "movel %4,%%a1\n\t" 42 "movel #0x20,%%d1\n\t" 43 "movel #0xf5,%%d0\n\t" 44 "trap #15\n\t" 45 "moveml %%sp@+,%%d3-%%d4" 46 : "=d" (reg_d0), "=m" (*buf) 47 : "ri" (n), "ri" (id), "g" ((int) buf) 48 : "%d1", "%d2", "%a1"); 49 50 return reg_d0; 51} 52static inline int _scsi_modesense (int page, int n, int id, void *buf) 53{ 54 register int reg_d0 __asm ("%d0"); 55 56 __asm volatile ("moveml %%d3-%%d4,%%sp@-\n\t" 57 "movel %2,%%d2\n\t" 58 "movel %3,%%d3\n\t" 59 "movel %4,%%d4\n\t" 60 "movel %5,%%a1\n\t" 61 "movel #0x29,%%d1\n\t" 62 "movel #0xf5,%%d0\n\t" 63 "trap #15\n\t" 64 "moveml %%sp@+,%%d3-%%d4" 65 : "=d" (reg_d0), "=m" (*(char*) buf) 66 : "ri" (page), "ri" (n), "ri" (id), "g" ((int) buf) 67 : "%d1", "%d2", "%a1"); 68 69 return reg_d0; 70} 71 72static inline int _scsi_read (int pos, int blk, int id, int size, void *buf) 73{ 74 register int reg_d0 __asm ("%d0"); 75 76 __asm volatile ("moveml %%d3-%%d5,%%sp@-\n\t" 77 "movel %2,%%d2\n\t" 78 "movel %3,%%d3\n\t" 79 "movel %4,%%d4\n\t" 80 "movel %5,%%d5\n\t" 81 "movel %6,%%a1\n\t" 82 "movel #0x21,%%d1\n\t" 83 "movel #0xf5,%%d0\n\t" 84 "trap #15\n\t" 85 "moveml %%sp@+,%%d3-%%d5" 86 : "=d" (reg_d0), "=m" (*(char*) buf) 87 : "ri" (pos), "ri" (blk), "ri" (id), "ri" (size), "g" ((int) buf) 88 : "%d1", "%d2", "%a1"); 89 90 return reg_d0; 91} 92 93static inline int _scsi_readcap (int id, struct _readcap *buf) 94{ 95 register int reg_d0 __asm ("%d0"); 96 97 __asm volatile ("moveml %%d4,%%sp@-\n\t" 98 "movel %2,%%d4\n\t" 99 "movel %3,%%a1\n\t" 100 "movel #0x25,%%d1\n\t" 101 "movel #0xf5,%%d0\n\t" 102 "trap #15\n\t" 103 "moveml %%sp@+,%%d4" 104 : "=d" (reg_d0), "=m" (*buf) 105 : "ri" (id), "g" ((int) buf) 106 : "%d1", "%a1"); 107 108 return reg_d0; 109} 110 111static inline int _scsi_seek (int pos, int id) 112{ 113 register int reg_d0 __asm ("%d0"); 114 115 __asm volatile ("moveml %%d4,%%sp@-\n\t" 116 "movel %1,%%d2\n\t" 117 "movel %2,%%d4\n\t" 118 "movel #0x2d,%%d1\n\t" 119 "movel #0xf5,%%d0\n\t" 120 "trap #15\n\t" 121 "moveml %%sp@+,%%d4" 122 : "=d" (reg_d0) 123 : "ri" (pos), "ri" (id) 124 : "%d1", "%d2"); 125 126 return reg_d0; 127} 128 129static inline int _scsi_testunit (int id) 130{ 131 register int reg_d0 __asm ("%d0"); 132 133 __asm volatile ("moveml %%d4,%%sp@-\n\t" 134 "movel %1,%%d4\n\t" 135 "movel #0x24,%%d1\n\t" 136 "movel #0xf5,%%d0\n\t" 137 "trap #15\n\t" 138 "moveml %%sp@+,%%d4" 139 : "=d" (reg_d0) 140 : "ri" (id) 141 : "%d1"); 142 143 return reg_d0; 144} 145 146static inline int _scsi_write (int pos, int blk, int id, int size, void *buf) 147{ 148 register int reg_d0 __asm ("%d0"); 149 150 __asm volatile ("moveml %%d3-%%d5,%%sp@-\n\t" 151 "movel %1,%%d2\n\t" 152 "movel %2,%%d3\n\t" 153 "movel %3,%%d4\n\t" 154 "movel %4,%%d5\n\t" 155 "movel %5,%%a1\n\t" 156 "movel #0x22,%%d1\n\t" 157 "movel #0xf5,%%d0\n\t" 158 "trap #15\n\t" 159 "moveml %%sp@+,%%d3-%%d5" 160 : "=d" (reg_d0) 161 : "ri" (pos), "ri" (blk), "ri" (id), "ri" (size), "g" ((int) buf) 162 : "%d1", "%d2", "%a1"); 163 164 return reg_d0; 165} 166 167static inline void _scsi_reset (void) 168{ 169 __asm volatile ("movel #0,%%d1\n\t" 170 "movel #0xf5,%%d0\n\t" 171 "trap #15\n\t" 172 : 173 : 174 : "%d0", "%d1"); 175} 176 177#endif 178