Re: inserting a Forth-like language into the Linux kernel

From: Rick Hohensee (humbubba@smarty.smart.net)
Date: Thu May 10 2001 - 01:12:34 EST


read() of a tty from the kernel does behave as per the tty settings.
I now have a kernel thread with stdin, out and err, FD's 0, 1 and 2,
open and reading lines of typed input. The "interpreter" adds 0x30
(ASCII 0) to the return value from read and prints it, which means
it occurs at the beginning of the next line. Here's what's sitting
on my tty1 screen right now...
.................................................................
1
1
1
1aaoeutasoeu aoeu oaeusntaoesutoaeut oeuoaeuo uoaeuoaeu
heeee
6e
2
1
1
1
1eeeeee
7ee
3
1onetu euaoeuaoeuoa eu aoeu ao eu ao eu aoeu aoeu ao eu aoe u aoe u
te e e e e
;e e e e
9e e e e
9e e e
7ee
3
...................................................................

This should simplify hanging an interpreter off this simple little top
loop. That is, userland H3sm was using cooked mode, so this is nice.
This is the top loop code, which is x86 assembly and H3sm
subroutines...

.................................................................
abort_H3sm:
        call buffer

top_loop_of_H3sm:
                                # stick a sleep in here.
                                # Do not melt the CPU, do not slow down
                                # the test cycle.
        call timespec
        call pdup
        call pplusc
        call pplusc
        call nanosleep
        call twopdrop
        call drop

        HANDOFF

        call zero # FD
        call read
        call literal
        .byte 4
        .int 0x30
        call plus
        call emit
ELL( top_loop_of_H3sm)
...................................................................

emit is similar to Forth EMIT. It is a one-byte write().
buffer and timespec put addresses on
the H3sm pointer stack. nanosleep and read are H3sm stack-passing
wrappers for the syscalls. HANDOFF is a macro for a stack-push-wrapped
schedule(). It's a macro because I suspect I'm going to have to sprinkle
it judiciously around H3sm. The nanosleep keeps my load average normal.

Rick Hohensee
www.clienux.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue May 15 2001 - 21:00:22 EST