sgiarcs.h 15 KB

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