Kernel Daemon insertion tools

I've got my 3-stack Forth-like language running in kernelspace, in the
manner of a kernel debugger I guess.  H3sm, Hohensee's 3-stack machine,
isn't Linux kernel code per se, but the stunts involved in getting it in
there are, and aren't specific to H3sm.

The version of H3sm used as a kernel thread is written entirely in gas/m4,
(and could be converted to build with my shasm Bash script assembler in a
matter of days/weeks, BTW) so it needs a wrapper to slow-dance with Linux.
In order to not create a lot of #include dependancy issues I just mimic
kpiod in terms of installing it in the kernel sources, using the shell of
that function as an example/wrapper, and inserting it in that source file
right after kpiod(). That was surprisingly easy. A better knowledge of
kernel code than mine would allow this to be done more maintainably. I had
started a linux/H3sm directory, but the #include issues ate my head.

Then we have namespaces. Linux has gajillions of labels in constant flux.
After getting a dummy H3sm_kthread symbol in System.map in a built kernel
by the above means, an ed script was devised. All labels in the standalone
H3sm were suffixed with "H3sm", so jz cellwisebooleanbla becomes jz
cellwisebooleanblaH3sm, main: became mainH3sm:, and just for regularity
top_loop_of_H3sm became top_loop_of_H3smH3sm. Not what I want to look at
normally, and I won't, unless I'm going into the kernel. Name conflicts
are thus astronomically unlikely. When I first wrote H3sm there were 0
Google hits for "h3sm".

Here's the sh/ed script to change labels. This runs on the pre-m4 source.
Tabs were expanded in posting this. Something similar could be run on the
gas phase of C output perhaps.
......................................................................
#
# convert 1.s.m4 to 1.k, m4/gas source for a Linux kernel daemon
#   or kernel thread ala kswapd
# april 2001

ed 1.s.m4 <<HERE
1
/.globl main/s/.globl main/.globl mainH3sm/
1
/.type    main,@f/s/.type    main,@function/.type  mainH3sm,@function/
1
,s/^\([a-zA-Z0-9_]*\):/\1H3sm:/
,s/\$1:/$\1H3sm:/
,s/[    ]*call \([a-zA-Z0-9_]*\)/call \1H3sm/
,s/^[   ]*ELL([         ]*\([a-zA-Z0-9_]*\)/ELL(                \1H3sm/
,s/^[   ]*YES([         ]*\([a-zA-Z0-9_]*\)/YES(                \1H3sm/
,s/^[   ]*NO([  ]*\([a-zA-Z0-9_]*\)/NO(         \1H3sm/
,s/ifnonzero[   ]*\([a-zA-Z0-9_]*\)/ifnonzero           \1H3sm/
,s/ifzero[      ]*\([a-zA-Z0-9_]*\)/ifzero              \1H3sm/
,s/ifnocarry[   ]*\([a-zA-Z0-9_]*\)/ifnocarry           \1H3sm/
,s/ifcarry[     ]*\([a-zA-Z0-9_]*\)/ifcarry             \1H3sm/
,s/jump[        ]*\([a-zA-Z0-9_]*\)/jump                \1H3sm/
w 1.k
q
HERE
....................................................................


