Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * ARC firmware interface defines.
0007  *
0008  * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
0009  * Copyright (C) 1999, 2001 Ralf Baechle (ralf@gnu.org)
0010  * Copyright (C) 1999 Silicon Graphics, Inc.
0011  */
0012 #ifndef _ASM_SGIARCS_H
0013 #define _ASM_SGIARCS_H
0014 
0015 #include <linux/kernel.h>
0016 
0017 #include <asm/types.h>
0018 #include <asm/fw/arc/types.h>
0019 
0020 /* Various ARCS error codes. */
0021 #define PROM_ESUCCESS           0x00
0022 #define PROM_E2BIG          0x01
0023 #define PROM_EACCESS            0x02
0024 #define PROM_EAGAIN         0x03
0025 #define PROM_EBADF          0x04
0026 #define PROM_EBUSY          0x05
0027 #define PROM_EFAULT         0x06
0028 #define PROM_EINVAL         0x07
0029 #define PROM_EIO            0x08
0030 #define PROM_EISDIR         0x09
0031 #define PROM_EMFILE         0x0a
0032 #define PROM_EMLINK         0x0b
0033 #define PROM_ENAMETOOLONG       0x0c
0034 #define PROM_ENODEV         0x0d
0035 #define PROM_ENOENT         0x0e
0036 #define PROM_ENOEXEC            0x0f
0037 #define PROM_ENOMEM         0x10
0038 #define PROM_ENOSPC         0x11
0039 #define PROM_ENOTDIR            0x12
0040 #define PROM_ENOTTY         0x13
0041 #define PROM_ENXIO          0x14
0042 #define PROM_EROFS          0x15
0043 /* SGI ARCS specific errno's. */
0044 #define PROM_EADDRNOTAVAIL      0x1f
0045 #define PROM_ETIMEDOUT          0x20
0046 #define PROM_ECONNABORTED       0x21
0047 #define PROM_ENOCONNECT         0x22
0048 
0049 /* Device classes, types, and identifiers for prom
0050  * device inventory queries.
0051  */
0052 enum linux_devclass {
0053     system, processor, cache, adapter, controller, peripheral, memory
0054 };
0055 
0056 enum linux_devtypes {
0057     /* Generic stuff. */
0058     Arc, Cpu, Fpu,
0059 
0060     /* Primary insn and data caches. */
0061     picache, pdcache,
0062 
0063     /* Secondary insn, data, and combined caches. */
0064     sicache, sdcache, sccache,
0065 
0066     memdev, eisa_adapter, tc_adapter, scsi_adapter, dti_adapter,
0067     multifunc_adapter, dsk_controller, tp_controller, cdrom_controller,
0068     worm_controller, serial_controller, net_controller, disp_controller,
0069     parallel_controller, ptr_controller, kbd_controller, audio_controller,
0070     misc_controller, disk_peripheral, flpy_peripheral, tp_peripheral,
0071     modem_peripheral, monitor_peripheral, printer_peripheral,
0072     ptr_peripheral, kbd_peripheral, term_peripheral, line_peripheral,
0073     net_peripheral, misc_peripheral, anon
0074 };
0075 
0076 enum linux_identifier {
0077     bogus, ronly, removable, consin, consout, input, output
0078 };
0079 
0080 /* A prom device tree component. */
0081 struct linux_component {
0082     enum linux_devclass class;  /* node class */
0083     enum linux_devtypes type;   /* node type */
0084     enum linux_identifier   iflags; /* node flags */
0085     USHORT          vers;   /* node version */
0086     USHORT          rev;    /* node revision */
0087     ULONG           key;    /* completely magic */
0088     ULONG           amask;  /* XXX affinity mask??? */
0089     ULONG           cdsize; /* size of configuration data */
0090     ULONG           ilen;   /* length of string identifier */
0091     _PULONG         iname;  /* string identifier */
0092 };
0093 typedef struct linux_component pcomponent;
0094 
0095 struct linux_sysid {
0096     char vend[8], prod[8];
0097 };
0098 
0099 /* ARCS prom memory descriptors. */
0100 enum arcs_memtypes {
0101     arcs_eblock,  /* exception block */
0102     arcs_rvpage,  /* ARCS romvec page */
0103     arcs_fcontig, /* Contiguous and free */
0104     arcs_free,    /* Generic free memory */
0105     arcs_bmem,    /* Borken memory, don't use */
0106     arcs_prog,    /* A loaded program resides here */
0107     arcs_atmp,    /* ARCS temporary storage area, wish Sparc OpenBoot told this */
0108     arcs_aperm,   /* ARCS permanent storage... */
0109 };
0110 
0111 /* ARC has slightly different types than ARCS */
0112 enum arc_memtypes {
0113     arc_eblock,  /* exception block */
0114     arc_rvpage,  /* romvec page */
0115     arc_free,    /* Generic free memory */
0116     arc_bmem,    /* Borken memory, don't use */
0117     arc_prog,    /* A loaded program resides here */
0118     arc_atmp,    /* temporary storage area */
0119     arc_aperm,   /* permanent storage */
0120     arc_fcontig, /* Contiguous and free */
0121 };
0122 
0123 union linux_memtypes {
0124     enum arcs_memtypes arcs;
0125     enum arc_memtypes arc;
0126 };
0127 
0128 struct linux_mdesc {
0129     union linux_memtypes type;
0130     ULONG base;
0131     ULONG pages;
0132 };
0133 
0134 /* Time of day descriptor. */
0135 struct linux_tinfo {
0136     unsigned short yr;
0137     unsigned short mnth;
0138     unsigned short day;
0139     unsigned short hr;
0140     unsigned short min;
0141     unsigned short sec;
0142     unsigned short msec;
0143 };
0144 
0145 /* ARCS virtual dirents. */
0146 struct linux_vdirent {
0147     ULONG namelen;
0148     unsigned char attr;
0149     char fname[32]; /* XXX empirical, should be a define */
0150 };
0151 
0152 /* Other stuff for files. */
0153 enum linux_omode {
0154     rdonly, wronly, rdwr, wronly_creat, rdwr_creat,
0155     wronly_ssede, rdwr_ssede, dirent, dirent_creat
0156 };
0157 
0158 enum linux_seekmode {
0159     absolute, relative
0160 };
0161 
0162 enum linux_mountops {
0163     media_load, media_unload
0164 };
0165 
0166 /* This prom has a bolixed design. */
0167 struct linux_bigint {
0168 #ifdef __MIPSEL__
0169     u32 lo;
0170     s32 hi;
0171 #else /* !(__MIPSEL__) */
0172     s32 hi;
0173     u32 lo;
0174 #endif
0175 };
0176 
0177 struct linux_finfo {
0178     struct linux_bigint   begin;
0179     struct linux_bigint   end;
0180     struct linux_bigint   cur;
0181     enum linux_devtypes   dtype;
0182     unsigned long         namelen;
0183     unsigned char         attr;
0184     char              name[32]; /* XXX empirical, should be define */
0185 };
0186 
0187 /* This describes the vector containing function pointers to the ARC
0188    firmware functions.  */
0189 struct linux_romvec {
0190     LONG    load;           /* Load an executable image. */
0191     LONG    invoke;         /* Invoke a standalong image. */
0192     LONG    exec;           /* Load and begin execution of a
0193                        standalone image. */
0194     LONG    halt;           /* Halt the machine. */
0195     LONG    pdown;          /* Power down the machine. */
0196     LONG    restart;        /* XXX soft reset??? */
0197     LONG    reboot;         /* Reboot the machine. */
0198     LONG    imode;          /* Enter PROM interactive mode. */
0199     LONG    _unused1;       /* Was ReturnFromMain(). */
0200 
0201     /* PROM device tree interface. */
0202     LONG    next_component;
0203     LONG    child_component;
0204     LONG    parent_component;
0205     LONG    component_data;
0206     LONG    child_add;
0207     LONG    comp_del;
0208     LONG    component_by_path;
0209 
0210     /* Misc. stuff. */
0211     LONG    cfg_save;
0212     LONG    get_sysid;
0213 
0214     /* Probing for memory. */
0215     LONG    get_mdesc;
0216     LONG    _unused2;       /* was Signal() */
0217 
0218     LONG    get_tinfo;
0219     LONG    get_rtime;
0220 
0221     /* File type operations. */
0222     LONG    get_vdirent;
0223     LONG    open;
0224     LONG    close;
0225     LONG    read;
0226     LONG    get_rstatus;
0227     LONG    write;
0228     LONG    seek;
0229     LONG    mount;
0230 
0231     /* Dealing with firmware environment variables. */
0232     LONG    get_evar;
0233     LONG    set_evar;
0234 
0235     LONG    get_finfo;
0236     LONG    set_finfo;
0237 
0238     /* Miscellaneous. */
0239     LONG    cache_flush;
0240     LONG    TestUnicodeCharacter;       /* ARC; not sure if ARCS too */
0241     LONG    GetDisplayStatus;
0242 };
0243 
0244 /* The SGI ARCS parameter block is in a fixed location for standalone
0245  * programs to access PROM facilities easily.
0246  */
0247 typedef struct _SYSTEM_PARAMETER_BLOCK {
0248     ULONG           magic;      /* magic cookie */
0249 #define PROMBLOCK_MAGIC      0x53435241
0250 
0251     ULONG           len;        /* length of parm block */
0252     USHORT          ver;        /* ARCS firmware version */
0253     USHORT          rev;        /* ARCS firmware revision */
0254     _PLONG          rs_block;   /* Restart block. */
0255     _PLONG          dbg_block;  /* Debug block. */
0256     _PLONG          gevect;     /* XXX General vector??? */
0257     _PLONG          utlbvect;   /* XXX UTLB vector??? */
0258     ULONG           rveclen;    /* Size of romvec struct. */
0259     _PVOID          romvec;     /* Function interface. */
0260     ULONG           pveclen;    /* Length of private vector. */
0261     _PVOID          pvector;    /* Private vector. */
0262     ULONG           adap_cnt;   /* Adapter count. */
0263     ULONG           adap_typ0;  /* First adapter type. */
0264     ULONG           adap_vcnt0; /* Adapter 0 vector count. */
0265     _PVOID          adap_vector;    /* Adapter 0 vector ptr. */
0266     ULONG           adap_typ1;  /* Second adapter type. */
0267     ULONG           adap_vcnt1; /* Adapter 1 vector count. */
0268     _PVOID          adap_vector1;   /* Adapter 1 vector ptr. */
0269     /* More adapter vectors go here... */
0270 } SYSTEM_PARAMETER_BLOCK, *PSYSTEM_PARAMETER_BLOCK;
0271 
0272 #define PROMBLOCK ((PSYSTEM_PARAMETER_BLOCK) (int)0xA0001000)
0273 #define ROMVECTOR ((struct linux_romvec *) (long)(PROMBLOCK)->romvec)
0274 
0275 /* Cache layout parameter block. */
0276 union linux_cache_key {
0277     struct param {
0278 #ifdef __MIPSEL__
0279         unsigned short size;
0280         unsigned char lsize;
0281         unsigned char bsize;
0282 #else /* !(__MIPSEL__) */
0283         unsigned char bsize;
0284         unsigned char lsize;
0285         unsigned short size;
0286 #endif
0287     } info;
0288     unsigned long allinfo;
0289 };
0290 
0291 /* Configuration data. */
0292 struct linux_cdata {
0293     char *name;
0294     int mlen;
0295     enum linux_devtypes type;
0296 };
0297 
0298 /* Common SGI ARCS firmware file descriptors. */
0299 #define SGIPROM_STDIN     0
0300 #define SGIPROM_STDOUT    1
0301 
0302 /* Common SGI ARCS firmware file types. */
0303 #define SGIPROM_ROFILE    0x01  /* read-only file */
0304 #define SGIPROM_HFILE     0x02  /* hidden file */
0305 #define SGIPROM_SFILE     0x04  /* System file */
0306 #define SGIPROM_AFILE     0x08  /* Archive file */
0307 #define SGIPROM_DFILE     0x10  /* Directory file */
0308 #define SGIPROM_DELFILE   0x20  /* Deleted file */
0309 
0310 /* SGI ARCS boot record information. */
0311 struct sgi_partition {
0312     unsigned char flag;
0313 #define SGIPART_UNUSED 0x00
0314 #define SGIPART_ACTIVE 0x80
0315 
0316     unsigned char shead, ssect, scyl; /* unused */
0317     unsigned char systype; /* OS type, Irix or NT */
0318     unsigned char ehead, esect, ecyl; /* unused */
0319     unsigned char rsect0, rsect1, rsect2, rsect3;
0320     unsigned char tsect0, tsect1, tsect2, tsect3;
0321 };
0322 
0323 #define SGIBBLOCK_MAGIC   0xaa55
0324 #define SGIBBLOCK_MAXPART 0x0004
0325 
0326 struct sgi_bootblock {
0327     unsigned char _unused[446];
0328     struct sgi_partition partitions[SGIBBLOCK_MAXPART];
0329     unsigned short magic;
0330 };
0331 
0332 /* BIOS parameter block. */
0333 struct sgi_bparm_block {
0334     unsigned short bytes_sect;    /* bytes per sector */
0335     unsigned char  sect_clust;    /* sectors per cluster */
0336     unsigned short sect_resv;     /* reserved sectors */
0337     unsigned char  nfats;         /* # of allocation tables */
0338     unsigned short nroot_dirents; /* # of root directory entries */
0339     unsigned short sect_volume;   /* sectors in volume */
0340     unsigned char  media_type;    /* media descriptor */
0341     unsigned short sect_fat;      /* sectors per allocation table */
0342     unsigned short sect_track;    /* sectors per track */
0343     unsigned short nheads;        /* # of heads */
0344     unsigned short nhsects;       /* # of hidden sectors */
0345 };
0346 
0347 struct sgi_bsector {
0348     unsigned char   jmpinfo[3];
0349     unsigned char   manuf_name[8];
0350     struct sgi_bparm_block info;
0351 };
0352 
0353 /* Debugging block used with SGI symmon symbolic debugger. */
0354 #define SMB_DEBUG_MAGIC   0xfeeddead
0355 struct linux_smonblock {
0356     unsigned long   magic;
0357     void        (*handler)(void);  /* Breakpoint routine. */
0358     unsigned long   dtable_base;       /* Base addr of dbg table. */
0359     int     (*printf)(const char *fmt, ...);
0360     unsigned long   btable_base;       /* Breakpoint table. */
0361     unsigned long   mpflushreqs;       /* SMP cache flush request list. */
0362     unsigned long   ntab;          /* Name table. */
0363     unsigned long   stab;          /* Symbol table. */
0364     int     smax;          /* Max # of symbols. */
0365 };
0366 
0367 /*
0368  * Macros for calling a 32-bit ARC implementation from 64-bit code
0369  */
0370 
0371 #if defined(CONFIG_64BIT) && defined(CONFIG_FW_ARC32)
0372 
0373 extern long call_o32(long vec, void *stack, ...);
0374 
0375 extern u64 o32_stk[4096];
0376 #define O32_STK (&o32_stk[ARRAY_SIZE(o32_stk)])
0377 
0378 #define ARC_CALL0(dest)                         \
0379 ({  long __res;                         \
0380     long __vec = (long) romvec->dest;               \
0381     __res = call_o32(__vec, O32_STK);               \
0382     __res;                              \
0383 })
0384 
0385 #define ARC_CALL1(dest, a1)                     \
0386 ({  long __res;                         \
0387     int  __a1 = (int) (long) (a1);                  \
0388     long __vec = (long) romvec->dest;               \
0389     __res = call_o32(__vec, O32_STK, __a1);             \
0390     __res;                              \
0391 })
0392 
0393 #define ARC_CALL2(dest, a1, a2)                     \
0394 ({  long __res;                         \
0395     int  __a1 = (int) (long) (a1);                  \
0396     int  __a2 = (int) (long) (a2);                  \
0397     long __vec = (long) romvec->dest;               \
0398     __res = call_o32(__vec, O32_STK, __a1, __a2);           \
0399     __res;                              \
0400 })
0401 
0402 #define ARC_CALL3(dest, a1, a2, a3)                 \
0403 ({  long __res;                         \
0404     int  __a1 = (int) (long) (a1);                  \
0405     int  __a2 = (int) (long) (a2);                  \
0406     int  __a3 = (int) (long) (a3);                  \
0407     long __vec = (long) romvec->dest;               \
0408     __res = call_o32(__vec, O32_STK, __a1, __a2, __a3);     \
0409     __res;                              \
0410 })
0411 
0412 #define ARC_CALL4(dest, a1, a2, a3, a4)                 \
0413 ({  long __res;                         \
0414     int  __a1 = (int) (long) (a1);                  \
0415     int  __a2 = (int) (long) (a2);                  \
0416     int  __a3 = (int) (long) (a3);                  \
0417     int  __a4 = (int) (long) (a4);                  \
0418     long __vec = (long) romvec->dest;               \
0419     __res = call_o32(__vec, O32_STK, __a1, __a2, __a3, __a4);   \
0420     __res;                              \
0421 })
0422 
0423 #define ARC_CALL5(dest, a1, a2, a3, a4, a5)             \
0424 ({  long __res;                         \
0425     int  __a1 = (int) (long) (a1);                  \
0426     int  __a2 = (int) (long) (a2);                  \
0427     int  __a3 = (int) (long) (a3);                  \
0428     int  __a4 = (int) (long) (a4);                  \
0429     int  __a5 = (int) (long) (a5);                  \
0430     long __vec = (long) romvec->dest;               \
0431     __res = call_o32(__vec, O32_STK, __a1, __a2, __a3, __a4, __a5); \
0432     __res;                              \
0433 })
0434 
0435 #endif /* defined(CONFIG_64BIT) && defined(CONFIG_FW_ARC32) */
0436 
0437 #if (defined(CONFIG_32BIT) && defined(CONFIG_FW_ARC32)) ||      \
0438     (defined(CONFIG_64BIT) && defined(CONFIG_FW_ARC64))
0439 
0440 #define ARC_CALL0(dest)                         \
0441 ({  long __res;                         \
0442     long (*__vec)(void) = (void *) romvec->dest;            \
0443                                     \
0444     __res = __vec();                        \
0445     __res;                              \
0446 })
0447 
0448 #define ARC_CALL1(dest, a1)                     \
0449 ({  long __res;                         \
0450     long __a1 = (long) (a1);                    \
0451     long (*__vec)(long) = (void *) romvec->dest;            \
0452                                     \
0453     __res = __vec(__a1);                        \
0454     __res;                              \
0455 })
0456 
0457 #define ARC_CALL2(dest, a1, a2)                     \
0458 ({  long __res;                         \
0459     long __a1 = (long) (a1);                    \
0460     long __a2 = (long) (a2);                    \
0461     long (*__vec)(long, long) = (void *) romvec->dest;      \
0462                                     \
0463     __res = __vec(__a1, __a2);                  \
0464     __res;                              \
0465 })
0466 
0467 #define ARC_CALL3(dest, a1, a2, a3)                 \
0468 ({  long __res;                         \
0469     long __a1 = (long) (a1);                    \
0470     long __a2 = (long) (a2);                    \
0471     long __a3 = (long) (a3);                    \
0472     long (*__vec)(long, long, long) = (void *) romvec->dest;    \
0473                                     \
0474     __res = __vec(__a1, __a2, __a3);                \
0475     __res;                              \
0476 })
0477 
0478 #define ARC_CALL4(dest, a1, a2, a3, a4)                 \
0479 ({  long __res;                         \
0480     long __a1 = (long) (a1);                    \
0481     long __a2 = (long) (a2);                    \
0482     long __a3 = (long) (a3);                    \
0483     long __a4 = (long) (a4);                    \
0484     long (*__vec)(long, long, long, long) = (void *) romvec->dest;  \
0485                                     \
0486     __res = __vec(__a1, __a2, __a3, __a4);              \
0487     __res;                              \
0488 })
0489 
0490 #define ARC_CALL5(dest, a1, a2, a3, a4, a5)             \
0491 ({  long __res;                         \
0492     long __a1 = (long) (a1);                    \
0493     long __a2 = (long) (a2);                    \
0494     long __a3 = (long) (a3);                    \
0495     long __a4 = (long) (a4);                    \
0496     long __a5 = (long) (a5);                    \
0497     long (*__vec)(long, long, long, long, long);            \
0498     __vec = (void *) romvec->dest;                  \
0499                                     \
0500     __res = __vec(__a1, __a2, __a3, __a4, __a5);            \
0501     __res;                              \
0502 })
0503 #endif /* both kernel and ARC either 32-bit or 64-bit */
0504 
0505 #endif /* _ASM_SGIARCS_H */