Enhanced the kernelland_emu to:
- support built-in modules - support the private kernel locking calls - support the private kernel doubly linked list functions git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7458 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,11 +1,28 @@
|
|||||||
SubDir OBOS_TOP src tests add-ons kernel ;
|
SubDir OBOS_TOP src tests add-ons kernel ;
|
||||||
|
|
||||||
|
UsePrivateHeaders [ FDirName kernel ] ;
|
||||||
UsePrivateHeaders shared ;
|
UsePrivateHeaders shared ;
|
||||||
|
SubDirHdrs $(OBOS_TOP) headers private kernel arch $(OBOS_ARCH) ;
|
||||||
|
SubDirHdrs $(OBOS_TOP) headers private kernel boot platform $(OBOS_BOOT_PLATFORM) ;
|
||||||
|
|
||||||
|
SharedLibrary kernelland_emu :
|
||||||
|
kernelland_emu.cpp
|
||||||
|
lock.c
|
||||||
|
list.c
|
||||||
|
|
||||||
|
: be stdc++.r4 ;
|
||||||
|
|
||||||
SharedLibrary kernelland_emu : kernelland_emu.cpp : be stdc++.r4 ;
|
|
||||||
AbsSymLink <boot!home!config!lib>libkernelland_emu.so : libkernelland_emu.so
|
AbsSymLink <boot!home!config!lib>libkernelland_emu.so : libkernelland_emu.so
|
||||||
: /boot/home/config/lib : false ;
|
: /boot/home/config/lib : false ;
|
||||||
|
|
||||||
|
SEARCH on [ FGristFiles
|
||||||
|
lock.c
|
||||||
|
] = [ FDirName $(OBOS_TOP) src kernel core ] ;
|
||||||
|
|
||||||
|
SEARCH on [ FGristFiles
|
||||||
|
list.c
|
||||||
|
] = [ FDirName $(OBOS_TOP) src kernel core util ] ;
|
||||||
|
|
||||||
# SubInclude OBOS_TOP src tests add-ons kernel disk_scanner ;
|
# SubInclude OBOS_TOP src tests add-ons kernel disk_scanner ;
|
||||||
SubInclude OBOS_TOP src tests add-ons kernel file_systems ;
|
SubInclude OBOS_TOP src tests add-ons kernel file_systems ;
|
||||||
SubInclude OBOS_TOP src tests add-ons kernel network ;
|
SubInclude OBOS_TOP src tests add-ons kernel network ;
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ Module::Uninit()
|
|||||||
void
|
void
|
||||||
Module::Get()
|
Module::Get()
|
||||||
{
|
{
|
||||||
if (fAddOn >= 0)
|
if (fAddOn != NULL)
|
||||||
fReferenceCount++;
|
fReferenceCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,9 +232,10 @@ Module::Get()
|
|||||||
bool
|
bool
|
||||||
Module::Put()
|
Module::Put()
|
||||||
{
|
{
|
||||||
if (fAddOn >= 0)
|
if (fAddOn == NULL)
|
||||||
fReferenceCount--;
|
return false;
|
||||||
return (fReferenceCount == 0 && !(fInfo->flags & B_KEEP_LOADED));
|
|
||||||
|
return (--fReferenceCount == 0 && !(fInfo->flags & B_KEEP_LOADED));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -318,7 +319,7 @@ public:
|
|||||||
ModuleManager();
|
ModuleManager();
|
||||||
~ModuleManager();
|
~ModuleManager();
|
||||||
|
|
||||||
static ModuleManager *Default() { return &fDefaultManager; }
|
static ModuleManager *Default() { return &sDefaultManager; }
|
||||||
|
|
||||||
status_t GetModule(const char *path, module_info **infop);
|
status_t GetModule(const char *path, module_info **infop);
|
||||||
status_t PutModule(const char *path);
|
status_t PutModule(const char *path);
|
||||||
@@ -331,6 +332,8 @@ public:
|
|||||||
size_t *bufferSize);
|
size_t *bufferSize);
|
||||||
status_t CloseModuleList(module_name_list *list);
|
status_t CloseModuleList(module_name_list *list);
|
||||||
|
|
||||||
|
status_t AddBuiltInModule(module_info *info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _FindModules(BDirectory &dir, const char *moduleDir,
|
void _FindModules(BDirectory &dir, const char *moduleDir,
|
||||||
module_name_list *list);
|
module_name_list *list);
|
||||||
@@ -339,7 +342,7 @@ private:
|
|||||||
void _PutAddOn(ModuleAddOn *addon);
|
void _PutAddOn(ModuleAddOn *addon);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static ModuleManager fDefaultManager;
|
static ModuleManager sDefaultManager;
|
||||||
ModuleList fModules;
|
ModuleList fModules;
|
||||||
BObjectList<ModuleAddOn> fAddOns;
|
BObjectList<ModuleAddOn> fAddOns;
|
||||||
};
|
};
|
||||||
@@ -475,6 +478,7 @@ ModuleManager::ReadNextModuleName(module_name_list *list, char *buffer,
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// CloseModuleList
|
// CloseModuleList
|
||||||
status_t
|
status_t
|
||||||
ModuleManager::CloseModuleList(module_name_list *list)
|
ModuleManager::CloseModuleList(module_name_list *list)
|
||||||
@@ -485,6 +489,16 @@ ModuleManager::CloseModuleList(module_name_list *list)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
ModuleManager::AddBuiltInModule(module_info *info)
|
||||||
|
{
|
||||||
|
BAutolock _lock(fModules);
|
||||||
|
|
||||||
|
return fModules.AddModule(new Module(NULL, info)) ? B_OK : B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// _FindModules
|
// _FindModules
|
||||||
void
|
void
|
||||||
ModuleManager::_FindModules(BDirectory &dir, const char *moduleDir,
|
ModuleManager::_FindModules(BDirectory &dir, const char *moduleDir,
|
||||||
@@ -571,11 +585,24 @@ ModuleManager::_PutAddOn(ModuleAddOn *addon)
|
|||||||
|
|
||||||
|
|
||||||
// singleton instance
|
// singleton instance
|
||||||
ModuleManager ModuleManager::fDefaultManager;
|
ModuleManager ModuleManager::sDefaultManager;
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
// private emulation functions
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" status_t
|
||||||
|
_add_builtin_module(module_info *info)
|
||||||
|
{
|
||||||
|
return ModuleManager::Default()->AddBuiltInModule(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
// the functions to be emulated follow
|
// the functions to be emulated follow
|
||||||
|
|
||||||
|
|
||||||
// get_module
|
// get_module
|
||||||
status_t
|
status_t
|
||||||
get_module(const char *path, module_info **vec)
|
get_module(const char *path, module_info **vec)
|
||||||
@@ -627,6 +654,21 @@ close_module_list(void *cookie)
|
|||||||
(module_name_list*)cookie);
|
(module_name_list*)cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
panic(const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
puts("*** PANIC ***");
|
||||||
|
va_start(args, format);
|
||||||
|
vprintf(format, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// dprintf
|
// dprintf
|
||||||
void
|
void
|
||||||
dprintf(const char *format,...)
|
dprintf(const char *format,...)
|
||||||
@@ -692,3 +734,14 @@ user_strlcpy(char *to, const char *from, size_t size)
|
|||||||
return from_length;
|
return from_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! Needed for locking */
|
||||||
|
|
||||||
|
bool kernel_startup = false;
|
||||||
|
|
||||||
|
extern "C" bool
|
||||||
|
arch_int_are_interrupts_enabled(void)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user