On Wed, 24 Jul 2013, Thorsten Glaser wrote:
> Thorsten Glaser <tg <at> mirbsd.de> writes:
> > Andreas Schwab dixit:
> > >The problem is that aranym expects the parameters of the natfeat calls
> > >to be physical addresses.  The nf_get_id calls use literal strings as
> > >parameters which only works when the drivers are builtin because phys ==
> > >virt then.

And fixing the conversion is non-trivial, as module memory is allocated using
vmalloc(), which may be non-contiguous in physical memory space, right?

> > Ah, right, there was that issue… so this patch should probably go in?
> 
> At first, anyway.

I prefer a fix to go in instead :-)

> Maybe if CONFIG_NATFEAT is selected (it’s bool), some bounce buffer could
> be allocated and memlocked, which the other NF* drivers can then use.
> (If NatFeat is not found during boot, no memory should be allocated.)
> 
> Especially if we had more NF* drivers in the future (hostfs could be made
> into something, maybe with something like umsdos on top for Unix file
> permissions? And I’m hoping for a bidirectional “virtio/serial” console…)
> this could be useful sharing, and not needing to have everything else
> in the kernel statically.
> 
> Well, if someone has time and wants to write this.

It doesn't have to be that complex...

The patch below adds a wrapper that copies the (supposedly short) name to
the kernel stack before calling into ARAnyM.
Does this make modular NatFeat drivers work for you?
It doesn't break the built-in drivers for me.

ARAnyM hackers: What's the maximum size of ID names?

diff --git a/arch/m68k/emu/natfeat.c b/arch/m68k/emu/natfeat.c
index cb574ae..98655ef 100644
--- a/arch/m68k/emu/natfeat.c
+++ b/arch/m68k/emu/natfeat.c
@@ -19,9 +19,11 @@
 #include <asm/machdep.h>
 #include <asm/natfeat.h>
 
+extern long nf_get_id2(const char *feature_name);
+
 asm("\n"
-"      .global nf_get_id,nf_call\n"
-"nf_get_id:\n"
+"      .global nf_get_id2,nf_call\n"
+"nf_get_id2:\n"
 "      .short  0x7300\n"
 "      rts\n"
 "nf_call:\n"
@@ -30,12 +32,24 @@ asm("\n"
 "1:    moveq.l #0,%d0\n"
 "      rts\n"
 "      .section __ex_table,\"a\"\n"
-"      .long   nf_get_id,1b\n"
+"      .long   nf_get_id2,1b\n"
 "      .long   nf_call,1b\n"
 "      .previous");
-EXPORT_SYMBOL_GPL(nf_get_id);
 EXPORT_SYMBOL_GPL(nf_call);
 
+long nf_get_id(const char *feature_name)
+{
+       char name_copy[32]; // FIXME maximum size of ID names?
+       size_t n;
+
+       n = strlcpy(name_copy, feature_name, sizeof(name_copy));
+       if (n >= sizeof(name_copy))
+               return 0;
+
+       return nf_get_id2(name_copy);
+}
+EXPORT_SYMBOL_GPL(nf_get_id);
+
 void nfprint(const char *fmt, ...)
 {
        static char buf[256];

Gr{oetje,eeting}s,

                                                Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                                            -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to