From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 28 07:33:55 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2ED0A1065A74 for ; Fri, 28 Aug 2009 07:33:55 +0000 (UTC) (envelope-from remodeler@alentogroup.org) Received: from courriel.marmotmail.com (courriel.marmotmail.com [85.17.36.172]) by mx1.freebsd.org (Postfix) with ESMTP id 9E75190256 for ; Fri, 28 Aug 2009 03:25:16 +0000 (UTC) Received: from bruce.epifora.com (localhost.local [127.0.0.1]) by courriel.marmotmail.com (Postfix) with ESMTP id 47DCF239625 for ; Fri, 28 Aug 2009 06:35:12 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by bruce.epifora.com (Postfix) with ESMTP id 2C9AD4761F9 for ; Thu, 27 Aug 2009 23:36:11 -0400 (EDT) Received: from bruce.epifora.com ([127.0.0.1]) by localhost (bruce.epifora.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 29974-10 for ; Thu, 27 Aug 2009 23:36:09 -0400 (EDT) Received: from alentogroup.org (localhost [127.0.0.1]) by bruce.epifora.com (Postfix) with ESMTP id 308A94761F8 for ; Thu, 27 Aug 2009 23:36:09 -0400 (EDT) From: "remodeler" To: freebsd-hackers@freebsd.org Date: Thu, 27 Aug 2009 23:36:09 -0400 Message-Id: <20090828033609.M34898@alentogroup.org> In-Reply-To: <200908270808.09790.jhb@freebsd.org> References: <20090826204513.M28384@alentogroup.org> <200908270808.09790.jhb@freebsd.org> X-OriginatingIP: 127.0.0.1 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Subject: Re: MBR hack for serial console X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2009 07:33:56 -0000 This is in response to John Baldwin's response to my question about using a non-legacy IO port for an i386 serial console. I notice that src/sys/boot/i386/boot0/boot0.S uses a call to the PC BIOS int 14h routine to access the serial console, if SIO is defined. I believe SIO is defined if make.conf specifies a port for BOOT_COMCONSOLE_PORT (though I'm probably wrong), in which case the boot0 executable would be made from src/sys/boot/i386/boot0/boot0sio when recompiling the boot blocks with: # cd /sys/boot # make clean # make # make install The 14h pc bios routine is definitely limited to 0x3F8, 0x2F8, 0x3E8, or 0x2E8 because it is called with the DX register set to specify COM1-COM4 (dx set to 0, 1, 2, or 3). boot2 looks like I might be able to specify the 0xe800 address for the serial console. src/sys/boot/i386/boot2/sio.S has this definition: .set SIO_PRT,SIOPRT but I am not sure where SIOPRT is set. I don't see if in any makefile. I would guess it is being set by BOOT_COMCONSOLE_PORT also? > if the device is behind a PCI-PCI bridge (which it probably is > if it is on bus 3) you have the problem that 0x3f8 is probably not > in the IO range decoded by the parent bridge The device is behind a bridge: pcib0 --> pci0 --> pcib3 --> pci3, but AMD doesn't have a data sheet available on the 'net to tell me what IO range is decoded by the parent bridge (750SB southbridge chip). I also notice in the PCI specification this ("I/O Space Address Decoding for Legacy Devices"): A function that supports a PC legacy function (IDE, VGA, etc.) is allowed to claim those addresses associated with the specific function when the I/O Space (see Figure 6-2) [the configuration space's Command Register layout, bit 0] enable bit is set. These addresses are not requested using a Base Address register but are assigned by initialization software. If a device identifies itself as a legacy function (class code), the initialization software grants the device permission to claim the I/O legacy addresses by setting the device’s I/O Space enable bit. > read the current value of the BAR instead and use that address? If I can set the serial console to a non-legacy port in boot2, that would be ideal. I don't think the boot0 routine would cause problems; it is just looking for keystrokes AFAIK. In this approach, I would guess it would make sense to read the value and set SIOPRT to it in boot2? I think from this point on, the serial console calls use sio.S, and these functions (sio_init, etc.) access the hardware directly with assembler out commands rather than using the PC BIOS routines like boot0. Would something as simple as: .set SIO_PRT,0xe800 in src/sys/boot/i386/boot2/sio.S work? If it does, I can develop code to read and set it to the current port instead of hard-coding it. Thanks again for your help.