aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprofkhaos <profkhaos@Khaos-Phantom.(none)>2009-08-21 18:34:09 +0300
committerprofkhaos <profkhaos@Khaos-Phantom.(none)>2009-08-21 18:34:09 +0300
commitc98f05d2e8ab03926931bada035139e9f91c6e4a (patch)
tree16acd0f7966eab849feed86fec3d560a985a5641
parent157b3a28a060a0bbfce0f047c8fa3712e0520207 (diff)
downloadsyslinux-c98f05d2e8ab03926931bada035139e9f91c6e4a.tar.gz
syslinux-c98f05d2e8ab03926931bada035139e9f91c6e4a.tar.xz
syslinux-c98f05d2e8ab03926931bada035139e9f91c6e4a.zip
Functional .c32 loading with modules dependency fileHEADklausm
-rw-r--r--com32/elflink/modules/background.c16
-rw-r--r--com32/include/sys/exec.h12
-rw-r--r--com32/include/sys/module.h13
-rw-r--r--com32/lib/sys/module/elf_module.c1
-rw-r--r--com32/lib/sys/module/exec.c41
-rw-r--r--core/elflink/cli.c6
-rw-r--r--core/elflink/load_env32.c11
7 files changed, 94 insertions, 6 deletions
diff --git a/com32/elflink/modules/background.c b/com32/elflink/modules/background.c
index c4f98f3e..c2f67475 100644
--- a/com32/elflink/modules/background.c
+++ b/com32/elflink/modules/background.c
@@ -13,8 +13,14 @@
#include <consoles.h>
#include <string.h>
#include <syslinux/vesacon.h>
+#include <sys/module.h>
#include "menu.h"
+static int background_init()
+{
+ return 0; // Nothing to do; return success
+}
+
const char *current_background = NULL;
int draw_background(const char *what)
@@ -35,3 +41,13 @@ void set_background(const char *new_background)
current_background = new_background;
}
}
+
+static void background_exit()
+{
+ // Nothing to do
+}
+
+// Define entry and exit points.
+MODULE_INIT(background_init);
+MODULE_EXIT(background_exit);
+
diff --git a/com32/include/sys/exec.h b/com32/include/sys/exec.h
index 0cb33bce..31b62beb 100644
--- a/com32/include/sys/exec.h
+++ b/com32/include/sys/exec.h
@@ -20,6 +20,16 @@
#define EXEC_ROOT_NAME "_root_.c32"
/**
+ * MODULES_DEP - The name of the standard module dependency file
+ *
+ * This is the file which contains information about the module dependency
+ * graph ( what other modules it depends on ). The file format is identical
+ * to the standard linux modules.dep file... for more information check out the
+ * man page ).
+ */
+#define MODULES_DEP "modules.dep"
+
+/**
* spawn_load - Load a library module or executes an executable one
* @name the name of the library/executable to use, including the extension
* (e.g. 'sort.c32')
@@ -32,6 +42,8 @@
*/
extern int spawn_load(const char *name,const char **argv);
+extern int module_load_dependencies(const char*name,const char*dep_file);
+
/**
* exec_init - Initialize the dynamic execution environment.
*
diff --git a/com32/include/sys/module.h b/com32/include/sys/module.h
index 1d94c094..f6ba0b5d 100644
--- a/com32/include/sys/module.h
+++ b/com32/include/sys/module.h
@@ -266,6 +266,19 @@ extern int module_load_shallow(struct elf_module *module, Elf32_Addr base_addr);
extern int module_unload(struct elf_module *module);
/**
+ * module_unload - unloads the module from the system.
+ * @module: the module descriptor structure.
+ *
+ * This function returns the type of module we're dealing with
+ * either a library module ( LIB_MODULE ), executable module ( EXEC_MODULE ),
+ * or an error ( UNKNOWN_MODULE ). The way it checks teh type is by checking to see
+ * if the module has its main_func set ( in which case it's an executable ). In case
+ * it doesn't it then checks to see if init_func is set ( in which case it's a
+ * library module. If this isn't the case either we don't know what it is so bail out
+ */
+extern int get_module_type(struct elf_module *module);
+
+/**
* module_unloadable - checks whether the given module can be unloaded.
* @module: the module descriptor structure
*
diff --git a/com32/lib/sys/module/elf_module.c b/com32/lib/sys/module/elf_module.c
index 66dc821f..aa78bf5a 100644
--- a/com32/lib/sys/module/elf_module.c
+++ b/com32/lib/sys/module/elf_module.c
@@ -497,3 +497,4 @@ error:
return res;
}
+
diff --git a/com32/lib/sys/module/exec.c b/com32/lib/sys/module/exec.c
index 52fa04d1..3a76be80 100644
--- a/com32/lib/sys/module/exec.c
+++ b/com32/lib/sys/module/exec.c
@@ -314,6 +314,47 @@ int spawn_load(const char *name,const char **argv)
return -1;
}
+int module_load_dependencies(const char*name,const char*dep_file)
+{
+ FILE *d_file=fopen(dep_file,"r");
+ char line[2048],aux[2048],temp_name[MODULE_NAME_SIZE],slbz[24];
+ int i=0,j=0,res=0;
+ if(d_file==NULL)
+ {
+ DBG_PRINT("Could not open object file '%s'\n",dep_file);
+ return -1;
+ }
+ do
+ {
+ if(fgets(line,2048,d_file)==NULL) break;
+ sscanf(line,"%s %[^\t\n]s",temp_name,aux);
+ }while(strncmp(name,temp_name,strlen(name)));
+ fclose(d_file);
+ //printf("%s %s\n",temp_name,aux);
+ while(aux[i])
+ {
+ if(aux[i]==' ')
+ {
+ temp_name[j]=NULL;
+ if(strlen(temp_name))
+ {
+ if(spawn_load(temp_name,NULL)<0)
+ {
+ //printf("\n\n%s\n\n",temp_name);
+ res=-1;
+ }
+ }
+ j=0;
+ }
+ else temp_name[j++]=aux[i];
+ i++;
+ }
+ temp_name[j]=NULL;
+ if(strlen(temp_name))
+ if(spawn_load(temp_name,NULL)<0) res=-1;
+ return res;
+}
+
void exec_term(void)
{
modules_term();
diff --git a/core/elflink/cli.c b/core/elflink/cli.c
index e58d6948..bbaab71c 100644
--- a/core/elflink/cli.c
+++ b/core/elflink/cli.c
@@ -349,7 +349,7 @@ void process_command(const char *cmd)
{
char **cmd_line = malloc((MAX_COMMAND_ARGS+1)*sizeof(char*));
char *temp_cmd=(char*)malloc(sizeof(char)*(strlen(cmd)+1));
- int argc = 0, len_mn;
+ int argc = 1, len_mn;
char *crt_arg,*module_name;
strcpy(temp_cmd,cmd);
@@ -361,6 +361,7 @@ void process_command(const char *cmd)
if(module_find(module_name) != NULL) goto cleanup;
do
{
+ cmd_line[0]=module_name;
crt_arg = strtok(NULL, COMMAND_DELIM);
if (crt_arg != NULL && strlen(crt_arg) > 0)
{
@@ -373,10 +374,11 @@ void process_command(const char *cmd)
}
}while (argc < MAX_COMMAND_ARGS);
cmd_line[argc] = NULL;
+ module_load_dependencies(module_name,MODULES_DEP);
/*int i;
for(i=0;i<argc;i++)
{
- printf("%s\n",cmd_line[i]);
+ printf("\n%s\n",cmd_line[i]);
}*/
spawn_load(module_name,cmd_line);
}
diff --git a/core/elflink/load_env32.c b/core/elflink/load_env32.c
index a4c81396..e42a3d8e 100644
--- a/core/elflink/load_env32.c
+++ b/core/elflink/load_env32.c
@@ -101,6 +101,7 @@ void load_env32(com32sys_t * regs)
{
printf("%s\n",aux->command);
}*/
+ //module_load_dependencies("mytest.c32",MODULES_DEP);
while(1)
{
@@ -127,9 +128,11 @@ void load_env32(com32sys_t * regs)
printf("%d\n",load_library("dyn/sort.dyn"));
printf("Loading ansiraw.c32\n%d\n",load_library("dyn/ansiraw.c32"));
- printf("Loading background.c32\n%d\n",load_library("dyn/background.c32"));
- printf("Loading printmsg.c32\n%d\n",load_library("dyn/printmsg.c32"));
- printf("Loading drain.c32\n%d\n",load_library("dyn/drain.c32"));
+ //printf("Loading background.c32\n%d\n",load_library("dyn/background.c32"));
+ spawn_load("dyn/background.c32",0);
+ //printf("Loading printmsg.c32\n%d\n",load_library("dyn/printmsg.c32"));
+ spawn_load("dyn/printmsg.c32",0);
+ /*printf("Loading drain.c32\n%d\n",load_library("dyn/drain.c32"));
printf("Loading sha1hash.c32\n%d\n",load_library("dyn/sha1hash.c32"));
printf("Loading unbase64.c32\n%d\n",load_library("dyn/unbase64.c32"));
printf("Loading sha512crypt\n%d\n",load_library("dyn/sha512crypt.c32"));
@@ -139,7 +142,7 @@ void load_env32(com32sys_t * regs)
printf("Loading passwd.c32\n%d\n",load_library("dyn/passwd.c32"));
printf("Loading get_key.c32\n%d\n",load_library("dyn/get_key.c32"));
//printf("Loading menumain.c32\n%d\n",load_library("dyn/menumain.c32"));
- spawn_load("dyn/menumain.c32",0);
+ spawn_load("dyn/menumain.c32",0);*/
/*printf("\n\nTrying to spawn 'dyn/hello.dyn'\n\n");
spawnv("dyn/hello.dyn",0);