[Haskell-cafe] Linux device drivers
Donald Bruce Stewart
dons at cse.unsw.edu.au
Mon Mar 21 00:42:03 EST 2005
> Wow! Did you also implement tcp in Haskell?
> Does hOp or House also have the ability to write to disk?
> (With HAppS, I've gotten rid of the AMP part of LAMP, it would be
> really cool to get rid of the L as well!)
Sorry! By "We've got a few drivers written in Haskell", I meant
"the Haskell community", not me personally :} You have the hOp and House
developers to thank for this stuff.
> On Mon, 21 Mar 2005, Donald Bruce Stewart wrote:
> >>I was wondering about the possibility of using Haskell for developing
> >>device drivers that would be kernel modules for Linux. If nothing else,
> >>it would be quite an educational experience for me, as I've not yet
> >>experimented with either the Linux kernel or Haskell FFI, nor have I
> >>had to learn how to squeeze much performance out of my Haskell code.
> >>Clearly, this application demands special things from the compiler and
> >>the runtime. But, I'm not exactly sure what, nor how to achieve such
> >>given current compilers. Does anyone have any thoughts?
> >Well, it would be tricky, but fun!
> >We've got a few drivers written in Haskell already (but not for Linux,
> >as far as I know). For example check out the House network stack and
> > http://cvs.haskell.org/cgi-bin/cvsweb.cgi/programatica/hOp/
> > http://cvs.haskell.org/cgi-bin/cvsweb.cgi/programatica/hOp/kernel/Kernel/Driver/NE2000/
> >So there's heavy use of Data.Bits and Word# types - but nothing that
> >isn't fairly well established in GHC Haskell, anyway.
> >Then (for GHC, anyway) you'd have to link the kernel against libHSrts.a,
> >as we do when calling Haskell from other kinds of C apps, which involves
> >compiling the C app with all the magic flags ghc normally sets up (ghc -v9
> >main.c is helpful). Something like: ;)
> >egcc -v -o a.out -DDONT_WANT_WIN32_DLL_SUPPORT main.o
> >-L/home/dons/lib/ghc-6.4 -lHStemplate-haskell -lHSCabal -lHSposix
> >-lHSposix_cbits -lHSlang -lHSmtl -lHShaskell-src -lHSunix -lHSunix_cbits
> >-lHShi -lHShaskell98 -lHSaltdata -lHSbase -lHSbase_cbits -lHSrts -lm -lgmp
> >-u GHCziBase_Izh_static_info -u GHCziBase_Czh_static_info -u
> >GHCziFloat_Fzh_static_info ...
> >Then, having the kernel start up the Haskell rts (at boot would be
> > hs_init(&argc, &argv);
> > .. do something in Haskell or C land ...
> > hs_exit();
> >Then you'd could dyn load (via GHC's rts) your Haskell driver into the C
> >app, and use it, as long as you've got a nice ffi interface to pass
> >values back and forward.
> >I'm sure the fun part is in the details ;)
> > Don
> >Haskell-Cafe mailing list
> >Haskell-Cafe at haskell.org
More information about the Haskell-Cafe