vaseboot/include/VasEBoot/arc/arc.h

285 lines
8.5 KiB
C

/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2011 Free Software Foundation, Inc.
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VAS_EBOOT_ARC_HEADER
#define VAS_EBOOT_ARC_HEADER 1
#include <VasEBoot/types.h>
#include <VasEBoot/symbol.h>
typedef unsigned VasEBoot_arc_enum_t;
typedef VasEBoot_uint64_t VasEBoot_arc_ularge_t;
typedef unsigned long VasEBoot_arc_ulong_t;
typedef long VasEBoot_arc_long_t;
typedef unsigned short VasEBoot_arc_ushort_t;
typedef unsigned char VasEBoot_arc_uchar_t;
typedef VasEBoot_arc_long_t VasEBoot_arc_err_t;
typedef VasEBoot_arc_ulong_t VasEBoot_arc_fileno_t;
struct VasEBoot_arc_memory_descriptor
{
VasEBoot_arc_enum_t type;
VasEBoot_arc_ulong_t start_page;
VasEBoot_arc_ulong_t num_pages;
};
enum VasEBoot_arc_memory_type
{
VAS_EBOOT_ARC_MEMORY_EXCEPTION_BLOCK,
VAS_EBOOT_ARC_MEMORY_SYSTEM_PARAMETER_BLOCK,
#ifdef VAS_EBOOT_CPU_WORDS_BIGENDIAN
VAS_EBOOT_ARC_MEMORY_FREE_CONTIGUOUS,
#endif
VAS_EBOOT_ARC_MEMORY_FREE,
VAS_EBOOT_ARC_MEMORY_BADRAM,
VAS_EBOOT_ARC_MEMORY_LOADED, VAS_EBOOT_ARC_MEMORY_FW_TEMPORARY,
VAS_EBOOT_ARC_MEMORY_FW_PERMANENT,
#ifndef VAS_EBOOT_CPU_WORDS_BIGENDIAN
VAS_EBOOT_ARC_MEMORY_FREE_CONTIGUOUS,
#endif
};
struct VasEBoot_arc_timeinfo
{
VasEBoot_arc_ushort_t y;
VasEBoot_arc_ushort_t m;
VasEBoot_arc_ushort_t d;
VasEBoot_arc_ushort_t h;
VasEBoot_arc_ushort_t min;
VasEBoot_arc_ushort_t s;
VasEBoot_arc_ushort_t ms;
};
struct VasEBoot_arc_display_status
{
VasEBoot_arc_ushort_t x;
VasEBoot_arc_ushort_t y;
VasEBoot_arc_ushort_t w;
VasEBoot_arc_ushort_t h;
VasEBoot_arc_uchar_t fgcolor;
VasEBoot_arc_uchar_t bgcolor;
VasEBoot_arc_uchar_t high_intensity;
VasEBoot_arc_uchar_t underscored;
VasEBoot_arc_uchar_t reverse_video;
};
enum
{
VAS_EBOOT_ARC_COMPONENT_FLAG_OUT = 0x40,
VAS_EBOOT_ARC_COMPONENT_FLAG_IN = 0x20,
};
struct VasEBoot_arc_component
{
VasEBoot_arc_enum_t class;
VasEBoot_arc_enum_t type;
VasEBoot_arc_enum_t flags;
VasEBoot_arc_ushort_t version;
VasEBoot_arc_ushort_t rev;
VasEBoot_arc_ulong_t key;
VasEBoot_arc_ulong_t affinity;
VasEBoot_arc_ulong_t configdatasize;
VasEBoot_arc_ulong_t idlen;
const char *idstr;
};
enum
{
#ifdef VAS_EBOOT_CPU_WORDS_BIGENDIAN
VAS_EBOOT_ARC_COMPONENT_TYPE_ARC = 1,
#else
VAS_EBOOT_ARC_COMPONENT_TYPE_ARC,
#endif
VAS_EBOOT_ARC_COMPONENT_TYPE_CPU,
VAS_EBOOT_ARC_COMPONENT_TYPE_FPU,
VAS_EBOOT_ARC_COMPONENT_TYPE_PRI_I_CACHE,
VAS_EBOOT_ARC_COMPONENT_TYPE_PRI_D_CACHE,
VAS_EBOOT_ARC_COMPONENT_TYPE_SEC_I_CACHE,
VAS_EBOOT_ARC_COMPONENT_TYPE_SEC_D_CACHE,
VAS_EBOOT_ARC_COMPONENT_TYPE_SEC_CACHE,
VAS_EBOOT_ARC_COMPONENT_TYPE_EISA,
VAS_EBOOT_ARC_COMPONENT_TYPE_TCA,
VAS_EBOOT_ARC_COMPONENT_TYPE_SCSI,
VAS_EBOOT_ARC_COMPONENT_TYPE_DTIA,
VAS_EBOOT_ARC_COMPONENT_TYPE_MULTIFUNC,
VAS_EBOOT_ARC_COMPONENT_TYPE_DISK_CONTROLLER,
VAS_EBOOT_ARC_COMPONENT_TYPE_TAPE_CONTROLLER,
VAS_EBOOT_ARC_COMPONENT_TYPE_CDROM_CONTROLLER,
VAS_EBOOT_ARC_COMPONENT_TYPE_WORM_CONTROLLER,
VAS_EBOOT_ARC_COMPONENT_TYPE_SERIAL_CONTROLLER,
VAS_EBOOT_ARC_COMPONENT_TYPE_NET_CONTROLLER,
VAS_EBOOT_ARC_COMPONENT_TYPE_DISPLAY_CONTROLLER,
VAS_EBOOT_ARC_COMPONENT_TYPE_PARALLEL_CONTROLLER,
VAS_EBOOT_ARC_COMPONENT_TYPE_POINTER_CONTROLLER,
VAS_EBOOT_ARC_COMPONENT_TYPE_KBD_CONTROLLER,
VAS_EBOOT_ARC_COMPONENT_TYPE_AUDIO_CONTROLLER,
VAS_EBOOT_ARC_COMPONENT_TYPE_OTHER_CONTROLLER,
VAS_EBOOT_ARC_COMPONENT_TYPE_DISK,
VAS_EBOOT_ARC_COMPONENT_TYPE_FLOPPY,
VAS_EBOOT_ARC_COMPONENT_TYPE_TAPE,
VAS_EBOOT_ARC_COMPONENT_TYPE_MODEM,
VAS_EBOOT_ARC_COMPONENT_TYPE_MONITOR,
VAS_EBOOT_ARC_COMPONENT_TYPE_PRINTER,
VAS_EBOOT_ARC_COMPONENT_TYPE_POINTER,
VAS_EBOOT_ARC_COMPONENT_TYPE_KBD,
VAS_EBOOT_ARC_COMPONENT_TYPE_TERMINAL,
#ifndef VAS_EBOOT_CPU_WORDS_BIGENDIAN
VAS_EBOOT_ARC_COMPONENT_TYPE_OTHER_PERIPHERAL,
#endif
VAS_EBOOT_ARC_COMPONENT_TYPE_LINE,
VAS_EBOOT_ARC_COMPONENT_TYPE_NET,
VAS_EBOOT_ARC_COMPONENT_TYPE_MEMORY_UNIT,
};
enum VasEBoot_arc_file_access
{
VAS_EBOOT_ARC_FILE_ACCESS_OPEN_RO,
VAS_EBOOT_ARC_FILE_ACCESS_OPEN_WO,
VAS_EBOOT_ARC_FILE_ACCESS_OPEN_RW,
};
struct VasEBoot_arc_fileinfo
{
VasEBoot_arc_ularge_t start;
VasEBoot_arc_ularge_t end;
VasEBoot_arc_ularge_t current;
VasEBoot_arc_enum_t type;
VasEBoot_arc_ulong_t fnamelength;
VasEBoot_arc_uchar_t attr;
char filename[32];
};
struct VasEBoot_arc_firmware_vector
{
/* 0x00. */
void *load;
void *invoke;
void *execute;
void *halt;
/* 0x10. */
void (*powerdown) (void);
void (*restart) (void);
void (*reboot) (void);
void (*exit) (void);
/* 0x20. */
void *reserved1;
const struct VasEBoot_arc_component * (*getpeer) (const struct VasEBoot_arc_component *comp);
const struct VasEBoot_arc_component * (*getchild) (const struct VasEBoot_arc_component *comp);
void *getparent;
/* 0x30. */
void *getconfigurationdata;
void *addchild;
void *deletecomponent;
void *getcomponent;
/* 0x40. */
void *saveconfiguration;
void *getsystemid;
struct VasEBoot_arc_memory_descriptor *(*getmemorydescriptor) (struct VasEBoot_arc_memory_descriptor *current);
void *reserved2;
/* 0x50. */
struct VasEBoot_arc_timeinfo *(*gettime) (void);
void *getrelativetime;
void *getdirectoryentry;
VasEBoot_arc_err_t (*open) (const char *path, VasEBoot_arc_enum_t mode,
VasEBoot_arc_fileno_t *fileno);
/* 0x60. */
VasEBoot_arc_err_t (*close) (VasEBoot_arc_fileno_t fileno);
VasEBoot_arc_err_t (*read) (VasEBoot_arc_fileno_t fileno, void *buf,
VasEBoot_arc_ulong_t n,
VasEBoot_arc_ulong_t *count);
VasEBoot_arc_err_t (*get_read_status) (VasEBoot_arc_fileno_t fileno);
VasEBoot_arc_err_t (*write) (VasEBoot_arc_fileno_t fileno, const void *buf,
VasEBoot_arc_ulong_t n,
VasEBoot_arc_ulong_t *count);
/* 0x70. */
VasEBoot_arc_err_t (*seek) (VasEBoot_arc_fileno_t fileno,
VasEBoot_arc_ularge_t *pos, VasEBoot_arc_enum_t mode);
void *mount;
const char * (*getenvironmentvariable) (const char *name);
void *setenvironmentvariable;
/* 0x80. */
VasEBoot_arc_err_t (*getfileinformation) (VasEBoot_arc_fileno_t fileno,
struct VasEBoot_arc_fileinfo *info);
void *setfileinformation;
void *flushallcaches;
void *testunicodecharacter;
/* 0x90. */
struct VasEBoot_arc_display_status * (*getdisplaystatus) (VasEBoot_arc_fileno_t fileno);
};
struct VasEBoot_arc_adapter
{
VasEBoot_arc_ulong_t adapter_type;
VasEBoot_arc_ulong_t adapter_vector_length;
void *adapter_vector;
};
struct VasEBoot_arc_system_parameter_block
{
VasEBoot_arc_ulong_t signature;
VasEBoot_arc_ulong_t length;
VasEBoot_arc_ushort_t version;
VasEBoot_arc_ushort_t revision;
void *restartblock;
void *debugblock;
void *gevector;
void *utlbmissvector;
VasEBoot_arc_ulong_t firmware_vector_length;
struct VasEBoot_arc_firmware_vector *firmwarevector;
VasEBoot_arc_ulong_t private_vector_length;
void *private_vector;
VasEBoot_arc_ulong_t adapter_count;
struct VasEBoot_arc_adapter adapters[0];
};
#define VAS_EBOOT_ARC_SYSTEM_PARAMETER_BLOCK ((struct VasEBoot_arc_system_parameter_block *) 0xa0001000)
#define VAS_EBOOT_ARC_FIRMWARE_VECTOR (VAS_EBOOT_ARC_SYSTEM_PARAMETER_BLOCK->firmwarevector)
#define VAS_EBOOT_ARC_STDIN 0
#define VAS_EBOOT_ARC_STDOUT 1
typedef int (*VasEBoot_arc_iterate_devs_hook_t)
(const char *name, const struct VasEBoot_arc_component *comp, void *data);
int EXPORT_FUNC (VasEBoot_arc_iterate_devs) (VasEBoot_arc_iterate_devs_hook_t hook,
void *hook_data,
int alt_names);
char *EXPORT_FUNC (VasEBoot_arc_alt_name_to_norm) (const char *name, const char *suffix);
int EXPORT_FUNC (VasEBoot_arc_is_device_serial) (const char *name, int alt_names);
#define FOR_ARC_CHILDREN(comp, parent) for (comp = VAS_EBOOT_ARC_FIRMWARE_VECTOR->getchild (parent); comp; comp = VAS_EBOOT_ARC_FIRMWARE_VECTOR->getpeer (comp))
extern void VasEBoot_arcdisk_init (void);
extern void VasEBoot_arcdisk_fini (void);
#endif