From: John Hodge Date: Sun, 27 Dec 2009 10:54:14 +0000 (+0800) Subject: Working on UDI support (UDI manager module now compiles) X-Git-Tag: rel0.06~354 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=ebe5e8898c7e8b2a0eb6ec285d214ff52ed18803;p=tpg%2Facess2.git Working on UDI support (UDI manager module now compiles) - DEBUG ONLY --- diff --git a/Kernel/Makefile.BuildNum b/Kernel/Makefile.BuildNum index c2a30d62..188cc18d 100644 --- a/Kernel/Makefile.BuildNum +++ b/Kernel/Makefile.BuildNum @@ -1 +1 @@ -BUILD_NUM = 1078 +BUILD_NUM = 1080 diff --git a/Kernel/modules.c b/Kernel/modules.c index 44c4cb51..ba92905f 100644 --- a/Kernel/modules.c +++ b/Kernel/modules.c @@ -5,6 +5,9 @@ #include #include +#define USE_EDI 0 +#define USE_UDI 1 + // === PROTOTYPES === int Modules_LoadBuiltins(); int Module_LoadMem(void *Buffer, Uint Length, char *ArgString); @@ -13,6 +16,9 @@ int Module_IsLoaded(char *Name); // === IMPORTS === +#if USE_UDI +extern int UDI_LoadDriver(void *Base); +#endif extern void StartupPrint(char *Str); extern tModule gKernelModules[]; extern void gKernelModulesEnd; @@ -152,6 +158,14 @@ int Module_LoadFile(char *Path, char *ArgString) } #endif + #if USE_UDI + if( Binary_FindSymbol(base, "udi_init_info", NULL ) == 0 ) + { + Binary_Relocate(base); // Relocate + return UDI_LoadDriver( base ); // And intialise + } + #endif + // Unknown module type?, return error Binary_Unload(base); #if USE_EDI diff --git a/Kernel/system.c b/Kernel/system.c index af668513..bb631ca5 100644 --- a/Kernel/system.c +++ b/Kernel/system.c @@ -247,7 +247,15 @@ void System_ExecuteScript() if(!sArg1) goto read2eol; Module_LoadFile(sArg1, ""); //!\todo Use the rest of the line as the argument string } - // - Load Module + // - Load Module (UDI) + else if(strncmp("udimod ", fData+i, 6) == 0) { + //char *tmp; + i += 7; + i += System_Int_GetString(fData+i, &sArg1); + if(!sArg1) goto read2eol; + Module_LoadFile(sArg1, ""); + } + // - Load Module (EDI) else if(strncmp("edimod ", fData+i, 6) == 0) { i += 7; i += System_Int_GetString(fData+i, &sArg1); diff --git a/Makefile.cfg b/Makefile.cfg index 441718cb..3875828f 100644 --- a/Makefile.cfg +++ b/Makefile.cfg @@ -21,7 +21,7 @@ ARCHDIR = x86 FILESYSTEMS = fat DRIVERS = ata_x86 -MODULES = FS_Ext2 FDD NE2000 BochsGA +MODULES = UDI FS_Ext2 FDD NE2000 BochsGA #DISTROOT = /mnt/AcessHDD/Acess2 #DISTROOT = ~/Projects/Acess2/Filesystem diff --git a/Modules/UDI/Makefile b/Modules/UDI/Makefile new file mode 100644 index 00000000..81b5f124 --- /dev/null +++ b/Modules/UDI/Makefile @@ -0,0 +1,8 @@ +# +# + +CPPFLAGS = -I./include +OBJ = main.o +NAME = UDI + +-include ../Makefile.tpl diff --git a/Modules/UDI/include/_udi/meta_gio.h b/Modules/UDI/include/_udi/meta_gio.h new file mode 100644 index 00000000..57d92352 --- /dev/null +++ b/Modules/UDI/include/_udi/meta_gio.h @@ -0,0 +1,26 @@ +/* + * Acess2 UDI Support + * _udi/meta_gio.h + * - General IO Metalanguage + */ +#ifndef _UDI_META_GIO_H_ +#define _UDI_META_GIO_H_ + +typedef struct { + udi_channel_event_ind_op_t *channel_event_ind_op ; + udi_gio_bind_ack_op_t *gio_bind_ack_op ; + udi_gio_unbind_ack_op_t *gio_unbind_ack_op ; + udi_gio_xfer_ack_op_t *gio_xfer_ack_op ; + udi_gio_xfer_nak_op_t *gio_xfer_nak_op ; + udi_gio_event_ind_op_t *gio_event_ind_op ; +} udi_gio_client_ops_t; + +typedef struct { + udi_channel_event_ind_op_t *channel_event_ind_op ; + udi_gio_bind_req_op_t *gio_bind_req_op ; + udi_gio_unbind_req_op_t *gio_unbind_req_op ; + udi_gio_xfer_req_op_t *gio_xfer_req_op ; + udi_gio_event_res_op_t *gio_event_res_op ; +} udi_gio_provider_ops_t ; + +#endif diff --git a/Modules/UDI/include/_udi/meta_mgmt.h b/Modules/UDI/include/_udi/meta_mgmt.h new file mode 100644 index 00000000..ac571371 --- /dev/null +++ b/Modules/UDI/include/_udi/meta_mgmt.h @@ -0,0 +1,45 @@ +/* + * Acess2 UDI Support + * _udi/meta_mgmt.h + * - Mangement Metalanguage + */ +#ifndef _UDI_META_MGMT_H_ +#define _UDI_META_MGMT_H_ + +typedef struct { + udi_cb_t gcb; +} udi_mgmt_cb_t; + + +typedef struct { + udi_cb_t gcb; + udi_trevent_t trace_mask; + udi_index_t meta_idx; +} udi_usage_cb_t; + + +typedef struct { + udi_cb_t gcb; + udi_ubit32_t child_ID; + void *child_data; + udi_instance_attr_list_t *attr_list; + udi_ubit8_t attr_valid_length; + const udi_filter_element_t *filter_list; + udi_ubit8_t filter_list_length; + udi_ubit8_t parent_ID; +} udi_enumerate_cb_t; + + +typedef void udi_usage_ind_op_t(udi_usage_cb_t *, udi_ubit8_t); +typedef void udi_enumerate_req_op_t(udi_enumerate_cb_t *, udi_ubit8_t); +typedef void udi_devmgmt_req_op_t(udi_mgmt_cb_t *, udi_ubit8_t); +typedef void udi_final_cleanup_req_op_t(udi_mgmt_cb_t *); + +typedef const struct { + udi_usage_ind_op_t *usage_ind_op; + udi_enumerate_req_op_t *enumerate_req_op; + udi_devmgmt_req_op_t *devmgmt_req_op; + udi_final_cleanup_req_op_t *final_cleanup_req_op; +} udi_mgmt_ops_t; + +#endif diff --git a/Modules/UDI/include/_udi/values.h b/Modules/UDI/include/_udi/values.h new file mode 100644 index 00000000..6c17d48e --- /dev/null +++ b/Modules/UDI/include/_udi/values.h @@ -0,0 +1,13 @@ +#ifndef _UDI_VALUES_H_ +#define _UDI_VALUES_H_ + +typedef udi_ubit8_t udi_instance_attr_type_t; +/* Instance Attribute Types */ +#define UDI_ATTR_NONE 0 +#define UDI_ATTR_STRING 1 +#define UDI_ATTR_ARRAY8 2 +#define UDI_ATTR_UBIT32 3 +#define UDI_ATTR_BOOLEAN 4 +#define UDI_ATTR_FILE 5 + +#endif diff --git a/Modules/UDI/include/udi.h b/Modules/UDI/include/udi.h new file mode 100644 index 00000000..6654d2da --- /dev/null +++ b/Modules/UDI/include/udi.h @@ -0,0 +1,164 @@ +/* + * Acess2 UDI Support + * udi.h + */ +#ifndef _UDI_H_ +#define _UDI_H_ + +#include + +typedef void udi_op_t(void); + +typedef udi_op_t const *udi_ops_vector_t; + +typedef const udi_ubit8_t udi_layout_t; + +typedef udi_ubit32_t udi_trevent_t; + +#include <_udi/values.h> + +typedef struct { + udi_channel_t channel; + void *context; + void *scratch; + void *initiator_context; + udi_origin_t origin; +} udi_cb_t; + +/** + * \name Attributes + * \{ + */ +#define UDI_MAX_ATTR_NAMELEN 32 +#define UDI_MAX_ATTR_SIZE 64 +typedef struct { + char attr_name[UDI_MAX_ATTR_NAMELEN]; + udi_ubit8_t attr_value[UDI_MAX_ATTR_SIZE]; + udi_ubit8_t attr_length; + udi_instance_attr_type_t attr_type; +} udi_instance_attr_list_t; + +typedef struct { + char attr_name[UDI_MAX_ATTR_NAMELEN]; + udi_ubit8_t attr_min[UDI_MAX_ATTR_SIZE]; + udi_ubit8_t attr_min_len; + udi_ubit8_t attr_max[UDI_MAX_ATTR_SIZE]; + udi_ubit8_t attr_max_len; + udi_instance_attr_type_t attr_type; + udi_ubit32_t attr_stride; +} udi_filter_element_t; +/** + * \} + */ + + + +#include <_udi/meta_mgmt.h> + +/** + */ +typedef const struct { + udi_index_t cb_idx; + udi_size_t scratch_requirement; +} udi_gcb_init_t; + +/** + */ +typedef const struct { + udi_index_t ops_idx; + udi_index_t cb_idx; +} udi_cb_select_t; + +/** + */ +typedef const struct { + udi_index_t cb_idx; + udi_index_t meta_idx; + udi_index_t meta_cb_num; + udi_size_t scratch_requirement; + udi_size_t inline_size; + udi_layout_t *inline_layout; +} udi_cb_init_t; + +/** + * The \a udi_ops_init_t structure contains information the environment + * needs to subsequently create channel endpoints for a particular type of ops + * vector and control block usage. This structure is part of \a udi_init_info. + */ +typedef const struct { + udi_index_t ops_idx; //!< Non Zero driver assigned number + udi_index_t meta_idx; //!< Metalanguage Selector + udi_index_t meta_ops_num; //!< Metalanguage Operation + udi_size_t chan_context_size; + udi_ops_vector_t *ops_vector; //!< Array of function pointers + const udi_ubit8_t *op_flags; +} udi_ops_init_t; + +/** + */ +typedef const struct { + udi_index_t region_idx; + udi_size_t rdata_size; +} udi_secondary_init_t; + + +/** + */ +typedef const struct { + udi_mgmt_ops_t *mgmt_ops; + const udi_ubit8_t *mgmt_op_flags; + udi_size_t mgmt_scratch_requirement; + udi_ubit8_t enumeration_attr_list_length; + udi_size_t rdata_size; + udi_size_t child_data_size; + udi_ubit8_t per_parent_paths; +} udi_primary_init_t; + +/** + */ +typedef const struct { + udi_primary_init_t *primary_init_info; + udi_secondary_init_t *secondary_init_list; //!< Array + udi_ops_init_t *ops_init_list; + udi_cb_init_t *cb_init_list; + udi_gcb_init_t *gcb_init_list; + udi_cb_select_t *cb_select_list; +} udi_init_t; + + +// +// == Regions == +// + +/** + * udi_limits_t reflects implementation-dependent system limits, such as + * memory allocation and timer resolution limits, for a particular region. These + * limits may vary from region to region, but will remain constant for the life of + * a region. + */ +typedef struct { + udi_size_t max_legal_alloc; + udi_size_t max_safe_alloc; + udi_size_t max_trace_log_formatted_len; + udi_size_t max_instance_attr_len; + udi_ubit32_t min_curtime_res; + udi_ubit32_t min_timer_res; +} udi_limits_t; + +/** +The \a udi_init_context_t structure is stored at the front of the region +data area of each newly created region, providing initial data that a driver will +need to begin executing in the region. A pointer to this structure (and therefore +the region data area as a whole) is made available to the driver as the initial +channel context for its first channel. + */ +typedef struct { + udi_index_t region_idx; + udi_limits_t limits; +} udi_init_context_t; + +typedef struct { + void *rdata; +} udi_chan_context_t; + +#endif diff --git a/Modules/UDI/include/udi_arch.h b/Modules/UDI/include/udi_arch.h new file mode 100644 index 00000000..0d8ac6a5 --- /dev/null +++ b/Modules/UDI/include/udi_arch.h @@ -0,0 +1,28 @@ +/* + * Acess2 UDI Support + * - Architecture Dependent Definitions + */ +#ifndef _UDI_ARCH_H_ +#define _UDI_ARCH_H_ + +//#if ARCH == x86 +typedef char udi_sbit8_t; /* signed 8-bit: -2^7..2^7-1 */ +typedef short udi_sbit16_t; /* signed 16-bit: -2^15..2^15-1 */ +typedef long udi_sbit32_t; /* signed 32-bit: -2^31..2^31-1 */ +typedef unsigned char udi_ubit8_t; /* unsigned 8-bit: 0..2^8-1 */ +typedef unsigned short udi_ubit16_t; /* unsigned 16-bit: 0..2^16-1 */ +typedef unsigned long udi_ubit32_t; /* unsigned 32-bit: 0..2^32-1 */ +typedef udi_ubit8_t udi_boolean_t; /* 0=False; 1..255=True */ + + +typedef unsigned int udi_size_t; /* buffer size (equiv to size_t) */ +typedef unsigned int udi_index_t; /* zero-based index type */ + +typedef void* udi_channel_t; /* UDI_NULL_CHANNEL */ +typedef void* udi_buf_path_t; /* UDI_NULL_BUF_PATH */ +typedef void* udi_origin_t; /* UDI_NULL_ORIGIN */ + +typedef void* udi_timestamp_t; +//#endif + +#endif diff --git a/Modules/UDI/main.c b/Modules/UDI/main.c new file mode 100644 index 00000000..63f6d8b2 --- /dev/null +++ b/Modules/UDI/main.c @@ -0,0 +1,61 @@ +/* + * Acess2 UDI Layer + */ +#define DEBUG 0 +#define VERSION ((0<<8)|1) +#include +#include +#include + +// === PROTOTYPES === + int UDI_Install(char **Arguments); + int UDI_LoadDriver(void *Base); + +// === GLOBALS === +MODULE_DEFINE(0, VERSION, UDI, UDI_Install, NULL, NULL); + +// === CODE === +/** + * \fn int UDI_Install(char **Arguments) + * \brief Stub intialisation routine + */ +int UDI_Install(char **Arguments) +{ + return 1; +} + +/** + * \fn int UDI_LoadDriver(void *Base) + */ +int UDI_LoadDriver(void *Base) +{ + udi_init_t *info; + int i, j; + if( Binary_FindSymbol(Base, "udi_init_info", (Uint*)&info) == 0) { + Binary_Unload(Base); + return 0; + } + + Log("primary_init_info = %p", info->primary_init_info); + Log("secondary_init_list = %p", info->secondary_init_list); + Log("ops_init_list = %p", info->ops_init_list); + + for( i = 0; info->ops_init_list[i].ops_idx; i++ ) + { + Log("info->ops_init_list[%i] = {", i); + Log(" .ops_idx = %i", info->ops_init_list[i].ops_idx); + Log(" .meta_idx = %i", info->ops_init_list[i].meta_idx); + Log(" .meta_ops_num = %i", info->ops_init_list[i].meta_ops_num); + Log(" .chan_context_size = %i", info->ops_init_list[i].chan_context_size); + Log(" .ops_vector = {"); + for( j = 0; info->ops_init_list[i].ops_vector; j++ ) + { + Log("%i: %p()", j, info->ops_init_list[i].ops_vector); + } + Log(" }"); + Log(" .op_flags = %p", info->ops_init_list[i].op_flags); + Log("}"); + } + + return 0; +}