Commit 8eafb9cd authored by Charlie Jacobsen's avatar Charlie Jacobsen Committed by Vikram Narayanan

libasync-integration: Fix LCD module inits.

If the module's init isn't marked with __init, it doesn't go in
the .init.text section. I was starting the LCD at the module_init
address; but this is the address of the beginning of .init.text,
not necessarily the module's init function. If the module's init
function is marked with __init, then it was going at the beginning
of that section, and so I was getting lucky.

Now I'm using the struct module.init pointer. Shouldn't matter
whether module's init function is in .init or regular .text (core)
now.
parent 71f69881
......@@ -547,7 +547,7 @@ int lcd_create_module_lcd(char *mdir, char *mname, cptr_t *lcd_out,
{
int ret;
cptr_t m_init_cptr, m_core_cptr;
gva_t m_init_link_addr, m_core_link_addr;
gva_t m_init_link_addr, m_core_link_addr, m_init_func_addr;
unsigned long m_init_size, m_core_size;
unsigned long m_struct_module_core_offset;
struct lcd_create_ctx *ctx;
......@@ -576,6 +576,7 @@ int lcd_create_module_lcd(char *mdir, char *mname, cptr_t *lcd_out,
&m_init_cptr, &m_core_cptr,
&m_init_link_addr, &m_core_link_addr,
&m_init_size, &m_core_size,
&m_init_func_addr,
&m_struct_module_core_offset);
if (ret) {
LIBLCD_ERR("error loading kernel module");
......@@ -605,7 +606,7 @@ int lcd_create_module_lcd(char *mdir, char *mname, cptr_t *lcd_out,
/*
* Configure initial control registers, etc. for LCD
*/
ret = lcd_config_registers(lcd, m_init_link_addr,
ret = lcd_config_registers(lcd, m_init_func_addr,
/* implicity put a null return address and
* frame address */
gva_add(LCD_STACK_GV_ADDR,
......
......@@ -19,6 +19,7 @@
* @m_init_link_addr: the address that the module's init code was linked for
* @m_init_size: size in bytes of the module init part of the image
* @m_core_size: size in bytes of the module core part of the image
* @m_init_func_addr: where the module's init routine is
* @m_struct_module_core_offset: offset into .ko's core where struct module
* is located
*
......@@ -42,6 +43,7 @@ int lcd_load_module(char *mdir, char *mname,
gva_t *m_core_link_addr,
unsigned long *m_init_size,
unsigned long *m_core_size,
gva_t *m_init_func_addr,
unsigned long *m_struct_module_core_offset);
/**
* lcd_release_module -- Unmap module bits and cap delete the pages
......
......@@ -176,6 +176,7 @@ int lcd_load_module(char *mdir, char *mname,
gva_t *m_core_link_addr,
unsigned long *m_init_size,
unsigned long *m_core_size,
gva_t *m_init_func_addr,
unsigned long *m_struct_module_core_offset)
{
int ret;
......@@ -213,6 +214,7 @@ int lcd_load_module(char *mdir, char *mname,
*m_core_link_addr = __gva((unsigned long)m->module_core);
*m_init_size = m->init_size;
*m_core_size = m->core_size;
*m_init_func_addr = __gva((unsigned long)m->init);
*m_struct_module_core_offset =
((unsigned long)m) - ((unsigned long)m->module_core);
......
......@@ -22,6 +22,7 @@ int lcd_load_module(char *mdir, char *mname,
gva_t *m_core_link_addr,
unsigned long *m_init_size,
unsigned long *m_core_size,
gva_t *m_init_func_addr,
unsigned long *m_struct_module_core_offset)
{
return -ENOSYS; /* not implemented */
......
......@@ -68,10 +68,23 @@ fail1:
return ret;
}
static int boot_init(void)
{
int ret;
LCD_MAIN({
ret = boot_main();
});
return ret;
}
static void boot_exit(void)
{
/* nothing to do */
}
module_init(boot_main);
module_init(boot_init);
module_exit(boot_exit);
......@@ -74,7 +74,7 @@ void foo1 (void) {
return;
}
static int __noreturn __init test_init(void)
static int __noreturn test_init(void)
{
int r;
......@@ -87,6 +87,19 @@ fail1:
lcd_exit(r);
}
static int __test_init(void)
{
int ret;
LCD_MAIN({
ret = test_init();
});
return ret;
}
/*
* make module loader happy (so we can unload). we don't actually call
* this before unloading the lcd (yet)
......@@ -96,5 +109,5 @@ static void __exit test_exit(void)
return;
}
module_init(test_init);
module_init(__test_init);
module_exit(test_exit);
......@@ -62,10 +62,23 @@ fail1:
return ret;
}
static int boot_init(void)
{
int ret;
LCD_MAIN({
ret = boot_main();
});
return ret;
}
static void boot_exit(void)
{
/* nothing to do */
}
module_init(boot_main);
module_init(boot_init);
module_exit(boot_exit);
......@@ -45,7 +45,7 @@ void do_stuff(void)
LIBLCD_MSG("out of do-finish");
}
static int __noreturn __init async_lcd_init(void)
static int __noreturn async_lcd_init(void)
{
int r = 0;
r = lcd_enter();
......@@ -60,10 +60,23 @@ out:
lcd_exit(r);
}
static int __async_lcd_init(void)
{
int ret;
LCD_MAIN({
ret = async_lcd_init();
});
return ret;
}
static void async_lcd_exit(void)
{
return;
}
module_init(async_lcd_init);
module_init(__async_lcd_init);
module_exit(async_lcd_exit);
......@@ -125,7 +125,7 @@ fail1:
return ret;
}
static int __init boot_init(void)
static int boot_init(void)
{
int ret;
......
......@@ -311,7 +311,7 @@ out:
lcd_exit(ret);
}
static int __init async_rpc_callee_init(void)
static int async_rpc_callee_init(void)
{
int ret;
......
......@@ -307,7 +307,7 @@ out:
lcd_exit(ret);
}
static int __init async_rpc_caller_init(void)
static int async_rpc_caller_init(void)
{
int ret;
......
......@@ -59,10 +59,23 @@ fail1:
return ret;
}
static int boot_init(void)
{
int ret;
LCD_MAIN({
ret = boot_main();
});
return ret;
}
static void boot_exit(void)
{
/* nothing to do */
}
module_init(boot_main);
module_init(boot_init);
module_exit(boot_exit);
......@@ -16,7 +16,7 @@ static int foo(void)
return 10;
}
static int __init my_init(void)
static int my_init(void)
{
int ret;
......@@ -33,6 +33,19 @@ out:
return ret;
}
static int __my_init(void)
{
int ret;
LCD_MAIN({
ret = my_init();
});
return ret;
}
/*
* make module loader happy (so we can unload). we don't actually call
* this before unloading the lcd (yet)
......@@ -42,5 +55,5 @@ static void __exit my_exit(void)
return;
}
module_init(my_init);
module_init(__my_init);
module_exit(my_exit);
......@@ -138,10 +138,23 @@ fail1:
return ret;
}
static int boot_init(void)
{
int ret;
LCD_MAIN({
ret = boot_main();
});
return ret;
}
static void boot_exit(void)
{
/* nothing to do */
}
module_init(boot_main);
module_init(boot_init);
module_exit(boot_exit);
......@@ -122,7 +122,7 @@ void original_minix_lcd_exit(void);
static struct dispatch_ctx ctx;
static int __init minix_lcd_boot(void)
static int minix_lcd_boot(void)
{
int ret;
cptr_t vfs_chnl;
......@@ -178,10 +178,23 @@ static int __init minix_lcd_boot(void)
lcd_exit(0);
}
static int minix_lcd_init(void)
{
int ret;
LCD_MAIN({
ret = minix_lcd_boot();
});
return ret;
}
static void __exit minix_lcd_exit(void)
{
/* Never called, for now. */
}
module_init(minix_lcd_boot);
module_init(minix_lcd_init);
module_exit(minix_lcd_exit);
......@@ -155,7 +155,7 @@ void original_vfs_lcd_exit(void);
static struct dispatch_ctx ctx;
static int __init vfs_lcd_boot(void)
static int vfs_lcd_boot(void)
{
int ret;
cptr_t vfs_chnl;
......@@ -216,10 +216,23 @@ static int __init vfs_lcd_boot(void)
lcd_exit(0);
}
static int vfs_lcd_init(void)
{
int ret;
LCD_MAIN({
ret = vfs_lcd_boot();
});
return ret;
}
static void __exit vfs_lcd_exit(void)
{
/* Never called, for now. */
}
module_init(vfs_lcd_boot);
module_init(vfs_lcd_init);
module_exit(vfs_lcd_exit);
......@@ -122,10 +122,23 @@ fail1:
return ret;
}
static int boot_init(void)
{
int ret;
LCD_MAIN({
ret = boot_main();
});
return ret;
}
static void boot_exit(void)
{
/* nothing to do */
}
module_init(boot_main);
module_init(boot_init);
module_exit(boot_exit);
......@@ -37,7 +37,7 @@ static void get_endpoint(void)
ep = lcd_get_boot_info()->cptrs[0];
}
static int __noreturn __init ipc1_lcd_init(void)
static int __noreturn ipc1_lcd_init(void)
{
int ret = 0;
ret = lcd_enter();
......@@ -54,10 +54,23 @@ out:
lcd_exit(ret);
}
static int __ipc1_lcd_init(void)
{
int ret;
LCD_MAIN({
ret = ipc1_lcd_init();
});
return ret;
}
static void ipc1_lcd_exit(void)
{
return;
}
module_init(ipc1_lcd_init);
module_init(__ipc1_lcd_init);
module_exit(ipc1_lcd_exit);
......@@ -125,10 +125,23 @@ fail1:
return ret;
}
static int boot_init(void)
{
int ret;
LCD_MAIN({
ret = boot_main();
});
return ret;
}
static void boot_exit(void)
{
/* nothing to do */
}
module_init(boot_main);
module_init(boot_init);
module_exit(boot_exit);
......@@ -24,7 +24,7 @@ static void get_endpoint(void)
ep = lcd_get_boot_info()->cptrs[0];
}
static int __noreturn __init lcd1_init(void)
static int __noreturn lcd1_init(void)
{
int r;
r = lcd_enter();
......@@ -42,10 +42,23 @@ out:
lcd_exit(r);
}
static int __lcd1_init(void)
{
int ret;
LCD_MAIN({
ret = lcd1_init();
});
return ret;
}
static void lcd1_exit(void)
{
return;
}
module_init(lcd1_init);
module_init(__lcd1_init);
module_exit(lcd1_exit);
......@@ -30,7 +30,7 @@ static void get_endpoint(void)
ep = lcd_get_boot_info()->cptrs[0];
}
static int __noreturn __init lcd2_init(void)
static int __noreturn lcd2_init(void)
{
int r;
r = lcd_enter();
......@@ -48,10 +48,23 @@ out:
lcd_exit(r);
}
static int __lcd2_init(void)
{
int ret;
LCD_MAIN({
ret = lcd2_init();
});
return ret;
}
static void lcd2_exit(void)
{
return;
}
module_init(lcd2_init);
module_init(__lcd2_init);
module_exit(lcd2_exit);
......@@ -62,10 +62,23 @@ fail1:
return ret;
}
static int boot_init(void)
{
int ret;
LCD_MAIN({
ret = boot_main();
});
return ret;
}
static void boot_exit(void)
{
/* nothing to do */
}
module_init(boot_main);
module_init(boot_init);
module_exit(boot_exit);
......@@ -319,7 +319,7 @@ fail1:
return ret;
}
static int __noreturn __init liblcd_test_lcd_init(void)
static int __noreturn liblcd_test_lcd_init(void)
{
int ret = 0;
ret = lcd_enter();
......@@ -383,10 +383,23 @@ out:
lcd_exit(ret);
}
static void __liblcd_test_lcd_init(void)
{
int ret;
LCD_MAIN({
ret = liblcd_test_lcd_init();
});
return ret;
}
static void liblcd_test_lcd_exit(void)
{
return;
}
module_init(liblcd_test_lcd_init);
module_init(__liblcd_test_lcd_init);
module_exit(liblcd_test_lcd_exit);
......@@ -63,10 +63,23 @@ fail1:
return ret;
}
static int boot_init(void)
{
int ret;
LCD_MAIN({
ret = boot_main();
});
return ret;
}
static void boot_exit(void)
{
/* nothing to do */
}
module_init(boot_main);
module_init(boot_init);
module_exit(boot_exit);
......@@ -40,7 +40,7 @@ static int foo(int x)
return x + 5;
}
static int __noreturn __init test_init(void)
static int __noreturn test_init(void)
{