Metasepi team meeting #13: NetBSD driver using Haskell

Post on 28-Jan-2015

116 views 8 download

Tags:

description

Metasepi team meeting #13: NetBSD driver using Haskell

transcript

Metasepi team meeting #13: NetBSD driver using HaskellMetasepi team meeting #13: NetBSD driver using HaskellMetasepi team meeting #13: NetBSD driver using HaskellMetasepi team meeting #13: NetBSD driver using HaskellMetasepi team meeting #13:NetBSD driver using Haskell

Metasepi Project / Kiwamu OkabeMetasepi Project / Kiwamu OkabeMetasepi Project / Kiwamu OkabeMetasepi Project / Kiwamu OkabeMetasepi Project / Kiwamu Okabe

Who am I?Who am I?Who am I?Who am I?Who am I?

☆ http://www.masterq.net/☆ http://www.masterq.net/☆ http://www.masterq.net/☆ http://www.masterq.net/☆ http://www.masterq.net/

☆ Self employed software engineer☆ Self employed software engineer☆ Self employed software engineer☆ Self employed software engineer☆ Self employed software engineer

☆ Founder of Metasepi Project☆ Founder of Metasepi Project☆ Founder of Metasepi Project☆ Founder of Metasepi Project☆ Founder of Metasepi Project

☆ A developer of Ajhc Haskell compiler☆ A developer of Ajhc Haskell compiler☆ A developer of Ajhc Haskell compiler☆ A developer of Ajhc Haskell compiler☆ A developer of Ajhc Haskell compiler

☆ A Debian Maintainer☆ A Debian Maintainer☆ A Debian Maintainer☆ A Debian Maintainer☆ A Debian Maintainer

☆ 10 years' experience in developing OS using NetBSD.☆ 10 years' experience in developing OS using NetBSD.☆ 10 years' experience in developing OS using NetBSD.☆ 10 years' experience in developing OS using NetBSD.☆ 10 years' experience in developing OS using NetBSD.

AgendaAgendaAgendaAgendaAgenda

☆ [1] Demo☆ [1] Demo☆ [1] Demo☆ [1] Demo☆ [1] Demo

☆ [2] What is Ajhc?☆ [2] What is Ajhc?☆ [2] What is Ajhc?☆ [2] What is Ajhc?☆ [2] What is Ajhc?

☆ [3] What is Metasepi?☆ [3] What is Metasepi?☆ [3] What is Metasepi?☆ [3] What is Metasepi?☆ [3] What is Metasepi?

☆ [4] What is compiler to build OS☆ [4] What is compiler to build OS☆ [4] What is compiler to build OS☆ [4] What is compiler to build OS☆ [4] What is compiler to build OS

☆ [5] NetBSD driver using Haskell☆ [5] NetBSD driver using Haskell☆ [5] NetBSD driver using Haskell☆ [5] NetBSD driver using Haskell☆ [5] NetBSD driver using Haskell

☆ [6] Ajhc is the best?☆ [6] Ajhc is the best?☆ [6] Ajhc is the best?☆ [6] Ajhc is the best?☆ [6] Ajhc is the best?

☆ [7] From Arafura to Bohai☆ [7] From Arafura to Bohai☆ [7] From Arafura to Bohai☆ [7] From Arafura to Bohai☆ [7] From Arafura to Bohai

[1] Demo[1] Demo[1] Demo[1] Demo[1] Demo

☆ NetBSD audio driver play sound☆ NetBSD audio driver play sound☆ NetBSD audio driver play sound☆ NetBSD audio driver play sound☆ NetBSD audio driver play sound

☆ The driver's interrupt handler rewrited using Haskell☆ The driver's interrupt handler rewrited using Haskell☆ The driver's interrupt handler rewrited using Haskell☆ The driver's interrupt handler rewrited using Haskell☆ The driver's interrupt handler rewrited using Haskell

☆ Watch the movie at following☆ Watch the movie at following☆ Watch the movie at following☆ Watch the movie at following☆ Watch the movie at following

http://bitly.com/netbsdajhchttp://bitly.com/netbsdajhchttp://bitly.com/netbsdajhchttp://bitly.com/netbsdajhchttp://bitly.com/netbsdajhc

☆ The source code at following☆ The source code at following☆ The source code at following☆ The source code at following☆ The source code at following

github.com/metasepi/netbsd-arafura-s1github.com/metasepi/netbsd-arafura-s1github.com/metasepi/netbsd-arafura-s1github.com/metasepi/netbsd-arafura-s1github.com/metasepi/netbsd-arafura-s1

Demo architectureDemo architectureDemo architectureDemo architectureDemo architecture

[2] What is Ajhc?[2] What is Ajhc?[2] What is Ajhc?[2] What is Ajhc?[2] What is Ajhc?

http://ajhc.metasepi.org/http://ajhc.metasepi.org/http://ajhc.metasepi.org/http://ajhc.metasepi.org/http://ajhc.metasepi.org/

☆ Ajhc := Arafura designed jhc☆ Ajhc := Arafura designed jhc☆ Ajhc := Arafura designed jhc☆ Ajhc := Arafura designed jhc☆ Ajhc := Arafura designed jhc

☆ jhc := John's Haskell Compiler☆ jhc := John's Haskell Compiler☆ jhc := John's Haskell Compiler☆ jhc := John's Haskell Compiler☆ jhc := John's Haskell Compiler

☆ http://repetae.net/computer/jhc/☆ http://repetae.net/computer/jhc/☆ http://repetae.net/computer/jhc/☆ http://repetae.net/computer/jhc/☆ http://repetae.net/computer/jhc/

☆ Jhc outputs binary that has low-memory-footprint and runs fast.☆ Jhc outputs binary that has low-memory-footprint and runs fast.☆ Jhc outputs binary that has low-memory-footprint and runs fast.☆ Jhc outputs binary that has low-memory-footprint and runs fast.☆ Jhc outputs binary that has low-memory-footprint and runs fast.

☆ Good for embedded software.☆ Good for embedded software.☆ Good for embedded software.☆ Good for embedded software.☆ Good for embedded software.

Who is John?Who is John?Who is John?Who is John?Who is John?

☆ John Meacham☆ John Meacham☆ John Meacham☆ John Meacham☆ John Meacham

☆ http://repetae.net/☆ http://repetae.net/☆ http://repetae.net/☆ http://repetae.net/☆ http://repetae.net/

Why need Ajhc?Why need Ajhc?Why need Ajhc?Why need Ajhc?Why need Ajhc?

☆ GHC is de facto standard on Haskell.☆ GHC is de facto standard on Haskell.☆ GHC is de facto standard on Haskell.☆ GHC is de facto standard on Haskell.☆ GHC is de facto standard on Haskell.

☆ GHC := Glasgow Haskell Compiler☆ GHC := Glasgow Haskell Compiler☆ GHC := Glasgow Haskell Compiler☆ GHC := Glasgow Haskell Compiler☆ GHC := Glasgow Haskell Compiler

☆ http://www.haskell.org/ghc/☆ http://www.haskell.org/ghc/☆ http://www.haskell.org/ghc/☆ http://www.haskell.org/ghc/☆ http://www.haskell.org/ghc/

☆ Why need another Haskell compiler?☆ Why need another Haskell compiler?☆ Why need another Haskell compiler?☆ Why need another Haskell compiler?☆ Why need another Haskell compiler?

☆ To develop kernel named "Metasepi".☆ To develop kernel named "Metasepi".☆ To develop kernel named "Metasepi".☆ To develop kernel named "Metasepi".☆ To develop kernel named "Metasepi".

[3] What is Metasepi?[3] What is Metasepi?[3] What is Metasepi?[3] What is Metasepi?[3] What is Metasepi?

http://metasepi.org/http://metasepi.org/http://metasepi.org/http://metasepi.org/http://metasepi.org/

☆ Unix-like OS designed by strong type.☆ Unix-like OS designed by strong type.☆ Unix-like OS designed by strong type.☆ Unix-like OS designed by strong type.☆ Unix-like OS designed by strong type.

☆ Using ML or more strong type lang.☆ Using ML or more strong type lang.☆ Using ML or more strong type lang.☆ Using ML or more strong type lang.☆ Using ML or more strong type lang.

Haskell http://www.haskell.org/Haskell http://www.haskell.org/Haskell http://www.haskell.org/Haskell http://www.haskell.org/Haskell http://www.haskell.org/

OCaml http://caml.inria.fr/OCaml http://caml.inria.fr/OCaml http://caml.inria.fr/OCaml http://caml.inria.fr/OCaml http://caml.inria.fr/

MLton http://mlton.org/MLton http://mlton.org/MLton http://mlton.org/MLton http://mlton.org/MLton http://mlton.org/

. . . and suchlike.. . . and suchlike.. . . and suchlike.. . . and suchlike.. . . and suchlike.

Why need Metasepi?Why need Metasepi?Why need Metasepi?Why need Metasepi?Why need Metasepi?

☆ We have already Linux or Windows.☆ We have already Linux or Windows.☆ We have already Linux or Windows.☆ We have already Linux or Windows.☆ We have already Linux or Windows.

☆ But the developers are suffering.☆ But the developers are suffering.☆ But the developers are suffering.☆ But the developers are suffering.☆ But the developers are suffering.

☆ If use the kernel changed by you,☆ If use the kernel changed by you,☆ If use the kernel changed by you,☆ If use the kernel changed by you,☆ If use the kernel changed by you,

☆ you will get many runtime error.☆ you will get many runtime error.☆ you will get many runtime error.☆ you will get many runtime error.☆ you will get many runtime error.

☆ Difficult even to reproduce it.☆ Difficult even to reproduce it.☆ Difficult even to reproduce it.☆ Difficult even to reproduce it.☆ Difficult even to reproduce it.

Doesn't OSS have good quality?Doesn't OSS have good quality?Doesn't OSS have good quality?Doesn't OSS have good quality?Doesn't OSS have good quality?

☆ "The Cathedral and the Bazaar"☆ "The Cathedral and the Bazaar"☆ "The Cathedral and the Bazaar"☆ "The Cathedral and the Bazaar"☆ "The Cathedral and the Bazaar"

☆ "Given enough eyeballs, all bugs are shallow."☆ "Given enough eyeballs, all bugs are shallow."☆ "Given enough eyeballs, all bugs are shallow."☆ "Given enough eyeballs, all bugs are shallow."☆ "Given enough eyeballs, all bugs are shallow."http://cruel.org/freeware/cathedral.htmlhttp://cruel.org/freeware/cathedral.htmlhttp://cruel.org/freeware/cathedral.htmlhttp://cruel.org/freeware/cathedral.htmlhttp://cruel.org/freeware/cathedral.html

☆ But if you develop your own product reusing OSS...☆ But if you develop your own product reusing OSS...☆ But if you develop your own product reusing OSS...☆ But if you develop your own product reusing OSS...☆ But if you develop your own product reusing OSS...

Low quality out of OSS umbrellaLow quality out of OSS umbrellaLow quality out of OSS umbrellaLow quality out of OSS umbrellaLow quality out of OSS umbrella

Type safetyType safetyType safetyType safetyType safety

☆ Less runtime errors.☆ Less runtime errors.☆ Less runtime errors.☆ Less runtime errors.☆ Less runtime errors.

☆ "数理科学的バグ撲滅方法論のすすめ"☆ "数理科学的バグ撲滅方法論のすすめ"☆ "数理科学的バグ撲滅方法論のすすめ"☆ "数理科学的バグ撲滅方法論のすすめ"☆ "数理科学的バグ撲滅方法論のすすめ"http://itpro.nikkeibp.co.jp/article/COLUMN/20060915/248230/http://itpro.nikkeibp.co.jp/article/COLUMN/20060915/248230/http://itpro.nikkeibp.co.jp/article/COLUMN/20060915/248230/http://itpro.nikkeibp.co.jp/article/COLUMN/20060915/248230/http://itpro.nikkeibp.co.jp/article/COLUMN/20060915/248230/

Kernel wants type desperatelyKernel wants type desperatelyKernel wants type desperatelyKernel wants type desperatelyKernel wants type desperately

☆ Kernels are developed with C lang.☆ Kernels are developed with C lang.☆ Kernels are developed with C lang.☆ Kernels are developed with C lang.☆ Kernels are developed with C lang.

☆ Error on user space => SEGV☆ Error on user space => SEGV☆ Error on user space => SEGV☆ Error on user space => SEGV☆ Error on user space => SEGV

☆ Error on kernel space => Halt!☆ Error on kernel space => Halt!☆ Error on kernel space => Halt!☆ Error on kernel space => Halt!☆ Error on kernel space => Halt!

☆ Should design kernel with the greatest care.☆ Should design kernel with the greatest care.☆ Should design kernel with the greatest care.☆ Should design kernel with the greatest care.☆ Should design kernel with the greatest care.

☆ C language is safe?☆ C language is safe?☆ C language is safe?☆ C language is safe?☆ C language is safe?

[4] What is compiler to build OS[4] What is compiler to build OS[4] What is compiler to build OS[4] What is compiler to build OS[4] What is compiler to build OS

☆ Need strong type.☆ Need strong type.☆ Need strong type.☆ Need strong type.☆ Need strong type.

☆ Need flexibility such as C language.☆ Need flexibility such as C language.☆ Need flexibility such as C language.☆ Need flexibility such as C language.☆ Need flexibility such as C language.

☆ Create it if there are not!☆ Create it if there are not!☆ Create it if there are not!☆ Create it if there are not!☆ Create it if there are not!

☆ From scratch? No thank you...☆ From scratch? No thank you...☆ From scratch? No thank you...☆ From scratch? No thank you...☆ From scratch? No thank you...

☆ Look for our compiler base.☆ Look for our compiler base.☆ Look for our compiler base.☆ Look for our compiler base.☆ Look for our compiler base.

Want POSIX free compilerWant POSIX free compilerWant POSIX free compilerWant POSIX free compilerWant POSIX free compiler

Programs to print "hoge" on terminal.Programs to print "hoge" on terminal.Programs to print "hoge" on terminal.Programs to print "hoge" on terminal.Programs to print "hoge" on terminal.

The lesser depends on POSIX, the smaller values.The lesser depends on POSIX, the smaller values.The lesser depends on POSIX, the smaller values.The lesser depends on POSIX, the smaller values.The lesser depends on POSIX, the smaller values.

Jhc output has only 20 undefJhc output has only 20 undefJhc output has only 20 undefJhc output has only 20 undefJhc output has only 20 undef$ nm hs.out | grep "U " U _IO_putc@@GLIBC_2.2.5 U __libc_start_main@@GLIBC_2.2.5 U _setjmp@@GLIBC_2.2.5 U abort@@GLIBC_2.2.5 U ctime@@GLIBC_2.2.5 U exit@@GLIBC_2.2.5 U fflush@@GLIBC_2.2.5 U fprintf@@GLIBC_2.2.5 U fputc@@GLIBC_2.2.5 U fputs@@GLIBC_2.2.5 U free@@GLIBC_2.2.5 U fwrite@@GLIBC_2.2.5 U getenv@@GLIBC_2.2.5 U malloc@@GLIBC_2.2.5 U memset@@GLIBC_2.2.5 U posix_memalign@@GLIBC_2.2.5 U realloc@@GLIBC_2.2.5 U setlocale@@GLIBC_2.2.5 U sysconf@@GLIBC_2.2.5 U times@@GLIBC_2.2.5

$ nm hs.out | grep "U " U _IO_putc@@GLIBC_2.2.5 U __libc_start_main@@GLIBC_2.2.5 U _setjmp@@GLIBC_2.2.5 U abort@@GLIBC_2.2.5 U ctime@@GLIBC_2.2.5 U exit@@GLIBC_2.2.5 U fflush@@GLIBC_2.2.5 U fprintf@@GLIBC_2.2.5 U fputc@@GLIBC_2.2.5 U fputs@@GLIBC_2.2.5 U free@@GLIBC_2.2.5 U fwrite@@GLIBC_2.2.5 U getenv@@GLIBC_2.2.5 U malloc@@GLIBC_2.2.5 U memset@@GLIBC_2.2.5 U posix_memalign@@GLIBC_2.2.5 U realloc@@GLIBC_2.2.5 U setlocale@@GLIBC_2.2.5 U sysconf@@GLIBC_2.2.5 U times@@GLIBC_2.2.5

$ nm hs.out | grep "U " U _IO_putc@@GLIBC_2.2.5 U __libc_start_main@@GLIBC_2.2.5 U _setjmp@@GLIBC_2.2.5 U abort@@GLIBC_2.2.5 U ctime@@GLIBC_2.2.5 U exit@@GLIBC_2.2.5 U fflush@@GLIBC_2.2.5 U fprintf@@GLIBC_2.2.5 U fputc@@GLIBC_2.2.5 U fputs@@GLIBC_2.2.5 U free@@GLIBC_2.2.5 U fwrite@@GLIBC_2.2.5 U getenv@@GLIBC_2.2.5 U malloc@@GLIBC_2.2.5 U memset@@GLIBC_2.2.5 U posix_memalign@@GLIBC_2.2.5 U realloc@@GLIBC_2.2.5 U setlocale@@GLIBC_2.2.5 U sysconf@@GLIBC_2.2.5 U times@@GLIBC_2.2.5

$ nm hs.out | grep "U " U _IO_putc@@GLIBC_2.2.5 U __libc_start_main@@GLIBC_2.2.5 U _setjmp@@GLIBC_2.2.5 U abort@@GLIBC_2.2.5 U ctime@@GLIBC_2.2.5 U exit@@GLIBC_2.2.5 U fflush@@GLIBC_2.2.5 U fprintf@@GLIBC_2.2.5 U fputc@@GLIBC_2.2.5 U fputs@@GLIBC_2.2.5 U free@@GLIBC_2.2.5 U fwrite@@GLIBC_2.2.5 U getenv@@GLIBC_2.2.5 U malloc@@GLIBC_2.2.5 U memset@@GLIBC_2.2.5 U posix_memalign@@GLIBC_2.2.5 U realloc@@GLIBC_2.2.5 U setlocale@@GLIBC_2.2.5 U sysconf@@GLIBC_2.2.5 U times@@GLIBC_2.2.5

$ nm hs.out | grep "U " U _IO_putc@@GLIBC_2.2.5 U __libc_start_main@@GLIBC_2.2.5 U _setjmp@@GLIBC_2.2.5 U abort@@GLIBC_2.2.5 U ctime@@GLIBC_2.2.5 U exit@@GLIBC_2.2.5 U fflush@@GLIBC_2.2.5 U fprintf@@GLIBC_2.2.5 U fputc@@GLIBC_2.2.5 U fputs@@GLIBC_2.2.5 U free@@GLIBC_2.2.5 U fwrite@@GLIBC_2.2.5 U getenv@@GLIBC_2.2.5 U malloc@@GLIBC_2.2.5 U memset@@GLIBC_2.2.5 U posix_memalign@@GLIBC_2.2.5 U realloc@@GLIBC_2.2.5 U setlocale@@GLIBC_2.2.5 U sysconf@@GLIBC_2.2.5 U times@@GLIBC_2.2.5

Jhc is translator to C languageJhc is translator to C languageJhc is translator to C languageJhc is translator to C languageJhc is translator to C language

Easy to cross buildEasy to cross buildEasy to cross buildEasy to cross buildEasy to cross build

Survive burning outSurvive burning outSurvive burning outSurvive burning outSurvive burning out

Let's develop with dogfooding style. (The method is called "Snatch".)Let's develop with dogfooding style. (The method is called "Snatch".)Let's develop with dogfooding style. (The method is called "Snatch".)Let's develop with dogfooding style. (The method is called "Snatch".)Let's develop with dogfooding style. (The method is called "Snatch".)

[5] NetBSD driver using Haskell[5] NetBSD driver using Haskell[5] NetBSD driver using Haskell[5] NetBSD driver using Haskell[5] NetBSD driver using Haskell

☆ Snatch target: HD Audio driver☆ Snatch target: HD Audio driver☆ Snatch target: HD Audio driver☆ Snatch target: HD Audio driver☆ Snatch target: HD Audio driversys/dev/pci/hdaudio |-- Makefile |-- ceareg.h |-- eldreg.h |-- files.hdaudio |-- hdafg.c |-- hdafg_dd.c |-- hdafg_dd.h |-- hdaudio.c |-- hdaudio_config.h |-- hdaudio_ids.c |-- hdaudio_ids.h |-- hdaudio_mixer.h |-- hdaudio_pci.c |-- hdaudio_pci.h |-- hdaudioio.h |-- hdaudioreg.h |-- hdaudiovar.h `-- hdmireg.h

sys/dev/pci/hdaudio |-- Makefile |-- ceareg.h |-- eldreg.h |-- files.hdaudio |-- hdafg.c |-- hdafg_dd.c |-- hdafg_dd.h |-- hdaudio.c |-- hdaudio_config.h |-- hdaudio_ids.c |-- hdaudio_ids.h |-- hdaudio_mixer.h |-- hdaudio_pci.c |-- hdaudio_pci.h |-- hdaudioio.h |-- hdaudioreg.h |-- hdaudiovar.h `-- hdmireg.h

sys/dev/pci/hdaudio |-- Makefile |-- ceareg.h |-- eldreg.h |-- files.hdaudio |-- hdafg.c |-- hdafg_dd.c |-- hdafg_dd.h |-- hdaudio.c |-- hdaudio_config.h |-- hdaudio_ids.c |-- hdaudio_ids.h |-- hdaudio_mixer.h |-- hdaudio_pci.c |-- hdaudio_pci.h |-- hdaudioio.h |-- hdaudioreg.h |-- hdaudiovar.h `-- hdmireg.h

sys/dev/pci/hdaudio |-- Makefile |-- ceareg.h |-- eldreg.h |-- files.hdaudio |-- hdafg.c |-- hdafg_dd.c |-- hdafg_dd.h |-- hdaudio.c |-- hdaudio_config.h |-- hdaudio_ids.c |-- hdaudio_ids.h |-- hdaudio_mixer.h |-- hdaudio_pci.c |-- hdaudio_pci.h |-- hdaudioio.h |-- hdaudioreg.h |-- hdaudiovar.h `-- hdmireg.h

sys/dev/pci/hdaudio |-- Makefile |-- ceareg.h |-- eldreg.h |-- files.hdaudio |-- hdafg.c |-- hdafg_dd.c |-- hdafg_dd.h |-- hdaudio.c |-- hdaudio_config.h |-- hdaudio_ids.c |-- hdaudio_ids.h |-- hdaudio_mixer.h |-- hdaudio_pci.c |-- hdaudio_pci.h |-- hdaudioio.h |-- hdaudioreg.h |-- hdaudiovar.h `-- hdmireg.h

Rewrited the driver entirety?Rewrited the driver entirety?Rewrited the driver entirety?Rewrited the driver entirety?Rewrited the driver entirety?

☆ No, partly☆ No, partly☆ No, partly☆ No, partly☆ No, partly

Where is Haskell code? (cont.)Where is Haskell code? (cont.)Where is Haskell code? (cont.)Where is Haskell code? (cont.)Where is Haskell code? (cont.)netbsd-arafura-s1 # <= based on NetBSD original source tree|-- BUILDING|-- GNUmakefile # <= Wrapper for building kernel|-- Makefile|-- Makefile.inc-- snip --|-- metasepi| |-- sound| | |-- Epopsan-signal.mp3| | `-- TheMojitoofFluorescence.mp3| `-- sys| |-- conf| | `-- files.haskell| |-- hsdummy # <= C code to support Ajhc runtime| `-- hssrc # <= Haskell code located| |-- Arch| | `-- I386| | |-- I386| | | `-- BusDma.hs| | `-- Include| | |-- BusDefs.hs| | |-- Cpu.hs| | `-- Types.hs

netbsd-arafura-s1 # <= based on NetBSD original source tree|-- BUILDING|-- GNUmakefile # <= Wrapper for building kernel|-- Makefile|-- Makefile.inc-- snip --|-- metasepi| |-- sound| | |-- Epopsan-signal.mp3| | `-- TheMojitoofFluorescence.mp3| `-- sys| |-- conf| | `-- files.haskell| |-- hsdummy # <= C code to support Ajhc runtime| `-- hssrc # <= Haskell code located| |-- Arch| | `-- I386| | |-- I386| | | `-- BusDma.hs| | `-- Include| | |-- BusDefs.hs| | |-- Cpu.hs| | `-- Types.hs

netbsd-arafura-s1 # <= based on NetBSD original source tree|-- BUILDING|-- GNUmakefile # <= Wrapper for building kernel|-- Makefile|-- Makefile.inc-- snip --|-- metasepi| |-- sound| | |-- Epopsan-signal.mp3| | `-- TheMojitoofFluorescence.mp3| `-- sys| |-- conf| | `-- files.haskell| |-- hsdummy # <= C code to support Ajhc runtime| `-- hssrc # <= Haskell code located| |-- Arch| | `-- I386| | |-- I386| | | `-- BusDma.hs| | `-- Include| | |-- BusDefs.hs| | |-- Cpu.hs| | `-- Types.hs

netbsd-arafura-s1 # <= based on NetBSD original source tree|-- BUILDING|-- GNUmakefile # <= Wrapper for building kernel|-- Makefile|-- Makefile.inc-- snip --|-- metasepi| |-- sound| | |-- Epopsan-signal.mp3| | `-- TheMojitoofFluorescence.mp3| `-- sys| |-- conf| | `-- files.haskell| |-- hsdummy # <= C code to support Ajhc runtime| `-- hssrc # <= Haskell code located| |-- Arch| | `-- I386| | |-- I386| | | `-- BusDma.hs| | `-- Include| | |-- BusDefs.hs| | |-- Cpu.hs| | `-- Types.hs

netbsd-arafura-s1 # <= based on NetBSD original source tree|-- BUILDING|-- GNUmakefile # <= Wrapper for building kernel|-- Makefile|-- Makefile.inc-- snip --|-- metasepi| |-- sound| | |-- Epopsan-signal.mp3| | `-- TheMojitoofFluorescence.mp3| `-- sys| |-- conf| | `-- files.haskell| |-- hsdummy # <= C code to support Ajhc runtime| `-- hssrc # <= Haskell code located| |-- Arch| | `-- I386| | |-- I386| | | `-- BusDma.hs| | `-- Include| | |-- BusDefs.hs| | |-- Cpu.hs| | `-- Types.hs

Where is Haskell code? (cont.)Where is Haskell code? (cont.)Where is Haskell code? (cont.)Where is Haskell code? (cont.)Where is Haskell code? (cont.)| |-- Dev| | |-- Auconv.hs| | |-- AudioIf.hs| | |-- Ic| | | |-- Ac97reg.hs| | | `-- Ac97var.hs| | `-- Pci| | |-- Auich| | | |-- Intr.hs| | | `-- Ptr.hs| | |-- Auich.hs| | |-- Auichreg.hs| | `-- Hdaudio| | |-- Hdaudio.hs| | |-- Hdaudioreg.hs| | `-- Hdaudiovar.hs| |-- Kern| | |-- KernMutex.hs| | |-- SubrKmem.hs| | `-- SubrPrf.hs| |-- Lib| | `-- Libkern| | `-- Libkern.hs

| |-- Dev| | |-- Auconv.hs| | |-- AudioIf.hs| | |-- Ic| | | |-- Ac97reg.hs| | | `-- Ac97var.hs| | `-- Pci| | |-- Auich| | | |-- Intr.hs| | | `-- Ptr.hs| | |-- Auich.hs| | |-- Auichreg.hs| | `-- Hdaudio| | |-- Hdaudio.hs| | |-- Hdaudioreg.hs| | `-- Hdaudiovar.hs| |-- Kern| | |-- KernMutex.hs| | |-- SubrKmem.hs| | `-- SubrPrf.hs| |-- Lib| | `-- Libkern| | `-- Libkern.hs

| |-- Dev| | |-- Auconv.hs| | |-- AudioIf.hs| | |-- Ic| | | |-- Ac97reg.hs| | | `-- Ac97var.hs| | `-- Pci| | |-- Auich| | | |-- Intr.hs| | | `-- Ptr.hs| | |-- Auich.hs| | |-- Auichreg.hs| | `-- Hdaudio| | |-- Hdaudio.hs| | |-- Hdaudioreg.hs| | `-- Hdaudiovar.hs| |-- Kern| | |-- KernMutex.hs| | |-- SubrKmem.hs| | `-- SubrPrf.hs| |-- Lib| | `-- Libkern| | `-- Libkern.hs

| |-- Dev| | |-- Auconv.hs| | |-- AudioIf.hs| | |-- Ic| | | |-- Ac97reg.hs| | | `-- Ac97var.hs| | `-- Pci| | |-- Auich| | | |-- Intr.hs| | | `-- Ptr.hs| | |-- Auich.hs| | |-- Auichreg.hs| | `-- Hdaudio| | |-- Hdaudio.hs| | |-- Hdaudioreg.hs| | `-- Hdaudiovar.hs| |-- Kern| | |-- KernMutex.hs| | |-- SubrKmem.hs| | `-- SubrPrf.hs| |-- Lib| | `-- Libkern| | `-- Libkern.hs

| |-- Dev| | |-- Auconv.hs| | |-- AudioIf.hs| | |-- Ic| | | |-- Ac97reg.hs| | | `-- Ac97var.hs| | `-- Pci| | |-- Auich| | | |-- Intr.hs| | | `-- Ptr.hs| | |-- Auich.hs| | |-- Auichreg.hs| | `-- Hdaudio| | |-- Hdaudio.hs| | |-- Hdaudioreg.hs| | `-- Hdaudiovar.hs| |-- Kern| | |-- KernMutex.hs| | |-- SubrKmem.hs| | `-- SubrPrf.hs| |-- Lib| | `-- Libkern| | `-- Libkern.hs

Where is Haskell code?Where is Haskell code?Where is Haskell code?Where is Haskell code?Where is Haskell code?| |-- Main.hs| |-- Metasepi| | `-- EitherIO.hs| `-- Sys| |-- Audioio.hs| |-- Bus.hs| |-- Device.hs| |-- Errno.hs| |-- Proc.hs| `-- Types.hs|-- regress|-- rescue|-- sbin|-- share|-- sys|-- tests|-- tools|-- travis-ci|-- usr.bin|-- usr.sbin`-- x11

| |-- Main.hs| |-- Metasepi| | `-- EitherIO.hs| `-- Sys| |-- Audioio.hs| |-- Bus.hs| |-- Device.hs| |-- Errno.hs| |-- Proc.hs| `-- Types.hs|-- regress|-- rescue|-- sbin|-- share|-- sys|-- tests|-- tools|-- travis-ci|-- usr.bin|-- usr.sbin`-- x11

| |-- Main.hs| |-- Metasepi| | `-- EitherIO.hs| `-- Sys| |-- Audioio.hs| |-- Bus.hs| |-- Device.hs| |-- Errno.hs| |-- Proc.hs| `-- Types.hs|-- regress|-- rescue|-- sbin|-- share|-- sys|-- tests|-- tools|-- travis-ci|-- usr.bin|-- usr.sbin`-- x11

| |-- Main.hs| |-- Metasepi| | `-- EitherIO.hs| `-- Sys| |-- Audioio.hs| |-- Bus.hs| |-- Device.hs| |-- Errno.hs| |-- Proc.hs| `-- Types.hs|-- regress|-- rescue|-- sbin|-- share|-- sys|-- tests|-- tools|-- travis-ci|-- usr.bin|-- usr.sbin`-- x11

| |-- Main.hs| |-- Metasepi| | `-- EitherIO.hs| `-- Sys| |-- Audioio.hs| |-- Bus.hs| |-- Device.hs| |-- Errno.hs| |-- Proc.hs| `-- Types.hs|-- regress|-- rescue|-- sbin|-- share|-- sys|-- tests|-- tools|-- travis-ci|-- usr.bin|-- usr.sbin`-- x11

How to buildHow to buildHow to buildHow to buildHow to build

☆ Install some packages☆ Install some packages☆ Install some packages☆ Install some packages☆ Install some packages$ sudo apt-get install ffmpeg qemu gcc$ sudo apt-get install ffmpeg qemu gcc$ sudo apt-get install ffmpeg qemu gcc$ sudo apt-get install ffmpeg qemu gcc$ sudo apt-get install ffmpeg qemu gcc

☆ Install Ajhc and git clone☆ Install Ajhc and git clone☆ Install Ajhc and git clone☆ Install Ajhc and git clone☆ Install Ajhc and git clone$ git clone https://github.com/metasepi/netbsd-arafura-s1.git$ cd netbsd-arafura-s1$ git clone https://github.com/metasepi/netbsd-arafura-s1.git$ cd netbsd-arafura-s1$ git clone https://github.com/metasepi/netbsd-arafura-s1.git$ cd netbsd-arafura-s1$ git clone https://github.com/metasepi/netbsd-arafura-s1.git$ cd netbsd-arafura-s1$ git clone https://github.com/metasepi/netbsd-arafura-s1.git$ cd netbsd-arafura-s1

☆ Build QEMU image☆ Build QEMU image☆ Build QEMU image☆ Build QEMU image☆ Build QEMU image$ make bootcd$ make bootcd$ make bootcd$ make bootcd$ make bootcd

Run the kernelRun the kernelRun the kernelRun the kernelRun the kernel

Run kernel on qemuRun kernel on qemuRun kernel on qemuRun kernel on qemuRun kernel on qemu$ make qemu

>> NetBSD/x86 BIOS Boot, Revision 5.9 (from NetBSD 6.1.1_PATCH)>> Memory: 639/1047544 k--snip--Created tmpfs /dev (1490944 byte, 2880 inodes)erase ^?, werase ^W, kill ^U, intr ^CThis image contains utilities which may be neededto get you out of a pinch.#

$ make qemu

>> NetBSD/x86 BIOS Boot, Revision 5.9 (from NetBSD 6.1.1_PATCH)>> Memory: 639/1047544 k--snip--Created tmpfs /dev (1490944 byte, 2880 inodes)erase ^?, werase ^W, kill ^U, intr ^CThis image contains utilities which may be neededto get you out of a pinch.#

$ make qemu

>> NetBSD/x86 BIOS Boot, Revision 5.9 (from NetBSD 6.1.1_PATCH)>> Memory: 639/1047544 k--snip--Created tmpfs /dev (1490944 byte, 2880 inodes)erase ^?, werase ^W, kill ^U, intr ^CThis image contains utilities which may be neededto get you out of a pinch.#

$ make qemu

>> NetBSD/x86 BIOS Boot, Revision 5.9 (from NetBSD 6.1.1_PATCH)>> Memory: 639/1047544 k--snip--Created tmpfs /dev (1490944 byte, 2880 inodes)erase ^?, werase ^W, kill ^U, intr ^CThis image contains utilities which may be neededto get you out of a pinch.#

$ make qemu

>> NetBSD/x86 BIOS Boot, Revision 5.9 (from NetBSD 6.1.1_PATCH)>> Memory: 639/1047544 k--snip--Created tmpfs /dev (1490944 byte, 2880 inodes)erase ^?, werase ^W, kill ^U, intr ^CThis image contains utilities which may be neededto get you out of a pinch.#

Kick play.sh script to play soundKick play.sh script to play soundKick play.sh script to play soundKick play.sh script to play soundKick play.sh script to play sound# ./play.sh# ./play.sh# ./play.sh# ./play.sh# ./play.sh

Build processBuild processBuild processBuild processBuild process

How to call C (figure)How to call C (figure)How to call C (figure)How to call C (figure)How to call C (figure)

How to call C (code)How to call C (code)How to call C (code)How to call C (code)How to call C (code)-- File: metasepi/sys/hssrc/Sys/Bus.hsbusSpaceRead4 = c_bus_space_read_4busSpaceWrite4 = c_bus_space_write_4foreign import ccall "hs_extern.h bus_space_read_4" c_bus_space_read_4 :: BusSpaceTagT -> BusSpaceHandleT -> BusSizeT -> IO Word32foreign import ccall "hs_extern.h bus_space_write_4" c_bus_space_write_4 :: BusSpaceTagT -> BusSpaceHandleT -> BusSizeT -> Word32 -> IO ()

-- File: metasepi/sys/hssrc/Sys/Bus.hsbusSpaceRead4 = c_bus_space_read_4busSpaceWrite4 = c_bus_space_write_4foreign import ccall "hs_extern.h bus_space_read_4" c_bus_space_read_4 :: BusSpaceTagT -> BusSpaceHandleT -> BusSizeT -> IO Word32foreign import ccall "hs_extern.h bus_space_write_4" c_bus_space_write_4 :: BusSpaceTagT -> BusSpaceHandleT -> BusSizeT -> Word32 -> IO ()

-- File: metasepi/sys/hssrc/Sys/Bus.hsbusSpaceRead4 = c_bus_space_read_4busSpaceWrite4 = c_bus_space_write_4foreign import ccall "hs_extern.h bus_space_read_4" c_bus_space_read_4 :: BusSpaceTagT -> BusSpaceHandleT -> BusSizeT -> IO Word32foreign import ccall "hs_extern.h bus_space_write_4" c_bus_space_write_4 :: BusSpaceTagT -> BusSpaceHandleT -> BusSizeT -> Word32 -> IO ()

-- File: metasepi/sys/hssrc/Sys/Bus.hsbusSpaceRead4 = c_bus_space_read_4busSpaceWrite4 = c_bus_space_write_4foreign import ccall "hs_extern.h bus_space_read_4" c_bus_space_read_4 :: BusSpaceTagT -> BusSpaceHandleT -> BusSizeT -> IO Word32foreign import ccall "hs_extern.h bus_space_write_4" c_bus_space_write_4 :: BusSpaceTagT -> BusSpaceHandleT -> BusSizeT -> Word32 -> IO ()

-- File: metasepi/sys/hssrc/Sys/Bus.hsbusSpaceRead4 = c_bus_space_read_4busSpaceWrite4 = c_bus_space_write_4foreign import ccall "hs_extern.h bus_space_read_4" c_bus_space_read_4 ::BusSpaceTagT -> BusSpaceHandleT -> BusSizeT -> IO Word32

foreign import ccall "hs_extern.h bus_space_write_4" c_bus_space_write_4 ::BusSpaceTagT -> BusSpaceHandleT -> BusSizeT -> Word32 -> IO ()

-- File: metasepi/sys/hssrc/Arch/I386/Include/BusDefs.hstype BusSizeT = CSizenewtype {-# CTYPE "struct bus_space_tag" #-} BusSpaceTag = BusSpaceTag ()type BusSpaceTagT = Ptr BusSpaceTagtype BusSpaceHandleT = VaddrT

-- File: metasepi/sys/hssrc/Arch/I386/Include/BusDefs.hstype BusSizeT = CSizenewtype {-# CTYPE "struct bus_space_tag" #-} BusSpaceTag = BusSpaceTag ()type BusSpaceTagT = Ptr BusSpaceTagtype BusSpaceHandleT = VaddrT

-- File: metasepi/sys/hssrc/Arch/I386/Include/BusDefs.hstype BusSizeT = CSizenewtype {-# CTYPE "struct bus_space_tag" #-} BusSpaceTag = BusSpaceTag ()type BusSpaceTagT = Ptr BusSpaceTagtype BusSpaceHandleT = VaddrT

-- File: metasepi/sys/hssrc/Arch/I386/Include/BusDefs.hstype BusSizeT = CSizenewtype {-# CTYPE "struct bus_space_tag" #-} BusSpaceTag = BusSpaceTag ()type BusSpaceTagT = Ptr BusSpaceTagtype BusSpaceHandleT = VaddrT

-- File: metasepi/sys/hssrc/Arch/I386/Include/BusDefs.hstype BusSizeT = CSizenewtype {-# CTYPE "struct bus_space_tag" #-} BusSpaceTag =BusSpaceTag ()type BusSpaceTagT = Ptr BusSpaceTagtype BusSpaceHandleT = VaddrT

Trace pointer chainTrace pointer chainTrace pointer chainTrace pointer chainTrace pointer chain/* C code */static intauich_open(void *addr, int flags){

struct auich_softc *sc;

sc = (struct auich_softc *)addr;mutex_spin_exit(&sc->sc_intr_lock);sc->codec_if->vtbl->lock(sc->codec_if);

// -- snip --

/* C code */static intauich_open(void *addr, int flags){

struct auich_softc *sc;

sc = (struct auich_softc *)addr;mutex_spin_exit(&sc->sc_intr_lock);sc->codec_if->vtbl->lock(sc->codec_if);

// -- snip --

/* C code */static intauich_open(void *addr, int flags){

struct auich_softc *sc;

sc = (struct auich_softc *)addr;mutex_spin_exit(&sc->sc_intr_lock);sc->codec_if->vtbl->lock(sc->codec_if);

// -- snip --

/* C code */static intauich_open(void *addr, int flags){

struct auich_softc *sc;

sc = (struct auich_softc *)addr;mutex_spin_exit(&sc->sc_intr_lock);sc->codec_if->vtbl->lock(sc->codec_if);

// -- snip --

/* C code */static intauich_open(void *addr, int flags){

struct auich_softc *sc;

sc = (struct auich_softc *)addr;mutex_spin_exit(&sc->sc_intr_lock);sc->codec_if->vtbl->lock(sc->codec_if);

// -- snip --

-- Haskell codeauichOpen :: Ptr AuichSoftc -> Int -> IO IntauichOpen sc flags = do mutexp <- p_AuichSoftc_sc_intr_lock sc codecif <- peek =<< p_AuichSoftc_codec_if sc lock <- peek =<< p_Ac97CodecIfVtbl_lock =<< peek =<< p_Ac97CodecIf_vtbl codecif mutexSpinExit mutexp call_Ac97CodecIfVtbl_lock lock codecif-- snip --

-- Haskell codeauichOpen :: Ptr AuichSoftc -> Int -> IO IntauichOpen sc flags = do mutexp <- p_AuichSoftc_sc_intr_lock sc codecif <- peek =<< p_AuichSoftc_codec_if sc lock <- peek =<< p_Ac97CodecIfVtbl_lock =<< peek =<< p_Ac97CodecIf_vtbl codecif mutexSpinExit mutexp call_Ac97CodecIfVtbl_lock lock codecif-- snip --

-- Haskell codeauichOpen :: Ptr AuichSoftc -> Int -> IO IntauichOpen sc flags = do mutexp <- p_AuichSoftc_sc_intr_lock sc codecif <- peek =<< p_AuichSoftc_codec_if sc lock <- peek =<< p_Ac97CodecIfVtbl_lock =<< peek =<< p_Ac97CodecIf_vtbl codecif mutexSpinExit mutexp call_Ac97CodecIfVtbl_lock lock codecif-- snip --

-- Haskell codeauichOpen :: Ptr AuichSoftc -> Int -> IO IntauichOpen sc flags = do mutexp <- p_AuichSoftc_sc_intr_lock sc codecif <- peek =<< p_AuichSoftc_codec_if sc lock <- peek =<< p_Ac97CodecIfVtbl_lock =<< peek =<< p_Ac97CodecIf_vtbl codecif mutexSpinExit mutexp call_Ac97CodecIfVtbl_lock lock codecif-- snip --

-- Haskell codeauichOpen :: Ptr AuichSoftc -> Int -> IO IntauichOpen sc flags = do mutexp <- p_AuichSoftc_sc_intr_lock sc codecif <- peek =<< p_AuichSoftc_codec_if sc lock <- peek =<< p_Ac97CodecIfVtbl_lock =<< peek =<<p_Ac97CodecIf_vtbl codecif mutexSpinExit mutexp call_Ac97CodecIfVtbl_lock lock codecif-- snip --

But need assistant code!But need assistant code!But need assistant code!But need assistant code!But need assistant code!

Tool to generate the codeTool to generate the codeTool to generate the codeTool to generate the codeTool to generate the code

https://github.com/ajhc/struct2hshttps://github.com/ajhc/struct2hshttps://github.com/ajhc/struct2hshttps://github.com/ajhc/struct2hshttps://github.com/ajhc/struct2hs

☆ Generate Haskell code scanning C☆ Generate Haskell code scanning C☆ Generate Haskell code scanning C☆ Generate Haskell code scanning C☆ Generate Haskell code scanning C$ struct2hs sys/dev/pci/auich_extern_SNATCHED.h | tail offsetOf_Pdevinit_pdev_attach :: Intp_Pdevinit_pdev_attach :: Ptr Pdevinit -> IO (Ptr (Ptr (FunPtr (Int -> IO ()))))p_Pdevinit_pdev_attach p = return $ plusPtr p $ offsetOf_Pdevinit_pdev_attachforeign import ccall "dynamic" call_Pdevinit_pdev_attach :: FunPtr (Int -> IO ()) -> Int -> IO ()foreign import primitive "const.offsetof(struct pdevinit, pdev_count)" offsetOf_Pdevinit_pdev_count :: Intp_Pdevinit_pdev_count :: Ptr Pdevinit -> IO (Ptr Int)p_Pdevinit_pdev_count p = return $ plusPtr p $ offsetOf_Pdevinit_pdev_count

$ struct2hs sys/dev/pci/auich_extern_SNATCHED.h | tail offsetOf_Pdevinit_pdev_attach :: Intp_Pdevinit_pdev_attach :: Ptr Pdevinit -> IO (Ptr (Ptr (FunPtr (Int -> IO ()))))p_Pdevinit_pdev_attach p = return $ plusPtr p $ offsetOf_Pdevinit_pdev_attachforeign import ccall "dynamic" call_Pdevinit_pdev_attach :: FunPtr (Int -> IO ()) -> Int -> IO ()foreign import primitive "const.offsetof(struct pdevinit, pdev_count)" offsetOf_Pdevinit_pdev_count :: Intp_Pdevinit_pdev_count :: Ptr Pdevinit -> IO (Ptr Int)p_Pdevinit_pdev_count p = return $ plusPtr p $ offsetOf_Pdevinit_pdev_count

$ struct2hs sys/dev/pci/auich_extern_SNATCHED.h | tail offsetOf_Pdevinit_pdev_attach :: Intp_Pdevinit_pdev_attach :: Ptr Pdevinit -> IO (Ptr (Ptr (FunPtr (Int -> IO ()))))p_Pdevinit_pdev_attach p = return $ plusPtr p $ offsetOf_Pdevinit_pdev_attachforeign import ccall "dynamic" call_Pdevinit_pdev_attach :: FunPtr (Int -> IO ()) -> Int -> IO ()foreign import primitive "const.offsetof(struct pdevinit, pdev_count)" offsetOf_Pdevinit_pdev_count :: Intp_Pdevinit_pdev_count :: Ptr Pdevinit -> IO (Ptr Int)p_Pdevinit_pdev_count p = return $ plusPtr p $ offsetOf_Pdevinit_pdev_count

$ struct2hs sys/dev/pci/auich_extern_SNATCHED.h | tail offsetOf_Pdevinit_pdev_attach :: Intp_Pdevinit_pdev_attach :: Ptr Pdevinit -> IO (Ptr (Ptr (FunPtr (Int -> IO ()))))p_Pdevinit_pdev_attach p = return $ plusPtr p $ offsetOf_Pdevinit_pdev_attachforeign import ccall "dynamic" call_Pdevinit_pdev_attach :: FunPtr (Int -> IO ()) -> Int -> IO ()foreign import primitive "const.offsetof(struct pdevinit, pdev_count)" offsetOf_Pdevinit_pdev_count :: Intp_Pdevinit_pdev_count :: Ptr Pdevinit -> IO (Ptr Int)p_Pdevinit_pdev_count p = return $ plusPtr p $ offsetOf_Pdevinit_pdev_count

$ struct2hs sys/dev/pci/auich_extern_SNATCHED.h | tail offsetOf_Pdevinit_pdev_attach :: Intp_Pdevinit_pdev_attach :: Ptr Pdevinit -> IO (Ptr (Ptr (FunPtr (Int -> IO ()))))p_Pdevinit_pdev_attach p = return $ plusPtr p $ offsetOf_Pdevinit_pdev_attachforeign import ccall "dynamic" call_Pdevinit_pdev_attach :: FunPtr (Int -> IO ()) -> Int -> IO ()foreign import primitive "const.offsetof(struct pdevinit, pdev_count)" offsetOf_Pdevinit_pdev_count :: Intp_Pdevinit_pdev_count :: Ptr Pdevinit -> IO (Ptr Int)p_Pdevinit_pdev_count p = return $ plusPtr p $ offsetOf_Pdevinit_pdev_count

[6] Ajhc is the best?[6] Ajhc is the best?[6] Ajhc is the best?[6] Ajhc is the best?[6] Ajhc is the best?

☆ No.☆ No.☆ No.☆ No.☆ No.

☆ Depended on GC☆ Depended on GC☆ Depended on GC☆ Depended on GC☆ Depended on GC

☆ Too buggy compiler☆ Too buggy compiler☆ Too buggy compiler☆ Too buggy compiler☆ Too buggy compiler

https://github.com/ajhc/ajhc/issueshttps://github.com/ajhc/ajhc/issueshttps://github.com/ajhc/ajhc/issueshttps://github.com/ajhc/ajhc/issueshttps://github.com/ajhc/ajhc/issues

☆ Can't use MonadTrans☆ Can't use MonadTrans☆ Can't use MonadTrans☆ Can't use MonadTrans☆ Can't use MonadTrans

☆ Debug hard for strong optimization☆ Debug hard for strong optimization☆ Debug hard for strong optimization☆ Debug hard for strong optimization☆ Debug hard for strong optimization

Before compiling (Haskell)Before compiling (Haskell)Before compiling (Haskell)Before compiling (Haskell)Before compiling (Haskell)hdaudioIntr :: Ptr HdaudioSoftc -> IO InthdaudioIntr sc = do intsts <- hdaRead4 sc e_HDAUDIO_MMIO_INTSTS if intsts .&. e_HDAUDIO_INTSTS_GIS /= 0 then hdaudioIntr' sc intsts else return 0

hdaudioIntr' :: Ptr HdaudioSoftc -> Word32 -> IO InthdaudioIntr' sc intsts = do when (intsts .&. e_HDAUDIO_INTSTS_CIS /= 0) $ do rirbsts <- hdaRead1 sc e_HDAUDIO_MMIO_RIRBSTS when (rirbsts .&. e_HDAUDIO_RIRBSTS_RINTFL /= 0) $ do mutexp <- p_HdaudioSoftc_sc_corb_mtx sc mutexEnter mutexp hdaudioRirbDequeue sc True mutexExit mutexp when (rirbsts .&. (e_HDAUDIO_RIRBSTS_RIRBOIS .|. e_HDAUDIO_RIRBSTS_RINTFL) /= 0) $ hdaWrite1 sc e_HDAUDIO_MMIO_RIRBSTS rirbsts hdaWrite4 sc e_HDAUDIO_MMIO_INTSTS e_HDAUDIO_INTSTS_CIS when (intsts .&. e_HDAUDIO_INTSTS_SIS_MASK /= 0) $ do mutexp <- p_HdaudioSoftc_sc_stream_mtx sc-- snip --

hdaudioIntr :: Ptr HdaudioSoftc -> IO InthdaudioIntr sc = do intsts <- hdaRead4 sc e_HDAUDIO_MMIO_INTSTS if intsts .&. e_HDAUDIO_INTSTS_GIS /= 0 then hdaudioIntr' sc intsts else return 0

hdaudioIntr' :: Ptr HdaudioSoftc -> Word32 -> IO InthdaudioIntr' sc intsts = do when (intsts .&. e_HDAUDIO_INTSTS_CIS /= 0) $ do rirbsts <- hdaRead1 sc e_HDAUDIO_MMIO_RIRBSTS when (rirbsts .&. e_HDAUDIO_RIRBSTS_RINTFL /= 0) $ do mutexp <- p_HdaudioSoftc_sc_corb_mtx sc mutexEnter mutexp hdaudioRirbDequeue sc True mutexExit mutexp when (rirbsts .&. (e_HDAUDIO_RIRBSTS_RIRBOIS .|. e_HDAUDIO_RIRBSTS_RINTFL) /= 0) $ hdaWrite1 sc e_HDAUDIO_MMIO_RIRBSTS rirbsts hdaWrite4 sc e_HDAUDIO_MMIO_INTSTS e_HDAUDIO_INTSTS_CIS when (intsts .&. e_HDAUDIO_INTSTS_SIS_MASK /= 0) $ do mutexp <- p_HdaudioSoftc_sc_stream_mtx sc-- snip --

hdaudioIntr :: Ptr HdaudioSoftc -> IO InthdaudioIntr sc = do intsts <- hdaRead4 sc e_HDAUDIO_MMIO_INTSTS if intsts .&. e_HDAUDIO_INTSTS_GIS /= 0 then hdaudioIntr' sc intsts else return 0

hdaudioIntr' :: Ptr HdaudioSoftc -> Word32 -> IO InthdaudioIntr' sc intsts = do when (intsts .&. e_HDAUDIO_INTSTS_CIS /= 0) $ do rirbsts <- hdaRead1 sc e_HDAUDIO_MMIO_RIRBSTS when (rirbsts .&. e_HDAUDIO_RIRBSTS_RINTFL /= 0) $ do mutexp <- p_HdaudioSoftc_sc_corb_mtx sc mutexEnter mutexp hdaudioRirbDequeue sc True mutexExit mutexp when (rirbsts .&. (e_HDAUDIO_RIRBSTS_RIRBOIS .|. e_HDAUDIO_RIRBSTS_RINTFL) /= 0) $ hdaWrite1 sc e_HDAUDIO_MMIO_RIRBSTS rirbsts hdaWrite4 sc e_HDAUDIO_MMIO_INTSTS e_HDAUDIO_INTSTS_CIS when (intsts .&. e_HDAUDIO_INTSTS_SIS_MASK /= 0) $ do mutexp <- p_HdaudioSoftc_sc_stream_mtx sc-- snip --

hdaudioIntr :: Ptr HdaudioSoftc -> IO InthdaudioIntr sc = do intsts <- hdaRead4 sc e_HDAUDIO_MMIO_INTSTS if intsts .&. e_HDAUDIO_INTSTS_GIS /= 0 then hdaudioIntr' sc intsts else return 0

hdaudioIntr' :: Ptr HdaudioSoftc -> Word32 -> IO InthdaudioIntr' sc intsts = do when (intsts .&. e_HDAUDIO_INTSTS_CIS /= 0) $ do rirbsts <- hdaRead1 sc e_HDAUDIO_MMIO_RIRBSTS when (rirbsts .&. e_HDAUDIO_RIRBSTS_RINTFL /= 0) $ do mutexp <- p_HdaudioSoftc_sc_corb_mtx sc mutexEnter mutexp hdaudioRirbDequeue sc True mutexExit mutexp when (rirbsts .&. (e_HDAUDIO_RIRBSTS_RIRBOIS .|. e_HDAUDIO_RIRBSTS_RINTFL) /= 0) $ hdaWrite1 sc e_HDAUDIO_MMIO_RIRBSTS rirbsts hdaWrite4 sc e_HDAUDIO_MMIO_INTSTS e_HDAUDIO_INTSTS_CIS when (intsts .&. e_HDAUDIO_INTSTS_SIS_MASK /= 0) $ do mutexp <- p_HdaudioSoftc_sc_stream_mtx sc-- snip --

hdaudioIntr :: Ptr HdaudioSoftc -> IO InthdaudioIntr sc = do intsts <- hdaRead4 sc e_HDAUDIO_MMIO_INTSTSif intsts .&. e_HDAUDIO_INTSTS_GIS /= 0 then hdaudioIntr' sc

intstselse return 0

hdaudioIntr' :: Ptr HdaudioSoftc -> Word32 -> IO InthdaudioIntr' sc intsts = do when (intsts .&. e_HDAUDIO_INTSTS_CIS /= 0) $ do rirbsts <- hdaRead1 sc e_HDAUDIO_MMIO_RIRBSTS when (rirbsts .&. e_HDAUDIO_RIRBSTS_RINTFL /= 0) $ do mutexp <- p_HdaudioSoftc_sc_corb_mtx sc mutexEnter mutexp hdaudioRirbDequeue sc True mutexExit mutexp when (rirbsts .&. (e_HDAUDIO_RIRBSTS_RIRBOIS .|.e_HDAUDIO_RIRBSTS_RINTFL) /= 0) $ hdaWrite1 sc e_HDAUDIO_MMIO_RIRBSTS rirbsts hdaWrite4 sc e_HDAUDIO_MMIO_INTSTS e_HDAUDIO_INTSTS_CIS when (intsts .&. e_HDAUDIO_INTSTS_SIS_MASK /= 0) $ do mutexp <- p_HdaudioSoftc_sc_stream_mtx sc-- snip --

After compiling (C language)After compiling (C language)After compiling (C language)After compiling (C language)After compiling (C language)

Debug in kernelDebug in kernelDebug in kernelDebug in kernelDebug in kernel

☆ Hardware state is sometime buggy☆ Hardware state is sometime buggy☆ Hardware state is sometime buggy☆ Hardware state is sometime buggy☆ Hardware state is sometime buggy

☆ Not only debug software☆ Not only debug software☆ Not only debug software☆ Not only debug software☆ Not only debug software

☆ but also hardware!☆ but also hardware!☆ but also hardware!☆ but also hardware!☆ but also hardware!

☆ Gap between Haskell and C code☆ Gap between Haskell and C code☆ Gap between Haskell and C code☆ Gap between Haskell and C code☆ Gap between Haskell and C code

☆ Can't debug pure Haskell code☆ Can't debug pure Haskell code☆ Can't debug pure Haskell code☆ Can't debug pure Haskell code☆ Can't debug pure Haskell code

☆ Need to debug generated C code☆ Need to debug generated C code☆ Need to debug generated C code☆ Need to debug generated C code☆ Need to debug generated C code

☆ Where is more better compiler?☆ Where is more better compiler?☆ Where is more better compiler?☆ Where is more better compiler?☆ Where is more better compiler?

[7] From Arafura to Bohai[7] From Arafura to Bohai[7] From Arafura to Bohai[7] From Arafura to Bohai[7] From Arafura to Bohai

☆ We are in Arafura iteration☆ We are in Arafura iteration☆ We are in Arafura iteration☆ We are in Arafura iteration☆ We are in Arafura iteration

☆ Arafura := Ajhc + Snatch + NetBSD☆ Arafura := Ajhc + Snatch + NetBSD☆ Arafura := Ajhc + Snatch + NetBSD☆ Arafura := Ajhc + Snatch + NetBSD☆ Arafura := Ajhc + Snatch + NetBSD

☆ Use "ATS" compiler on the next☆ Use "ATS" compiler on the next☆ Use "ATS" compiler on the next☆ Use "ATS" compiler on the next☆ Use "ATS" compiler on the next

☆ Let's start Bohai iteration!☆ Let's start Bohai iteration!☆ Let's start Bohai iteration!☆ Let's start Bohai iteration!☆ Let's start Bohai iteration!

☆ Bohai := ATS + Snatch + NetBSD☆ Bohai := ATS + Snatch + NetBSD☆ Bohai := ATS + Snatch + NetBSD☆ Bohai := ATS + Snatch + NetBSD☆ Bohai := ATS + Snatch + NetBSD

What is ATS language?What is ATS language?What is ATS language?What is ATS language?What is ATS language?

http://www.ats-lang.org/http://www.ats-lang.org/http://www.ats-lang.org/http://www.ats-lang.org/http://www.ats-lang.org/

☆ Has syntax like ML☆ Has syntax like ML☆ Has syntax like ML☆ Has syntax like ML☆ Has syntax like ML

☆ Compiled into C☆ Compiled into C☆ Compiled into C☆ Compiled into C☆ Compiled into C

☆ Dependent type☆ Dependent type☆ Dependent type☆ Dependent type☆ Dependent type

☆ Linear type☆ Linear type☆ Linear type☆ Linear type☆ Linear type

☆ Without GC☆ Without GC☆ Without GC☆ Without GC☆ Without GC

☆ Without any runtime☆ Without any runtime☆ Without any runtime☆ Without any runtime☆ Without any runtime

Japan ATS User GroupJapan ATS User GroupJapan ATS User GroupJapan ATS User GroupJapan ATS User Group

http://jats-ug.metasepi.org/http://jats-ug.metasepi.org/http://jats-ug.metasepi.org/http://jats-ug.metasepi.org/http://jats-ug.metasepi.org/

☆ Translating ATS documents☆ Translating ATS documents☆ Translating ATS documents☆ Translating ATS documents☆ Translating ATS documents

☆ ATS propaganda in Japan☆ ATS propaganda in Japan☆ ATS propaganda in Japan☆ ATS propaganda in Japan☆ ATS propaganda in Japan

☆ Join us!☆ Join us!☆ Join us!☆ Join us!☆ Join us!

Hongwei said... (cont.)Hongwei said... (cont.)Hongwei said... (cont.)Hongwei said... (cont.)Hongwei said... (cont.)

☆ Hongwei Xi as ATS author☆ Hongwei Xi as ATS author☆ Hongwei Xi as ATS author☆ Hongwei Xi as ATS author☆ Hongwei Xi as ATS author

☆ Associate Professor☆ Associate Professor☆ Associate Professor☆ Associate Professor☆ Associate Professor

☆ at Boston University☆ at Boston University☆ at Boston University☆ at Boston University☆ at Boston UniversityDate: Mon Dec 23 11:40 JST 2013

Hi Metasepi-chan,

I spent quite some time today browsing metasepi.org.

I am really interested in your Metasepi project, partly because I myself wanted to implement NetBSD in ATS about 5 years ago. Unfortunately, I never had time to get the project started as I needed to spend so much time on ATS2. By the way, I had planned to use the very same approach which you call "Snatch". I had also considered Minix but I chose NetBSD because it was a real OS.

Date: Mon Dec 23 11:40 JST 2013

Hi Metasepi-chan,

I spent quite some time today browsing metasepi.org.

I am really interested in your Metasepi project, partly because I myself wanted to implement NetBSD in ATS about 5 years ago. Unfortunately, I never had time to get the project started as I needed to spend so much time on ATS2. By the way, I had planned to use the very same approach which you call "Snatch". I had also considered Minix but I chose NetBSD because it was a real OS.

Date: Mon Dec 23 11:40 JST 2013

Hi Metasepi-chan,

I spent quite some time today browsing metasepi.org.

I am really interested in your Metasepi project, partly because I myself wanted to implement NetBSD in ATS about 5 years ago. Unfortunately, I never had time to get the project started as I needed to spend so much time on ATS2. By the way, I had planned to use the very same approach which you call "Snatch". I had also considered Minix but I chose NetBSD because it was a real OS.

Date: Mon Dec 23 11:40 JST 2013

Hi Metasepi-chan,

I spent quite some time today browsing metasepi.org.

I am really interested in your Metasepi project, partly because I myself wanted to implement NetBSD in ATS about 5 years ago. Unfortunately, I never had time to get the project started as I needed to spend so much time on ATS2. By the way, I had planned to use the very same approach which you call "Snatch". I had also considered Minix but I chose NetBSD because it was a real OS.

Date: Mon Dec 23 11:40 JST 2013

Hi Metasepi-chan,

I spent quite some time today browsing metasepi.org.

I am really interested in your Metasepi project, partly because I myself wanted to implement NetBSD in ATS about 5 years ago. Unfortunately, I never had time to get the project started as I needed to spend so much time on ATS2. By the way, I had planned to use the very same approach which you call "Snatch". I had also considered Minix but I chose NetBSD because it was a real OS.

Hongwei said... (cont.)Hongwei said... (cont.)Hongwei said... (cont.)Hongwei said... (cont.)Hongwei said... (cont.)I think I know first-handedly the dilemma you are currently in. On one hand, you want to be able to fully focus on writing the kernel. On the other hand, you also need to add features to Ajhc constantly to address all kinds of issues that keep popping up, which undoubtedly makes it very difficult for you to focus.

I would highly recommend that you use ATS to implement NetBSD kernel. Unlike jhc, there is no semantics gap between ATS and C. In particular, they both use the same native unboxed data representation. Once you become familiar with ATS, you can readily visualize the C code that your ATS source is to be compiled into. ATS is truly an ideal language for the kind of "Snatch" approach you want to take to re-write NetBSD. If you take the lead, then I will be happy to "chip in" :)

I also spent some time reading documentation on jhc. Personally, I feel that there is simply too much uncertainty to use it in real kernel implementation. Features like GC could make the kernel highly unpredictable, scaring away potential users.

I think I know first-handedly the dilemma you are currently in. On one hand, you want to be able to fully focus on writing the kernel. On the other hand, you also need to add features to Ajhc constantly to address all kinds of issues that keep popping up, which undoubtedly makes it very difficult for you to focus.

I would highly recommend that you use ATS to implement NetBSD kernel. Unlike jhc, there is no semantics gap between ATS and C. In particular, they both use the same native unboxed data representation. Once you become familiar with ATS, you can readily visualize the C code that your ATS source is to be compiled into. ATS is truly an ideal language for the kind of "Snatch" approach you want to take to re-write NetBSD. If you take the lead, then I will be happy to "chip in" :)

I also spent some time reading documentation on jhc. Personally, I feel that there is simply too much uncertainty to use it in real kernel implementation. Features like GC could make the kernel highly unpredictable, scaring away potential users.

I think I know first-handedly the dilemma you are currently in. On one hand, you want to be able to fully focus on writing the kernel. On the other hand, you also need to add features to Ajhc constantly to address all kinds of issues that keep popping up, which undoubtedly makes it very difficult for you to focus.

I would highly recommend that you use ATS to implement NetBSD kernel. Unlike jhc, there is no semantics gap between ATS and C. In particular, they both use the same native unboxed data representation. Once you become familiar with ATS, you can readily visualize the C code that your ATS source is to be compiled into. ATS is truly an ideal language for the kind of "Snatch" approach you want to take to re-write NetBSD. If you take the lead, then I will be happy to "chip in" :)

I also spent some time reading documentation on jhc. Personally, I feel that there is simply too much uncertainty to use it in real kernel implementation. Features like GC could make the kernel highly unpredictable, scaring away potential users.

I think I know first-handedly the dilemma you are currently in. On one hand, you want to be able to fully focus on writing the kernel. On the other hand, you also need to add features to Ajhc constantly to address all kinds of issues that keep popping up, which undoubtedly makes it very difficult for you to focus.

I would highly recommend that you use ATS to implement NetBSD kernel. Unlike jhc, there is no semantics gap between ATS and C. In particular, they both use the same native unboxed data representation. Once you become familiar with ATS, you can readily visualize the C code that your ATS source is to be compiled into. ATS is truly an ideal language for the kind of "Snatch" approach you want to take to re-write NetBSD. If you take the lead, then I will be happy to "chip in" :)

I also spent some time reading documentation on jhc. Personally, I feel that there is simply too much uncertainty to use it in real kernel implementation. Features like GC could make the kernel highly unpredictable, scaring away potential users.

I think I know first-handedly the dilemma you are currently in. On one hand, you want to be able to fully focus on writing the kernel. On the other hand, you also need to add features to Ajhc constantly to address all kinds of issues that keep popping up, which undoubtedly makes it very difficult for you to focus.

I would highly recommend that you use ATS to implement NetBSD kernel. Unlike jhc, there is no semantics gap between ATS and C. In particular, they both use the same native unboxed data representation. Once you become familiar with ATS, you can readily visualize the C code that your ATS source is to be compiled into. ATS is truly an ideal language for the kind of "Snatch" approach you want to take to re-write NetBSD. If you take the lead, then I will be happy to "chip in" :)

I also spent some time reading documentation on jhc. Personally, I feel that there is simply too much uncertainty to use it in real kernel implementation. Features like GC could make the kernel highly unpredictable, scaring away potential users.

Hongwei said...Hongwei said...Hongwei said...Hongwei said...Hongwei said...I think that we both believe C is the right language for systems programming. The problem with C is that it is too difficult to write correct C programs. ATS is designed to allow the programmer to correctly write the kind of C programs he or she wanted to write in the first place. While jhc generates C code, the kind of C code it generates may not be suited for kernel. This is what I call a semantics gap.

I write this message in the hope that we could join effort in doing something that has not been done up to now: Writing a real kernel in (largely) functional style that can truly deliever safety-wise as well as performance-wise.

Cheers,

--Hongwei

I think that we both believe C is the right language for systems programming. The problem with C is that it is too difficult to write correct C programs. ATS is designed to allow the programmer to correctly write the kind of C programs he or she wanted to write in the first place. While jhc generates C code, the kind of C code it generates may not be suited for kernel. This is what I call a semantics gap.

I write this message in the hope that we could join effort in doing something that has not been done up to now: Writing a real kernel in (largely) functional style that can truly deliever safety-wise as well as performance-wise.

Cheers,

--Hongwei

I think that we both believe C is the right language for systems programming. The problem with C is that it is too difficult to write correct C programs. ATS is designed to allow the programmer to correctly write the kind of C programs he or she wanted to write in the first place. While jhc generates C code, the kind of C code it generates may not be suited for kernel. This is what I call a semantics gap.

I write this message in the hope that we could join effort in doing something that has not been done up to now: Writing a real kernel in (largely) functional style that can truly deliever safety-wise as well as performance-wise.

Cheers,

--Hongwei

I think that we both believe C is the right language for systems programming. The problem with C is that it is too difficult to write correct C programs. ATS is designed to allow the programmer to correctly write the kind of C programs he or she wanted to write in the first place. While jhc generates C code, the kind of C code it generates may not be suited for kernel. This is what I call a semantics gap.

I write this message in the hope that we could join effort in doing something that has not been done up to now: Writing a real kernel in (largely) functional style that can truly deliever safety-wise as well as performance-wise.

Cheers,

--Hongwei

I think that we both believe C is the right language for systems programming. The problem with C is that it is too difficult to write correct C programs. ATS is designed to allow the programmer to correctly write the kind of C programs he or she wanted to write in the first place. While jhc generates C code, the kind of C code it generates may not be suited for kernel. This is what I call a semantics gap.

I write this message in the hope that we could join effort in doing something that has not been done up to now: Writing a real kernel in (largely) functional style that can truly deliever safety-wise as well as performance-wise.

Cheers,

--Hongwei