sgiarcs.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * ARC firmware interface defines.
  7. *
  8. * Copyright (C) 1996 David S. Miller ([email protected])
  9. * Copyright (C) 1999, 2001 Ralf Baechle ([email protected])
  10. * Copyright (C) 1999 Silicon Graphics, Inc.
  11. */
  12. #ifndef _ASM_SGIARCS_H
  13. #define _ASM_SGIARCS_H
  14. #include <linux/kernel.h>
  15. #include <asm/types.h>
  16. #include <asm/fw/arc/types.h>
  17. /* Various ARCS error codes. */
  18. #define PROM_ESUCCESS 0x00
  19. #define PROM_E2BIG 0x01
  20. #define PROM_EACCESS 0x02
  21. #define PROM_EAGAIN 0x03
  22. #define PROM_EBADF 0x04
  23. #define PROM_EBUSY 0x05
  24. #define PROM_EFAULT 0x06
  25. #define PROM_EINVAL 0x07
  26. #define PROM_EIO 0x08
  27. #define PROM_EISDIR 0x09
  28. #define PROM_EMFILE 0x0a
  29. #define PROM_EMLINK 0x0b
  30. #define PROM_ENAMETOOLONG 0x0c
  31. #define PROM_ENODEV 0x0d
  32. #define PROM_ENOENT 0x0e
  33. #define PROM_ENOEXEC 0x0f
  34. #define PROM_ENOMEM 0x10
  35. #define PROM_ENOSPC 0x11
  36. #define PROM_ENOTDIR 0x12
  37. #define PROM_ENOTTY 0x13
  38. #define PROM_ENXIO 0x14
  39. #define PROM_EROFS 0x15
  40. /* SGI ARCS specific errno's. */
  41. #define PROM_EADDRNOTAVAIL 0x1f
  42. #define PROM_ETIMEDOUT 0x20
  43. #define PROM_ECONNABORTED 0x21
  44. #define PROM_ENOCONNECT 0x22
  45. /* Device classes, types, and identifiers for prom
  46. * device inventory queries.
  47. */
  48. enum linux_devclass {
  49. system, processor, cache, adapter, controller, peripheral, memory
  50. };
  51. enum linux_devtypes {
  52. /* Generic stuff. */
  53. Arc, Cpu, Fpu,
  54. /* Primary insn and data caches. */
  55. picache, pdcache,
  56. /* Secondary insn, data, and combined caches. */
  57. sicache, sdcache, sccache,
  58. memdev, eisa_adapter, tc_adapter, scsi_adapter, dti_adapter,
  59. multifunc_adapter, dsk_controller, tp_controller, cdrom_controller,
  60. worm_controller, serial_controller, net_controller, disp_controller,
  61. parallel_controller, ptr_controller, kbd_controller, audio_controller,
  62. misc_controller, disk_peripheral, flpy_peripheral, tp_peripheral,
  63. modem_peripheral, monitor_peripheral, printer_peripheral,
  64. ptr_peripheral, kbd_peripheral, term_peripheral, line_peripheral,
  65. net_peripheral, misc_peripheral, anon
  66. };
  67. enum linux_identifier {
  68. bogus, ronly, removable, consin, consout, input, output
  69. };
  70. /* A prom device tree component. */
  71. struct linux_component {
  72. enum linux_devclass class; /* node class */
  73. enum linux_devtypes type; /* node type */
  74. enum linux_identifier iflags; /* node flags */
  75. USHORT vers; /* node version */
  76. USHORT rev; /* node revision */
  77. ULONG key; /* completely magic */
  78. ULONG amask; /* XXX affinity mask??? */
  79. ULONG cdsize; /* size of configuration data */
  80. ULONG ilen; /* length of string identifier */
  81. _PULONG iname; /* string identifier */
  82. };
  83. typedef struct linux_component pcomponent;
  84. struct linux_sysid {
  85. char vend[8], prod[8];
  86. };
  87. /* ARCS prom memory descriptors. */
  88. enum arcs_memtypes {
  89. arcs_eblock, /* exception block */
  90. arcs_rvpage, /* ARCS romvec page */
  91. arcs_fcontig, /* Contiguous and free */
  92. arcs_free, /* Generic free memory */
  93. arcs_bmem, /* Borken memory, don't use */
  94. arcs_prog, /* A loaded program resides here */
  95. arcs_atmp, /* ARCS temporary storage area, wish Sparc OpenBoot told this */
  96. arcs_aperm, /* ARCS permanent storage... */
  97. };
  98. /* ARC has slightly different types than ARCS */
  99. enum arc_memtypes {
  100. arc_eblock, /* exception block */
  101. arc_rvpage, /* romvec page */
  102. arc_free, /* Generic free memory */
  103. arc_bmem, /* Borken memory, don't use */
  104. arc_prog, /* A loaded program resides here */
  105. arc_atmp, /* temporary storage area */
  106. arc_aperm, /* permanent storage */
  107. arc_fcontig, /* Contiguous and free */
  108. };
  109. union linux_memtypes {
  110. enum arcs_memtypes arcs;
  111. enum arc_memtypes arc;
  112. };
  113. struct linux_mdesc {
  114. union linux_memtypes type;
  115. ULONG base;
  116. ULONG pages;
  117. };
  118. /* Time of day descriptor. */
  119. struct linux_tinfo {
  120. unsigned short yr;
  121. unsigned short mnth;
  122. unsigned short day;
  123. unsigned short hr;
  124. unsigned short min;
  125. unsigned short sec;
  126. unsigned short msec;
  127. };
  128. /* ARCS virtual dirents. */
  129. struct linux_vdirent {
  130. ULONG namelen;
  131. unsigned char attr;
  132. char fname[32]; /* XXX empirical, should be a define */
  133. };
  134. /* Other stuff for files. */
  135. enum linux_omode {
  136. rdonly, wronly, rdwr, wronly_creat, rdwr_creat,
  137. wronly_ssede, rdwr_ssede, dirent, dirent_creat
  138. };
  139. enum linux_seekmode {
  140. absolute, relative
  141. };
  142. enum linux_mountops {
  143. media_load, media_unload
  144. };
  145. /* This prom has a bolixed design. */
  146. struct linux_bigint {
  147. #ifdef __MIPSEL__
  148. u32 lo;
  149. s32 hi;
  150. #else /* !(__MIPSEL__) */
  151. s32 hi;
  152. u32 lo;
  153. #endif
  154. };
  155. struct linux_finfo {
  156. struct linux_bigint begin;
  157. struct linux_bigint end;
  158. struct linux_bigint cur;
  159. enum linux_devtypes dtype;
  160. unsigned long namelen;
  161. unsigned char attr;
  162. char name[32]; /* XXX empirical, should be define */
  163. };
  164. /* This describes the vector containing function pointers to the ARC
  165. firmware functions. */
  166. struct linux_romvec {
  167. LONG load; /* Load an executable image. */
  168. LONG invoke; /* Invoke a standalong image. */
  169. LONG exec; /* Load and begin execution of a
  170. standalone image. */
  171. LONG halt; /* Halt the machine. */
  172. LONG pdown; /* Power down the machine. */
  173. LONG restart; /* XXX soft reset??? */
  174. LONG reboot; /* Reboot the machine. */
  175. LONG imode; /* Enter PROM interactive mode. */
  176. LONG _unused1; /* Was ReturnFromMain(). */
  177. /* PROM device tree interface. */
  178. LONG next_component;
  179. LONG child_component;
  180. LONG parent_component;
  181. LONG component_data;
  182. LONG child_add;
  183. LONG comp_del;
  184. LONG component_by_path;
  185. /* Misc. stuff. */
  186. LONG cfg_save;
  187. LONG get_sysid;
  188. /* Probing for memory. */
  189. LONG get_mdesc;
  190. LONG _unused2; /* was Signal() */
  191. LONG get_tinfo;
  192. LONG get_rtime;
  193. /* File type operations. */
  194. LONG get_vdirent;
  195. LONG open;
  196. LONG close;
  197. LONG read;
  198. LONG get_rstatus;
  199. LONG write;
  200. LONG seek;
  201. LONG mount;
  202. /* Dealing with firmware environment variables. */
  203. LONG get_evar;
  204. LONG set_evar;
  205. LONG get_finfo;
  206. LONG set_finfo;
  207. /* Miscellaneous. */
  208. LONG cache_flush;
  209. LONG TestUnicodeCharacter; /* ARC; not sure if ARCS too */
  210. LONG GetDisplayStatus;
  211. };
  212. /* The SGI ARCS parameter block is in a fixed location for standalone
  213. * programs to access PROM facilities easily.
  214. */
  215. typedef struct _SYSTEM_PARAMETER_BLOCK {
  216. ULONG magic; /* magic cookie */
  217. #define PROMBLOCK_MAGIC 0x53435241
  218. ULONG len; /* length of parm block */
  219. USHORT ver; /* ARCS firmware version */
  220. USHORT rev; /* ARCS firmware revision */
  221. _PLONG rs_block; /* Restart block. */
  222. _PLONG dbg_block; /* Debug block. */
  223. _PLONG gevect; /* XXX General vector??? */
  224. _PLONG utlbvect; /* XXX UTLB vector??? */
  225. ULONG rveclen; /* Size of romvec struct. */
  226. _PVOID romvec; /* Function interface. */
  227. ULONG pveclen; /* Length of private vector. */
  228. _PVOID pvector; /* Private vector. */
  229. ULONG adap_cnt; /* Adapter count. */
  230. ULONG adap_typ0; /* First adapter type. */
  231. ULONG adap_vcnt0; /* Adapter 0 vector count. */
  232. _PVOID adap_vector; /* Adapter 0 vector ptr. */
  233. ULONG adap_typ1; /* Second adapter type. */
  234. ULONG adap_vcnt1; /* Adapter 1 vector count. */
  235. _PVOID adap_vector1; /* Adapter 1 vector ptr. */
  236. /* More adapter vectors go here... */
  237. } SYSTEM_PARAMETER_BLOCK, *PSYSTEM_PARAMETER_BLOCK;
  238. #define PROMBLOCK ((PSYSTEM_PARAMETER_BLOCK) (int)0xA0001000)
  239. #define ROMVECTOR ((struct linux_romvec *) (long)(PROMBLOCK)->romvec)
  240. /* Cache layout parameter block. */
  241. union linux_cache_key {
  242. struct param {
  243. #ifdef __MIPSEL__
  244. unsigned short size;
  245. unsigned char lsize;
  246. unsigned char bsize;
  247. #else /* !(__MIPSEL__) */
  248. unsigned char bsize;
  249. unsigned char lsize;
  250. unsigned short size;
  251. #endif
  252. } info;
  253. unsigned long allinfo;
  254. };
  255. /* Configuration data. */
  256. struct linux_cdata {
  257. char *name;
  258. int mlen;
  259. enum linux_devtypes type;
  260. };
  261. /* Common SGI ARCS firmware file descriptors. */
  262. #define SGIPROM_STDIN 0
  263. #define SGIPROM_STDOUT 1
  264. /* Common SGI ARCS firmware file types. */
  265. #define SGIPROM_ROFILE 0x01 /* read-only file */
  266. #define SGIPROM_HFILE 0x02 /* hidden file */
  267. #define SGIPROM_SFILE 0x04 /* System file */
  268. #define SGIPROM_AFILE 0x08 /* Archive file */
  269. #define SGIPROM_DFILE 0x10 /* Directory file */
  270. #define SGIPROM_DELFILE 0x20 /* Deleted file */
  271. /* SGI ARCS boot record information. */
  272. struct sgi_partition {
  273. unsigned char flag;
  274. #define SGIPART_UNUSED 0x00
  275. #define SGIPART_ACTIVE 0x80
  276. unsigned char shead, ssect, scyl; /* unused */
  277. unsigned char systype; /* OS type, Irix or NT */
  278. unsigned char ehead, esect, ecyl; /* unused */
  279. unsigned char rsect0, rsect1, rsect2, rsect3;
  280. unsigned char tsect0, tsect1, tsect2, tsect3;
  281. };
  282. #define SGIBBLOCK_MAGIC 0xaa55
  283. #define SGIBBLOCK_MAXPART 0x0004
  284. struct sgi_bootblock {
  285. unsigned char _unused[446];
  286. struct sgi_partition partitions[SGIBBLOCK_MAXPART];
  287. unsigned short magic;
  288. };
  289. /* BIOS parameter block. */
  290. struct sgi_bparm_block {
  291. unsigned short bytes_sect; /* bytes per sector */
  292. unsigned char sect_clust; /* sectors per cluster */
  293. unsigned short sect_resv; /* reserved sectors */
  294. unsigned char nfats; /* # of allocation tables */
  295. unsigned short nroot_dirents; /* # of root directory entries */
  296. unsigned short sect_volume; /* sectors in volume */
  297. unsigned char media_type; /* media descriptor */
  298. unsigned short sect_fat; /* sectors per allocation table */
  299. unsigned short sect_track; /* sectors per track */
  300. unsigned short nheads; /* # of heads */
  301. unsigned short nhsects; /* # of hidden sectors */
  302. };
  303. struct sgi_bsector {
  304. unsigned char jmpinfo[3];
  305. unsigned char manuf_name[8];
  306. struct sgi_bparm_block info;
  307. };
  308. /* Debugging block used with SGI symmon symbolic debugger. */
  309. #define SMB_DEBUG_MAGIC 0xfeeddead
  310. struct linux_smonblock {
  311. unsigned long magic;
  312. void (*handler)(void); /* Breakpoint routine. */
  313. unsigned long dtable_base; /* Base addr of dbg table. */
  314. int (*printf)(const char *fmt, ...);
  315. unsigned long btable_base; /* Breakpoint table. */
  316. unsigned long mpflushreqs; /* SMP cache flush request list. */
  317. unsigned long ntab; /* Name table. */
  318. unsigned long stab; /* Symbol table. */
  319. int smax; /* Max # of symbols. */
  320. };
  321. /*
  322. * Macros for calling a 32-bit ARC implementation from 64-bit code
  323. */
  324. #if defined(CONFIG_64BIT) && defined(CONFIG_FW_ARC32)
  325. extern long call_o32(long vec, void *stack, ...);
  326. extern u64 o32_stk[4096];
  327. #define O32_STK (&o32_stk[ARRAY_SIZE(o32_stk)])
  328. #define ARC_CALL0(dest) \
  329. ({ long __res; \
  330. long __vec = (long) romvec->dest; \
  331. __res = call_o32(__vec, O32_STK); \
  332. __res; \
  333. })
  334. #define ARC_CALL1(dest, a1) \
  335. ({ long __res; \
  336. int __a1 = (int) (long) (a1); \
  337. long __vec = (long) romvec->dest; \
  338. __res = call_o32(__vec, O32_STK, __a1); \
  339. __res; \
  340. })
  341. #define ARC_CALL2(dest, a1, a2) \
  342. ({ long __res; \
  343. int __a1 = (int) (long) (a1); \
  344. int __a2 = (int) (long) (a2); \
  345. long __vec = (long) romvec->dest; \
  346. __res = call_o32(__vec, O32_STK, __a1, __a2); \
  347. __res; \
  348. })
  349. #define ARC_CALL3(dest, a1, a2, a3) \
  350. ({ long __res; \
  351. int __a1 = (int) (long) (a1); \
  352. int __a2 = (int) (long) (a2); \
  353. int __a3 = (int) (long) (a3); \
  354. long __vec = (long) romvec->dest; \
  355. __res = call_o32(__vec, O32_STK, __a1, __a2, __a3); \
  356. __res; \
  357. })
  358. #define ARC_CALL4(dest, a1, a2, a3, a4) \
  359. ({ long __res; \
  360. int __a1 = (int) (long) (a1); \
  361. int __a2 = (int) (long) (a2); \
  362. int __a3 = (int) (long) (a3); \
  363. int __a4 = (int) (long) (a4); \
  364. long __vec = (long) romvec->dest; \
  365. __res = call_o32(__vec, O32_STK, __a1, __a2, __a3, __a4); \
  366. __res; \
  367. })
  368. #define ARC_CALL5(dest, a1, a2, a3, a4, a5) \
  369. ({ long __res; \
  370. int __a1 = (int) (long) (a1); \
  371. int __a2 = (int) (long) (a2); \
  372. int __a3 = (int) (long) (a3); \
  373. int __a4 = (int) (long) (a4); \
  374. int __a5 = (int) (long) (a5); \
  375. long __vec = (long) romvec->dest; \
  376. __res = call_o32(__vec, O32_STK, __a1, __a2, __a3, __a4, __a5); \
  377. __res; \
  378. })
  379. #endif /* defined(CONFIG_64BIT) && defined(CONFIG_FW_ARC32) */
  380. #if (defined(CONFIG_32BIT) && defined(CONFIG_FW_ARC32)) || \
  381. (defined(CONFIG_64BIT) && defined(CONFIG_FW_ARC64))
  382. #define ARC_CALL0(dest) \
  383. ({ long __res; \
  384. long (*__vec)(void) = (void *) romvec->dest; \
  385. \
  386. __res = __vec(); \
  387. __res; \
  388. })
  389. #define ARC_CALL1(dest, a1) \
  390. ({ long __res; \
  391. long __a1 = (long) (a1); \
  392. long (*__vec)(long) = (void *) romvec->dest; \
  393. \
  394. __res = __vec(__a1); \
  395. __res; \
  396. })
  397. #define ARC_CALL2(dest, a1, a2) \
  398. ({ long __res; \
  399. long __a1 = (long) (a1); \
  400. long __a2 = (long) (a2); \
  401. long (*__vec)(long, long) = (void *) romvec->dest; \
  402. \
  403. __res = __vec(__a1, __a2); \
  404. __res; \
  405. })
  406. #define ARC_CALL3(dest, a1, a2, a3) \
  407. ({ long __res; \
  408. long __a1 = (long) (a1); \
  409. long __a2 = (long) (a2); \
  410. long __a3 = (long) (a3); \
  411. long (*__vec)(long, long, long) = (void *) romvec->dest; \
  412. \
  413. __res = __vec(__a1, __a2, __a3); \
  414. __res; \
  415. })
  416. #define ARC_CALL4(dest, a1, a2, a3, a4) \
  417. ({ long __res; \
  418. long __a1 = (long) (a1); \
  419. long __a2 = (long) (a2); \
  420. long __a3 = (long) (a3); \
  421. long __a4 = (long) (a4); \
  422. long (*__vec)(long, long, long, long) = (void *) romvec->dest; \
  423. \
  424. __res = __vec(__a1, __a2, __a3, __a4); \
  425. __res; \
  426. })
  427. #define ARC_CALL5(dest, a1, a2, a3, a4, a5) \
  428. ({ long __res; \
  429. long __a1 = (long) (a1); \
  430. long __a2 = (long) (a2); \
  431. long __a3 = (long) (a3); \
  432. long __a4 = (long) (a4); \
  433. long __a5 = (long) (a5); \
  434. long (*__vec)(long, long, long, long, long); \
  435. __vec = (void *) romvec->dest; \
  436. \
  437. __res = __vec(__a1, __a2, __a3, __a4, __a5); \
  438. __res; \
  439. })
  440. #endif /* both kernel and ARC either 32-bit or 64-bit */
  441. #endif /* _ASM_SGIARCS_H */