Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make IOP skeleton showcase module unloading #577

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions skeleton/iop/hello_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "irx_imports.h"

#define MODNAME "hello"
IRX_ID("IOP skeleton", 1, 1);
IRX_ID("IOP_skeleton", 1, 1);

extern struct irx_export_table _exp_hello;

Expand All @@ -12,12 +12,38 @@ extern struct irx_export_table _exp_hello;


// This is a bit like a "main" for IRX files.
int _start(int argc, char *argv[])
int _start(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi)
{
if (RegisterLibraryEntries(&_exp_hello) != 0)

#ifndef NO_MODULE_UNLOAD_SUPPORT
if (argc < 0) _stop(argc, argv, startaddr, mi);
#endif
if (RegisterLibraryEntries(&_exp_hello) != 0) {
printf("Failed to RegisterLibraryEntries()\n");
return MODULE_NO_RESIDENT_END;
}

hello();

return MODULE_RESIDENT_END;
#ifdef MODULE_UNLOAD_ORIGINAL_APPROACH
return MODULE_REMOVABLE_END;
#else
#ifndef NO_MODULE_UNLOAD_SUPPORT
if (mi && ((mi->newflags & 2) != 0))
mi->newflags |= 0x10;
#endif
return MODULE_RESIDENT_END;
#endif
}

// Here you have to deinit devices, free memory, release exports,
// or whatever cleanup is required depending on what is your module doing
#ifndef NO_MODULE_UNLOAD_SUPPORT
int _stop(int argc, char *argv[], void *startaddr, ModuleInfo_t *mi)
{
printf("Unloading %s module\n", MODNAME);
ReleaseLibraryEntries(&_exp_hello);

return MODULE_NO_RESIDENT_END; //if the deinit process fails for whatever reason. you should return MODULE_REMOVABLE_END
}
#endif
Loading