[EROS-Port] PATCH: port to a Sony laptop

Wolfgang Oertl Wolfgang.Oertl@uibk.ac.at
Thu, 30 Nov 2000 10:03:40 +0100


Hi everybody,

now that Eros finally boots (at least from a floppy) on my laptop, I have
compiled this set of patches that I had to apply to make it work.

Hardware:
Sony VAIO PCG-F400: Intel Celeron, 64MB RAM, IDE harddisk, IDE cdrom, Floppy

Software:
linux-2.4.0-test11 with reiserfs-3.6.19
GNU gcc 2.95.2
GNU libc 2.1.3
GNU binutils 2.9.5.0.24
GNU make 3.79.1
GNU flex 2.5.4
GNU bison 1.25
GNU awk 3.0.5
netpbm 8.4
(looks like a whole gnu herd here...)

The Eros version I used I downloaded recently from www.eros-os.org/~eros/pkg,
the newest file (according to the CVS Entries files) having the date
Nov 19 23:27:05 2000.
I have to do the downloading via 1.4 MB floppy discs, so I didn't get the xenv
package...  Most of my problems surely stem from this.


Overview
--------

* hardware: Gate A20 enabling locked my machine up.
- arch/i486/.../symnames.s: duplicate '.LF0' labels.
- environent: I had to figure out which variables to set.
- compiler: flags, compile errors in __asm__ statements.
- precompiler: problems with the 'arch i486' line in imgmap.i486
- devfs on linux: change of the device name of the floppy



Environment
-----------

set -a
EROS_HOSTENV=linux
EROS_ROOT=/usr/local/eros
EROS_ARCH=i486
EROS_CONFIG=DEFAULT
#EROS_HD=/dev/discs/disc0/part6
PATH=$PATH:$EROS_ROOT/cross/bin
set +a

Further, I had to create the symlink src/base/sys/eros/machine -> i486.
This was also mentioned today in another mail on eros-arch.


Compiler
--------

The code to identify egcs and gcc 2.8+ doesn't work for my version of GCC, so
I just disabled it.  Furthermore, there are some warnings, mostly related to
C++ constructors (which, according to the compiler, should throw an exception,
not return NULL), so I had to remove the '-Werror' switch.

diff -ru eros-orig/src/build/lib/make/linux.mk eros-my/src/build/lib/make/linux.mk
--- eros-orig/src/build/lib/make/linux.mk	Thu Oct 14 00:00:32 1999
+++ eros-my/src/build/lib/make/linux.mk	Tue Nov 28 00:08:59 2000
@@ -21,7 +21,8 @@
 # Overrides for building under Linux, using RedHat 4.2 or later:
 
 # GCC 2.8+ and EGCS require these to successfully compile the kernel:
-ifneq "" "$(findstring /usr/bin/egcs,$(wildcard /usr/bin/*))"
+#  gcc 2.95.2 isn't named egcs anymore...
+#ifneq "" "$(findstring /usr/bin/egcs,$(wildcard /usr/bin/*))"
 EROS_GPLUS_OPTIM=-fno-rtti -fno-exceptions
 NATIVE_GPLUS_OPTIM=-fno-rtti -fno-exceptions
-endif
+#endif
diff -ru eros-orig/src/build/lib/make/makevars.mk eros-my/src/build/lib/make/makevars.mk
--- eros-orig/src/build/lib/make/makevars.mk	Sat May 13 17:27:28 2000
+++ eros-my/src/build/lib/make/makevars.mk	Tue Nov 28 00:51:23 2000
@@ -60,12 +60,14 @@
 
 NATIVE_GCC=gcc
 ifndef GCCWARN
-GCCWARN=-Wall -Winline -Werror -Wno-format
+#GCCWARN=-Wall -Winline -Werror -Wno-format
+GCCWARN=-Wall -Winline -Wno-format
 endif
 
 NATIVE_GPLUS=g++
 ifndef GPLUSWARN
-GPLUSWARN=-Wall -Winline -Werror -Wno-format
+#GPLUSWARN=-Wall -Winline -Werror -Wno-format
+GPLUSWARN=-Wall -Winline -Wno-format
 endif
 
 #


The following __asm__ statements don't compile, so I removed the offending
part.  I don't know whether this has any unexpected side-effects though...

diff -ru eros-orig/src/base/sys/eros/i486/memory.h eros-my/src/base/sys/eros/i486/memory.h
--- eros-orig/src/base/sys/eros/i486/memory.h	Mon Oct 16 02:48:35 2000
+++ eros-my/src/base/sys/eros/i486/memory.h	Tue Nov 28 00:36:39 2000
@@ -30,7 +30,7 @@
 			"movsl\n\t"
 			: /* no output */
 			:"c" (len>>2),"S" (from),"D" (to)
-			:"cx","si","di","memory");
+			:"memory");	/* 28-11-2000 w.o.: removed cx, di, si */
 }
 
 inline void
@@ -41,7 +41,7 @@
 			"movsw\n\t"
 			: /* no output */
 			:"c" (len>>1),"S" (from),"D" (to)
-			:"cx","si","di","memory");
+			:"memory");	/* 28-11-2000 w.o.: removed cx, di, si */
 }
 
 #if 0
@@ -72,7 +72,7 @@
 			"movsb\n\t"
 			: /* "=c" (len), "=S" , "=D" */
 			:"c" (len),"S" (from),"D" (to)
-			: "0", "1", "2", "memory");
+			:"memory");	/* 28-11-2000 w.o.: removed cx, di, si */
 }
 
 #ifdef __KERNEL__



That probably was just a warning, but here it is anyway:

diff -ru eros-orig/src/base/sys/kernel/kern_CpuReserve.cxx eros-my/src/base/sys/kernel/kern_CpuReserve.cxx
--- eros-orig/src/base/sys/kernel/kern_CpuReserve.cxx	Thu Oct 14 00:43:58 1999
+++ eros-my/src/base/sys/kernel/kern_CpuReserve.cxx	Fri Nov 24 18:37:08 2000
@@ -134,7 +134,7 @@
 
     uint64_t nextPeriod = SysTimer::Now() + period;
 
-    reserveTimer.WakeupAtTick(nextPeriod, CpuReserve::Replenish);
+    reserveTimer.WakeupAtTick(nextPeriod, &CpuReserve::Replenish);	/* w.o. 24-11-2000 */
   }
   else {
     active = false;



Precompiler
-----------

This concerns mkimage: The macro 'i486' is defined as '1', which leads to the
failure of the line 'arch i486;', because mksysvol sees 'arch 1;'.  OTOH in
some other file 'i486' (or 'i386') must be defined, so I simply changed this
thus:

diff -ru eros-orig/src/base/sysimage/imgmap.i486 eros-my/src/base/sysimage/imgmap.i486
--- eros-orig/src/base/sysimage/imgmap.i486	Thu Oct 14 00:47:06 1999
+++ eros-my/src/base/sysimage/imgmap.i486	Tue Nov 28 22:21:04 2000
@@ -23,7 +23,7 @@
 /* Master system image description for 32 bit EROS systems.
  */
 
-arch i486;
+arch arch_i486;
 
 /*********************************************
  * PRIMORDIAL DOMAINS
diff -ru eros-orig/src/base/cross/lib/erosimg/ExecArch.cxx eros-my/src/base/cross/lib/erosimg/ExecArch.cxx
--- eros-orig/src/base/cross/lib/erosimg/ExecArch.cxx	Thu Oct 14 00:35:22 1999
+++ eros-my/src/base/cross/lib/erosimg/ExecArch.cxx	Tue Nov 28 18:40:56 2000
@@ -26,7 +26,7 @@
 ExecArch::Architecture
 ExecArch::FromString(InternedString& name)
 {
-  if (name == InternedString("i486")) {
+  if (name == InternedString("arch_i486")) {		/* patch w.o. */
     return ExecArch::arch_i486;
   }
   else {




Linux
-----

I use devfs, so the device names are different:

diff -ru eros-orig/src/build/lib/make/makevars.mk eros-my/src/build/lib/make/makevars.mk
--- eros-orig/src/build/lib/make/makevars.mk	Sat May 13 17:27:28 2000
+++ eros-my/src/build/lib/make/makevars.mk	Tue Nov 28 00:51:23 2000
@@ -84,7 +86,7 @@
 # Then variables related to installation and test generation:
 #
 
-HOST_FD=/dev/fd0H1440 
+HOST_FD=/dev/floppy/0
 
 ###############################################################
 #
diff -ru eros-orig/src/build/lib/make/linux-xenv.mk eros-my/src/build/lib/make/linux-xenv.mk
--- eros-orig/src/build/lib/make/linux-xenv.mk	Sat May 13 17:05:08 2000
+++ eros-my/src/build/lib/make/linux-xenv.mk	Tue Nov 28 00:49:08 2000
@@ -40,4 +40,5 @@
 
 GAWK=gawk
 
-HOST_FD=/dev/fd0H1440
+HOST_FD=/dev/floppy/0
+


Hardware
--------

The Gate-A20 enabling routine simply locked my machine up, not even the
off-button would work, and when I tried to boot Windoze later it couldn't
enable the gate A20 (even though the machine was completely off - no battery,
no A/C - before).

So I simply replaced this code with the corresponding code of the Linux
kernel, but not all of it: the commented-out part of 'wait until...' would
reboot the machine :-(



diff -ru eros-orig/src/base/sys/arch/i486/boot/cons_io.c eros-my/src/base/sys/arch/i486/boot/cons_io.c
--- eros-orig/src/base/sys/arch/i486/boot/cons_io.c	Thu Oct 14 00:40:20 1999
+++ eros-my/src/base/sys/arch/i486/boot/cons_io.c	Tue Nov 28 21:43:28 2000
@@ -38,6 +38,8 @@
 					   enable data line
 					   enable clock line */
 
+#if 0
+
 /*
  * Gate A20 for high memory
  */
@@ -58,6 +60,103 @@
 	while (inb(K_STATUS) & K_IBUF_FUL);
 #endif	IBM_L40
 }
+
+#else
+
+/* grabbed from Linux boot code in arch/i386/boot/setup.S */
+
+
+void empty_8042();
+__asm__("
+");
+
+unsigned char	x_20 = KB_A20;
+
+void
+gateA20()
+{
+
+__asm__("
+
+# that was painless, now we enable a20
+        call    empty_8042
+
+        movb    $0xD1, %al                      # command write
+        outb    %al, $0x64
+        call    empty_8042
+
+        movb    $0xDF, %al                      # A20 on
+        outb    %al, $0x60
+        call    empty_8042
+
+#
+#       You must preserve the other bits here. Otherwise embarrasing things
+#       like laptops powering off on boot happen. Corrected version by Kira
+#       Brown from Linux 2.2
+#
+        inb     $0x92, %al                      #
+        orb     $02, %al                        # 'fast A20' version
+        outb    %al, $0x92                      # some chips have only this
+
+# wait until a20 really *is* enabled; it can take a fair amount of
+# time on certain systems; Toshiba Tecras are known to have this
+# problem.  The memory location used here (0x200) is the int 0x80
+# vector, which should be safe to use.
+
+#        xorw    %ax, %ax                        # segment 0x0000
+#        movw    %ax, %fs
+#        decw    %ax                             # segment 0xffff (HMA)
+#        movw    %ax, %gs
+#a20_wait:
+#        incw    %ax                             # unused memory location <0xfff0
+#        movw    %ax, %fs:(0x200)                # we use the 'int 0x80' vector
+#        cmpw    %gs:(0x210), %ax                # and its corresponding HMA addr
+#        je      a20_wait                        # loop until no longer aliased
+
+	jmp	a20_done
+
+# This routine checks that the keyboard command queue is empty
+# (after emptying the output buffers)
+#
+# Some machines have delusions that the keyboard buffer is always full
+# with no keyboard attached...
+
+empty_8042:
+        pushl   %ecx
+        movl    $0x00FFFFFF, %ecx
+
+empty_8042_loop:
+        decl    %ecx
+        jz      empty_8042_end_loop
+
+        call    delay
+
+        inb     $0x64, %al                      # 8042 status port
+        testb   $1, %al                         # output buffer?
+        jz      no_output
+
+        call    delay
+        inb     $0x60, %al                      # read it
+        jmp     empty_8042_loop
+
+no_output:
+        testb   $2, %al                         # is input buffer full?
+        jnz     empty_8042_loop                 # yes - loop
+empty_8042_end_loop:
+        popl    %ecx
+        ret
+
+# Delay is needed after doing I/O
+delay:
+        jmp     .+2                             # jmp $+2
+        ret
+ 
+a20_done:
+	");
+
+}
+
+#endif
 
 static char hexdigits[16] = {
   '0', '1', '2', '3', '4', '5', '6', '7',



There is one more issue: the AWK script to generate
src/base/sys/arch/i486/build/DEFAULT/symnames.s outputs (don't ask me why)
lots of '.LF0: .asciz ""' lines, so there are double LF0 labels - of course
this doesn't assemble.  I manually deleted these offending lines.

----------------

If you need any further information, or want me to try something out, feel
free to mail me directly or on the eros-port/eros-arch lists.

This said, I wonder what I can now do with the OS.  It boots fine, I have to
enter 'c' (continue) a few times (als described in some mail on eros-port),
the the idle thread runs.  I typed away until the thing locked up saying
something about a buffer overrun in some Kbd handler :-(


Here and there a Unix (i.e. POSIX) emulator is mentioned, I wonder where it
is?  Or can you give me hints how to make Eros boot from the hard disc, and do
checkpoints to disc so that I can try the pull-the-plug-and-reboot-real-fast
effect?

Cheers,
Wolfgang Oertl