From owner-p4-projects@FreeBSD.ORG Fri Apr 4 17:05:00 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 93EBF37B404; Fri, 4 Apr 2003 17:04:59 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1D16537B401 for ; Fri, 4 Apr 2003 17:04:59 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id AE24D43F93 for ; Fri, 4 Apr 2003 17:04:58 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h3514w0U087537 for ; Fri, 4 Apr 2003 17:04:58 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h3514wY5087534 for perforce@freebsd.org; Fri, 4 Apr 2003 17:04:58 -0800 (PST) Date: Fri, 4 Apr 2003 17:04:58 -0800 (PST) Message-Id: <200304050104.h3514wY5087534@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 28100 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Apr 2003 01:05:00 -0000 http://perforce.freebsd.org/chv.cgi?CH=28100 Change 28100 by peter@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 -#include #include #include #include @@ -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@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@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@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@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