[libj6] Remove driver_main

The `driver_main` sinature was an alternate signature for `main`
implemented with weak symbols, but it causes linking issues when not
statically linked, and drivers are going to work differently soon
anyway. Just get rid of it for now.
This commit is contained in:
Justin C. Miller
2023-08-26 19:23:13 -07:00
parent eda816ad90
commit 646a534dfd
5 changed files with 15 additions and 5 deletions

View File

@@ -73,6 +73,9 @@ struct j6_init_args
/// Find the first handle of the given type held by this process /// Find the first handle of the given type held by this process
j6_handle_t j6_find_first_handle(j6_object_type obj_type); j6_handle_t j6_find_first_handle(j6_object_type obj_type);
/// Get the init args
const j6_init_args * j6_get_init_args();
/// Drivers may use driver_main instead of main /// Drivers may use driver_main instead of main
int driver_main(unsigned, const char **, const char **, const j6_init_args *); int driver_main(unsigned, const char **, const char **, const j6_init_args *);

View File

@@ -36,12 +36,18 @@ j6_find_first_handle(j6_object_type obj_type)
return j6_handle_invalid; return j6_handle_invalid;
} }
extern "C" j6_init_args * const j6_init_args *
j6_get_init_args()
{
return &init_args;
}
extern "C" void
__init_libj6(uint64_t arg0, uint64_t arg1) __init_libj6(uint64_t arg0, uint64_t arg1)
{ {
init_args.args[0] = arg0; init_args.args[0] = arg0;
init_args.args[1] = arg1; init_args.args[1] = arg1;
return &init_args;
} }
#endif // __j6kernel #endif // __j6kernel

View File

@@ -7,7 +7,6 @@ j6 = module("j6",
"channel.cpp", "channel.cpp",
"condition.cpp", "condition.cpp",
"init.cpp", "init.cpp",
"init.s",
"memutils.cpp", "memutils.cpp",
"mutex.cpp", "mutex.cpp",
"protocol_ids.cpp", "protocol_ids.cpp",

View File

@@ -20,7 +20,7 @@ extern "C" {
} }
int int
driver_main(unsigned argc, const char **argv, const char **env, const j6_init_args *init) main(int argc, const char **argv, const char **env)
{ {
j6::syslog("fb driver starting"); j6::syslog("fb driver starting");
@@ -28,6 +28,7 @@ driver_main(unsigned argc, const char **argv, const char **env, const j6_init_ar
using bootproto::devices::video_mode; using bootproto::devices::video_mode;
using bootproto::devices::fb_layout; using bootproto::devices::fb_layout;
const j6_init_args *init = j6_get_init_args();
const uefi_fb *fb = reinterpret_cast<const uefi_fb*>(init->args[0]); const uefi_fb *fb = reinterpret_cast<const uefi_fb*>(init->args[0]);
if (!fb || !fb->framebuffer) { if (!fb || !fb->framebuffer) {

View File

@@ -27,7 +27,7 @@ using bootproto::module_type;
constexpr uintptr_t stack_top = 0xf80000000; constexpr uintptr_t stack_top = 0xf80000000;
int int
driver_main(unsigned argc, const char **argv, const char **env, const j6_init_args *initp) main(int argc, const char **argv, const char **env)
{ {
j6_status_t s; j6_status_t s;
@@ -74,6 +74,7 @@ driver_main(unsigned argc, const char **argv, const char **env, const j6_init_ar
if (s != j6_status_ok) if (s != j6_status_ok)
return s; return s;
const j6_init_args *initp = j6_get_init_args();
uintptr_t modules_addr = initp->args[0]; uintptr_t modules_addr = initp->args[0];
std::vector<const module*> mods; std::vector<const module*> mods;