Hopefully this patch includes all the of feedback from the last one. This patch adds a character device driver to allow user space access to the aranym natfeats nfstderr. Peace, Stephen Signed-off-by: Stephen R. Marenka <stephen@xxxxxxxxxxx> --- linux-2.6.22/arch/m68k/emu/nfstderr.c.orig 1969-12-31 18:00:00.000000000 -0600 +++ linux-2.6.22/arch/m68k/emu/nfstderr.c 2008-01-12 09:53:13.000000000 -0600 @@ -0,0 +1,90 @@ +/* + * atari_nfstderr.c - ARAnyM NF_STDERR handler for GNU/Linux + * + * With this module you may write to the emulator's stderr output + * (the native console). + * + * Copyright (c) 2008 Stephen R. Marenka + * + * Based on the ARAnyM driver for FreeMiNT written by Standa Opichal. + * + * This software may be used and distributed according to the terms of + * the GNU General Public License (GPL), incorporated herein by reference. + */ + +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/init.h> +#include <linux/kernel.h> /* printk() */ +#include <linux/fs.h> /* everything... */ +#include <linux/errno.h> /* error codes */ +#include <linux/types.h> /* size_t */ +#include <linux/miscdevice.h> +#include <asm/uaccess.h> /* copy_*_user */ +#include <asm/natfeat.h> + +/* natfeats id */ +int nfstderr_id; + + +MODULE_AUTHOR("Stephen R. Marenka"); +MODULE_DESCRIPTION("ARAnyM NFstderr driver"); +MODULE_LICENSE("GPL"); + + +ssize_t nfstderr_write(struct file *filp, const char __user *str, size_t count, + loff_t *f_pos) +{ + char buf[68]; + size_t retcount = count; + + buf[64] = 0; + while (count > 64) { + copy_from_user(buf, str, 64); + nf_call(nfstderr_id, buf); + str += 64; + count -= 64; + } + copy_from_user(buf, str, count); + buf[count] = 0; + nf_call(nfstderr_id, buf); + + return retcount; +} + +struct file_operations nfstderr_fops = { + .owner = THIS_MODULE, + .write = nfstderr_write, +}; + +struct miscdevice nfstderr_misc = { + .minor = MISC_DYNAMIC_MINOR, + .name = "nfstderr", + .fops = &nfstderr_fops +}; + +int nfstderr_init_module(void) +{ + int result; + + nfstderr_id = nf_get_id("NF_STDERR"); + if (!nfstderr_id) { + printk(KERN_ERR "nfstderr: error can't find natfeats\n"); + return -1; + } + + result = misc_register(&nfstderr_misc); + if (result) { + printk(KERN_ERR "nfstderr: Unable to register misc device\n"); + return result; + } + return 0; +} + +void nfstderr_cleanup_module(void) +{ + misc_deregister(&nfstderr_misc); +} + +module_init(nfstderr_init_module); +module_exit(nfstderr_cleanup_module); --- linux-2.6.22/arch/m68k/emu/Makefile.orig 2008-01-09 12:42:03.000000000 -0600 +++ linux-2.6.22/arch/m68k/emu/Makefile 2008-01-10 16:45:07.000000000 -0600 @@ -2,6 +2,6 @@ # Makefile for Linux arch/m68k/emu source directory # -obj-y += natfeat.o +obj-y += natfeat.o nfstderr.o obj-$(CONFIG_NFETH) += nfeth.o -- Stephen R. Marenka If life's not fun, you're not doing it right! <stephen@xxxxxxxxxxx>
Attachment:
signature.asc
Description: Digital signature