projects:gforth-as-pid-one:start
                **Dies ist eine alte Version des Dokuments!**
Inhaltsverzeichnis
Gforth als Prozess 1 unter Linux
USB-Stick oder SD-Karte mit GForth almost native
Die Installation von GForth 'almost native' für x86-32Bit wurde für i686 Rechner (Pentium-Pro und neuer) kompiliert. Getestet wurde auf einem Thinkpad X60 und einen NoName Laptop mit VIA C7 CPU.
Bei Fragen und Verbesserungsvorschlägen bitte eine E-Mail an gforth-an@strotmann.de.
Anleitung Dateien
Anleitung zum erstellen einen USB-Stick oder SD-Karte unter Linux
- USB Stick oder SD-Karte einstecken, Gerätename per „dmesg“ herausfinden (im folgenden /dev/sdb1 bitte gegen den eigenen Gerätenamen austauschen. ACHTUNG, bei falschem Gerätenamen droht Datenverlust!)
 - die Software „syslinux“ als Paket installieren (per yum, apt-get, emerge etc)
 - eine primäre Partition auf dem Stick anlegen (wenn nicht schon vorhanden)
 - Partition mit dem EXT2 Dateisystem formatieren
% mkfs.ext2 /dev/sdb1 - Partition anhängen
'% mount /dev/sdb1 /mnt - Dateien auf die Partition spielen
cd /mnt; tar cvfz gforth-almost-native-20140815.tgz; sync; cd; - extlinux installieren
% extlinux -i /mnt - Bootsektor installieren
% cat /usr/share/syslinux/mbr.bin > /dev/sdb - Partition aushängen
% umount /mnt - USB-Stick ausprobieren
 
Anleitung Dateisystem-Abbild
- USB-Stick oder SD-Karte einstecken (mind. 512 MB), Gerätename per „dmesg“ herausfinden (im folgenden /dev/sdb1 bitte gegen den eigenen Gerätenamen austauschen. ACHTUNG, bei falschem Gerätenamen droht Datenverlust!)
 - Image auf das Gerät spielen
gzcat gforth-almost-native-20140815.img.gz | dd bs=1M > /dev/sdb - USB-Stick oder SD-Karte ausprobieren
 
GForth 'almost native' USB-Stick Image (512MB) vom 20140815 (37 MB)
Linux Syscalls aus GForth für ia86-32bit Linux
abi-code sys-getpid ( -- pid ) \ get process ID for gforth
   20  #   ax mov  \ get-pid syscall
   $80 #      int  \ execute syscall
   ax      cx mov  \ save result
   4 sp d) ax mov  \ get stackpointer
   4 #     ax sub  \ make space for result on stack
   cx    ax ) mov  \ move result to stack
              ret  \ return from code
end-code
abi-code sys-reboot ( -- ) \ shutdown and reboot machine
       88 # ax mov  \ reboot syscall
$fee1dead # bx mov  \ magic 1
 85072278 # cx mov  \ magic 2
$01234567 # dx mov  \ command (restart)
      $80 #    int  \ execute syscall
               ret  \ we don't expect to come back
end-code
abi-code sys-poweroff ( -- ) \ shutdown and poweroff machine
       88 # ax mov  \ reboot syscall
$fee1dead # bx mov  \ magic 1
 85072278 # cx mov  \ magic 2
$4321fedc # dx mov  \ command (poweroff)
      $80 #    int  \ execute syscall
               ret  \ we don't expect to come back
end-code
abi-code sys-sync ( -- ) \ commit buffer cache to disk
  36 #      ax mov  \ sync syscall
 $80 #         int  \ execute syscall
  4 sp d)   ax mov  \ return stackpointer
               ret  \ return
end-code
\ redefine "bye"
: bye sys-sync sys-poweroff ;
Links
- GNU/Forth Dokumentation: https://www.complang.tuwien.ac.at/forth/gforth/Docs-html
 - GNU/Forth Quellcode auf github: https://github.com/forthy42/gforth
 - Anton Ertl: Almost native Forth: http://www.complang.tuwien.ac.at/forth/gforth/almost-native/
 - Linux 64bit Syscall Tabbelle: http://blog.rchapman.org/post/36801038863/linux-system-call-table-for-x86-64
 
projects/gforth-as-pid-one/start.1409493394.txt.gz · Zuletzt geändert: 2014-08-31 15:56 von cas