PERFORCE change 28100 for review
Peter Wemm
peter at FreeBSD.org
Fri Apr 4 17:05:00 PST 2003
http://perforce.freebsd.org/chv.cgi?CH=28100
Change 28100 by peter at peter_overcee on 2003/04/04 17:04:27
add a serial trace function, and stub out some stuff. I dont
remember the details. :-]
Affected files ...
.. //depot/projects/hammer/sys/x86_64/x86_64/locore.s#20 edit
Differences ...
==== //depot/projects/hammer/sys/x86_64/x86_64/locore.s#20 (text+ko) ====
@@ -44,7 +44,6 @@
*/
#include <machine/asmacros.h>
-#include <machine/cputypes.h>
#include <machine/psl.h>
#include <machine/pmap.h>
#include <machine/specialreg.h>
@@ -151,6 +150,15 @@
call init_serial
PING('H');
+ PING('e');
+ PING('l');
+ PING('l');
+ PING('o');
+ PING('!');
+ PING('\r');
+ PING('\n');
+ hlt
+#if 0
call recover_metadata
PING('i');
call identify_cpu
@@ -274,8 +282,6 @@
movl %eax,R(cpu_id) # store cpu_id
movl %ebx,R(cpu_procinfo) # store cpu_procinfo
movl %edx,R(cpu_feature) # store cpu_feature
-
- movl $CPU_686,R(cpu) # call it a pentium pro
ret
@@ -423,6 +429,7 @@
/* Region descriptor for the gdt above */
gdt_rd: .word (gdt_end - gdt)
.word R(gdt)
+#endif
.bss
ALIGN_DATA /* just to be sure */
@@ -430,7 +437,120 @@
.space 0x1000 /* space for tmpstk - temporary stack */
HIDENAME(tmpstk):
+#if 0
physfree: .space 4 /* phys addr of next free page */
KPTphys: .space 4 /* phys addr of kernel page tables */
p0upa: .space 4 /* phys addr of proc0's UAREA */
p0kpa: .space 4 /* phys addr of proc0's STACK */
+#endif
+
+#define COMBRD(x) (1843200 / (16*(x)))
+#define COMCONSOLE 0x3f8
+#define CONSPEED 9600
+
+ .code32
+ .text
+/*
+ * void serial_putc(int ch);
+ * Write character `ch' to port COMCONSOLE.
+ */
+ .globl serial_putc
+ .type serial_putc at function
+serial_putc:
+ movl $10000, %ecx # timeout
+ movl $COMCONSOLE + 5, %edx # line status reg
+1:
+ decl %ecx
+ je 2f
+ inb %dx, %al
+ testb $0x20, %al
+ je 1b # TX buffer not empty
+
+ movb 4(%esp), %al
+
+ subl $5, %edx # TX output reg
+ outb %al, %dx # send this one
+
+2:
+ ret
+
+/*
+ * int serial_getc(void);
+ * Read a character from port COMCONSOLE.
+ */
+ .globl serial_getc
+ .type serial_getc at function
+serial_getc:
+ mov $COMCONSOLE + 5, %edx # line status reg
+1:
+ inb %dx, %al
+ testb $0x01, %al
+ je 1b # no rx char available
+
+ xorl %eax, %eax
+ subl $5, %edx # rx buffer reg
+ inb %dx, %al # fetch (first) character
+
+ andb $0x7F, %al # remove any parity bits we get
+ cmpb $0x7F, %al # make DEL...
+ jne 2f
+ movb $0x08, %al # look like BS
+2:
+ ret
+
+/*
+ * int serial_ischar(void);
+ * If there is a character in the input buffer of port COMCONSOLE,
+ * return nonzero; otherwise return 0.
+ */
+
+ .globl serial_ischar
+ .type serial_ischar at function
+serial_ischar:
+ xorl %eax, %eax
+ movl $COMCONSOLE + 5, %edx # line status reg
+ inb %dx, %al
+ andb $0x01, %al # rx char available?
+ ret
+
+/*
+ * void init_serial(void);
+ * Initialize port COMCONSOLE to speed CONSPEED, line settings 8N1.
+ */
+
+ .globl init_serial
+ .type init_serial at function
+init_serial:
+ movl $COMCONSOLE + 3, %edx # line control reg
+ movb $0x80, %al
+ outb %al, %dx # enable DLAB
+
+ subl $3, %edx # divisor latch, low byte
+ movb $COMBRD(CONSPEED) & 0xff, %al
+ outb %al, %dx
+ incl %edx # divisor latch, high byte
+ movb $COMBRD(CONSPEED) >> 8, %al
+ outb %al, %dx
+
+ incl %edx # fifo control register (if any)
+ xorl %eax,%eax
+ outb %al, %dx # disable fifo to reduce worst-case busy-wait
+
+ incl %edx # line control reg
+ movb $0x03, %al
+ outb %al, %dx # 8N1
+
+ incl %edx # modem control reg
+ outb %al, %dx # enable DTR/RTS
+
+ /* Flush the input buffer. */
+ incl %edx # line status reg
+1:
+ subl $5, %edx # rx buffer reg
+ inb %dx, %al # throw away (unconditionally the first time)
+ addl $5, %edx # line status reg
+ inb %dx, %al
+ testb $0x01, %al
+ jne 1b # more
+
+ ret
More information about the p4-projects
mailing list