2008-03-04 18:22:31 +00:00
|
|
|
#include <sys/sysmacros.h>
|
2008-03-14 00:04:01 +00:00
|
|
|
#include <sys/vmsystm.h>
|
|
|
|
#include <sys/vnode.h>
|
2008-03-14 20:56:26 +00:00
|
|
|
#include <sys/kmem.h>
|
2008-02-27 21:56:51 +00:00
|
|
|
#include "config.h"
|
2008-02-27 19:09:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Generic support
|
|
|
|
*/
|
|
|
|
|
|
|
|
int p0 = 0;
|
|
|
|
EXPORT_SYMBOL(p0);
|
2008-02-27 21:56:51 +00:00
|
|
|
|
2008-03-12 21:33:28 +00:00
|
|
|
char hw_serial[11];
|
|
|
|
EXPORT_SYMBOL(hw_serial);
|
|
|
|
|
2008-03-14 00:04:01 +00:00
|
|
|
vmem_t *zio_alloc_arena = NULL;
|
|
|
|
EXPORT_SYMBOL(zio_alloc_arena);
|
|
|
|
|
2008-03-06 23:12:55 +00:00
|
|
|
int
|
|
|
|
highbit(unsigned long i)
|
|
|
|
{
|
|
|
|
register int h = 1;
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
return (0);
|
|
|
|
#if BITS_PER_LONG == 64
|
|
|
|
if (i & 0xffffffff00000000ul) {
|
|
|
|
h += 32; i >>= 32;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (i & 0xffff0000) {
|
|
|
|
h += 16; i >>= 16;
|
|
|
|
}
|
|
|
|
if (i & 0xff00) {
|
|
|
|
h += 8; i >>= 8;
|
|
|
|
}
|
|
|
|
if (i & 0xf0) {
|
|
|
|
h += 4; i >>= 4;
|
|
|
|
}
|
|
|
|
if (i & 0xc) {
|
|
|
|
h += 2; i >>= 2;
|
|
|
|
}
|
|
|
|
if (i & 0x2) {
|
|
|
|
h += 1;
|
|
|
|
}
|
|
|
|
return (h);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(highbit);
|
|
|
|
|
2008-03-12 21:33:28 +00:00
|
|
|
int
|
|
|
|
ddi_strtoul(const char *str, char **nptr, int base, unsigned long *result)
|
|
|
|
{
|
|
|
|
char *end;
|
|
|
|
return (*result = simple_strtoul(str, &end, base));
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ddi_strtoul);
|
|
|
|
|
2008-02-27 21:56:51 +00:00
|
|
|
static int __init spl_init(void)
|
|
|
|
{
|
2008-03-14 00:04:01 +00:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = vn_init();
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2008-03-12 21:33:28 +00:00
|
|
|
strcpy(hw_serial, "007f0100"); /* loopback */
|
2008-02-27 21:56:51 +00:00
|
|
|
printk(KERN_INFO "spl: Loaded Solaris Porting Layer v%s\n", VERSION);
|
2008-03-14 00:04:01 +00:00
|
|
|
|
2008-03-14 20:56:26 +00:00
|
|
|
#ifdef DEBUG_KMEM
|
|
|
|
atomic64_set(&kmem_alloc_used, 0);
|
|
|
|
atomic64_set(&vmem_alloc_used, 0);
|
|
|
|
#endif
|
|
|
|
|
2008-02-27 21:56:51 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spl_fini(void)
|
|
|
|
{
|
2008-03-14 00:04:01 +00:00
|
|
|
vn_fini();
|
2008-03-14 20:56:26 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_KMEM
|
|
|
|
if (atomic64_read(&kmem_alloc_used) != 0)
|
|
|
|
printk("Warning: kmem leaked %ld/%ld bytes\n",
|
|
|
|
atomic_read(&kmem_alloc_used), kmem_alloc_max);
|
|
|
|
|
|
|
|
if (atomic64_read(&vmem_alloc_used) != 0)
|
|
|
|
printk("Warning: vmem leaked %ld/%ld bytes\n",
|
|
|
|
atomic_read(&vmem_alloc_used), vmem_alloc_max);
|
|
|
|
#endif
|
|
|
|
|
2008-02-27 21:56:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(spl_init);
|
|
|
|
module_exit(spl_fini);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Lawrence Livermore National Labs");
|
|
|
|
MODULE_DESCRIPTION("Solaris Porting Layer");
|
|
|
|
MODULE_LICENSE("GPL");
|