Author: arty
Date: Fri Jan 5 08:50:55 2007
New Revision: 25302
URL:
http://svn.reactos.org/svn/reactos?rev=25302&view=rev
Log:
A test to see if things are mostly working. You can build it and then load
them on a prep box. You'll see output on the serial port if they linked
and bound properly. I have a patch for gxemul that can load pecoff and bind
imports, that can be used for this purpose.
Added:
branches/powerpc/reactos/tools/ppc-build/serialtest/
branches/powerpc/reactos/tools/ppc-build/serialtest/makefile
branches/powerpc/reactos/tools/ppc-build/serialtest/serial.c
branches/powerpc/reactos/tools/ppc-build/serialtest/serial.def
branches/powerpc/reactos/tools/ppc-build/serialtest/serial.h
branches/powerpc/reactos/tools/ppc-build/serialtest/serialtest.c
Added: branches/powerpc/reactos/tools/ppc-build/serialtest/makefile
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc-build…
==============================================================================
--- branches/powerpc/reactos/tools/ppc-build/serialtest/makefile (added)
+++ branches/powerpc/reactos/tools/ppc-build/serialtest/makefile Fri Jan 5 08:50:55 2007
@@ -1,0 +1,16 @@
+all: serialtest.exe serial.dll
+
+libserial.a serial.exp:
+ reactos-powerpc-dlltool -D serial.dll -e serial.exp -l libserial.a -d serial.def -k -A
-S reactos-powerpc-as -L reactos-powerpc-ld
+
+serialtest.exe: serial.h serialtest.c libserial.a
+ reactos-powerpc-gcc -Wl,--image-base=0x400000 -Wl,--entry,main -nostdlib -nostartfiles
-o $@ serialtest.c -L. -lserial
+
+serial.dll: serial.o serial.exp
+ reactos-powerpc-gcc -Wl,--image-base=0x600000 -Wl,--entry,sync -nostdlib -nostartfiles
-shared -o $@ serial.o serial.exp
+
+serial.o: serial.c
+ reactos-powerpc-gcc -c $<
+
+clean:
+ rm -rf *.o *.a *.exp *.dll
Added: branches/powerpc/reactos/tools/ppc-build/serialtest/serial.c
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc-build…
==============================================================================
--- branches/powerpc/reactos/tools/ppc-build/serialtest/serial.c (added)
+++ branches/powerpc/reactos/tools/ppc-build/serialtest/serial.c Fri Jan 5 08:50:55 2007
@@ -1,0 +1,37 @@
+#include "serial.h"
+
+void sync() {
+ __asm__("eieio\n\t"
+ "sync");
+}
+
+void send(char *serport, char c) {
+ /* Wait for Clear to Send */
+ while( !(serport[LSR] & 0x20) ) sync();
+
+ serport[THR] = c;
+ sync();
+}
+
+char recv(char *serport) {
+ char c;
+
+ while( !(serport[LSR] & 1) ) sync();
+
+ c = serport[RCV];
+ sync();
+}
+
+void setup(char *serport, int baud) {
+ int x = 115200 / baud;
+ serport[LCR] = 128;
+ sync();
+ serport[BAUDLOW] = x & 255;
+ sync();
+ serport[BAUDHIGH] = x >> 8;
+ sync();
+ serport[LCR] = 3;
+ sync();
+ serport[IER] = 0;
+ sync();
+}
Added: branches/powerpc/reactos/tools/ppc-build/serialtest/serial.def
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc-build…
==============================================================================
--- branches/powerpc/reactos/tools/ppc-build/serialtest/serial.def (added)
+++ branches/powerpc/reactos/tools/ppc-build/serialtest/serial.def Fri Jan 5 08:50:55
2007
@@ -1,0 +1,5 @@
+LIBRARY SERIAL.DLL
+EXPORTS
+setup@8
+send@8
+recv@4
Added: branches/powerpc/reactos/tools/ppc-build/serialtest/serial.h
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc-build…
==============================================================================
--- branches/powerpc/reactos/tools/ppc-build/serialtest/serial.h (added)
+++ branches/powerpc/reactos/tools/ppc-build/serialtest/serial.h Fri Jan 5 08:50:55 2007
@@ -1,0 +1,21 @@
+#ifndef SERIAL_H
+#define SERIAL_H
+
+#define RCV 0
+#define THR 0
+#define BAUDLOW 0
+#define BAUDHIGH 1
+#define IER 1
+#define FCR 2
+#define ISR 2
+#define LCR 3
+#define MCR 4
+#define LSR 5
+#define MSR 6
+#define SPR 7
+
+extern void send(char *serport, char c);
+extern char recv(char *serport);
+extern void setup(char *serport, int baud);
+
+#endif//SERIAL_H
Added: branches/powerpc/reactos/tools/ppc-build/serialtest/serialtest.c
URL:
http://svn.reactos.org/svn/reactos/branches/powerpc/reactos/tools/ppc-build…
==============================================================================
--- branches/powerpc/reactos/tools/ppc-build/serialtest/serialtest.c (added)
+++ branches/powerpc/reactos/tools/ppc-build/serialtest/serialtest.c Fri Jan 5 08:50:55
2007
@@ -1,0 +1,17 @@
+#include "serial.h"
+
+int main() {
+ int i;
+ char *iobase = (char *)0x80000000;
+ char *serport = iobase + 0x3f8;
+
+ setup( serport, 9600 );
+
+ for( i = ' '; i <= '~'; i++ ) {
+ send(serport, i);
+ }
+ send(serport, 0xa);
+
+ return 0;
+}
+