--- schemix.c.orig 2003-04-29 06:05:42.000000000 +0200 +++ /home/dzu/linuxppc_2_4_devel/drivers/char/schemix.c 2003-04-29 06:59:35.000000000 +0200 @@ -51,6 +51,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef CONFIG_DEVICE_FS +#include +#endif + #include "schemix.h" #define TOK_EOF (-1) @@ -271,9 +275,11 @@ long number_of_mallocs; static void *malloc( long size ) { - number_of_mallocs++; static long total=0; - void *toret = vmalloc(size); + void *toret; + + number_of_mallocs++; + toret = vmalloc(size); total += size; #if SCHEMIX_DEBUG printk(KERN_ALERT "Schemix allocating %ld bytes (%ld allocated so far)... %s", @@ -1469,8 +1475,7 @@ static int strvcmp( const char* name_wit static void* kernel_symbol_lookup( char* name ) { - struct module *mod; - mod = &the_kernel; + struct module *mod = &the_kernel; size_t i; struct module_symbol *s; s = mod->syms; @@ -1574,9 +1579,12 @@ EXPORT_SYMBOL(test_var); /* call a kernel getter */ pointer call_kernel_getter(scheme *sc, pointer proc) { + pointer type; + void* var_ptr; + printk( KERN_ALERT "test_var = %d\n", test_var ); - pointer type = car(proc); - void* var_ptr = avalue_unchecked(cdr(proc)); + type = car(proc); + var_ptr = avalue_unchecked(cdr(proc)); /* FIXME: parse type properly! */ if( is_symbol(car(type)) && strcmp(symname(car(type)), "int") == 0 ) /* var holds a single int */ return mk_integer( sc, (long)(*((int*)var_ptr)) ); @@ -1596,10 +1604,13 @@ static pointer mk_kernel_setter(scheme * /* call a kernel setter */ void call_kernel_setter(scheme *sc, pointer proc, pointer args) { + pointer type, x; + void* var_ptr; + printk( KERN_ALERT "test_var = %d\n", test_var ); - pointer type = car(proc); - pointer x = car(args); - void* var_ptr = avalue_unchecked(cdr(proc)); + type = car(proc); + x = car(args); + var_ptr = avalue_unchecked(cdr(proc)); /* FIXME: parse type properly! */ if( is_symbol(car(type)) && strcmp(symname(car(type)), "int") == 0 ) /* var holds a single int */ { @@ -3798,9 +3809,12 @@ void scheme_set_output_port_string(schem sc->outport=port_from_string(sc,start,past_the_end,port_output); } +static int schemix_major=0; + void scheme_deinit(scheme *sc) { int i; + devfs_unregister_chrdev( schemix_major, "schemix" ); devfs_unregister( sc->devfs_handle ); sc->oblist=sc->NIL; @@ -3876,6 +3890,10 @@ scheme* make_device(scheme *sc, char *na #if SCHEMIX_DEBUG printk(KERN_ALERT "Registering device '%s'...\n", name); #endif + + if ((schemix_major=devfs_register_chrdev(0, name, &schemix_file_ops))<0) + return NULL; + new_scheme->devfs_handle = devfs_register( NULL, name, DEVFS_FL_AUTO_DEVNUM, 0, 0, S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, &schemix_file_ops, (void*)new_scheme ); @@ -3939,7 +3957,7 @@ static void schemix_exit(void) static int device_open( struct inode *inode, struct file *file ) { - scheme *sc = (scheme*)file->private_data; + scheme *sc = root_sc; #if SCHEMIX_DEBUG printk(KERN_ALERT "Schemix device open\n"); #endif @@ -3952,7 +3970,7 @@ static int device_open( struct inode *in static int device_release( struct inode *inode, struct file *file ) { - scheme *sc = (scheme*)file->private_data; + scheme *sc = root_sc; #if SCHEMIX_DEBUG printk(KERN_ALERT "Schemix device closing\n"); #endif @@ -3965,10 +3983,11 @@ static ssize_t device_read( struct file size_t length, loff_t *offset ) { + unsigned int n; #if SCHEMIX_DEBUG printk(KERN_ALERT "Schemix device_read()\n"); #endif - scheme *sc = (scheme*)file->private_data; + scheme *sc = root_sc; /* Evaluate the user hook (if one is defined) */ /* FIXME: Check that *on-read* is a procedure */ if( find_slot_in_env(sc,sc->envir,sc->ON_READ,1) != sc->NIL ) @@ -3981,7 +4000,6 @@ static ssize_t device_read( struct file /* write as much as we can into buffer. if we get up to output_device_buffer_end then we reset */ - unsigned int n; for( n=0; noutput_buffer_pos < sc->output_buffer_end; n++ ) put_user( *(sc->output_buffer_pos++), buffer++ ); if( sc->output_buffer_pos == sc->output_buffer_end ) @@ -3996,7 +4014,7 @@ static ssize_t device_write( struct file { /* Evaluate the user hook (if one is defined). Otherwise, read and eval. */ - scheme *sc = (scheme*)file->private_data; + scheme *sc = root_sc; int hooked = (find_slot_in_env(sc,sc->envir,sc->ON_WRITE,1) != sc->NIL ); unsigned int n; char *i = sc->input_buffer;