From owner-freebsd-current@FreeBSD.ORG Sat Oct 13 00:04:32 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0CF411E5 for ; Sat, 13 Oct 2012 00:04:32 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-oa0-f54.google.com (mail-oa0-f54.google.com [209.85.219.54]) by mx1.freebsd.org (Postfix) with ESMTP id C06B78FC0C for ; Sat, 13 Oct 2012 00:04:31 +0000 (UTC) Received: by mail-oa0-f54.google.com with SMTP id n9so4519963oag.13 for ; Fri, 12 Oct 2012 17:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=/WSldf+kEkaSXKR0oPLjHO/fk2GPMCM7RKE2Y3BV8EA=; b=LEil+sY/v72VMmIrgishr1anogZY3/u+QbHjPinQ0sGo9BxuwXfUiMDjpC1SPfuGhH MDNer9ILq41ok6AJ/2GGlsOWegIzngJNfYL2gqG7Zx9eb0AyehYWZuzBkQ3MuzkTknVj XJeP5pq/XFuJdv9kpTu4SaV26ZIe+w7QS8qoj70L+TMp8LnTcEm1kN05HRZJxZR9+2Tk dnfsZJHOnLPWwfMsUPiC6LFZIcr/AHTi9YOZylmQ/Y7EVBq5Sjb3RTX9JkGo7KfIoB/G zjXGhYooXm1ivm5rhDMldy6G/VI916LZqMjVFlr/ENVkKxZpngJDKUH77MOMMqq6Qada DrWA== MIME-Version: 1.0 Received: by 10.182.31.50 with SMTP id x18mr4652666obh.56.1350086664949; Fri, 12 Oct 2012 17:04:24 -0700 (PDT) Received: by 10.76.167.202 with HTTP; Fri, 12 Oct 2012 17:04:24 -0700 (PDT) In-Reply-To: <5078A803.7070705@delphij.net> References: <5078A803.7070705@delphij.net> Date: Fri, 12 Oct 2012 17:04:24 -0700 Message-ID: Subject: Re: boot2/loader: serial port handling From: Garrett Cooper To: d@delphij.net Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-current@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Oct 2012 00:04:32 -0000 On Fri, Oct 12, 2012 at 4:30 PM, Xin Li wrote: > Hi, > > We have some rather hacky quick hack at $WORK that addresses a problem > we have found with boot2/loader and wants to share it and see if we can > have more neat solution. > > Here is the problem: the current boot2 and loader have various places > where it considers serial port to exist. When the port is not there, > the code would hang because it tests whether the hardware's -READY bit, > basically something like: > > do { > } while (inpb(state register) & READY_BIT); > > This unfortunately would enter an infinite loop when the device is not > present -- all in operations would get all bits set. > > To reproduce this, one can compile boot2/loader with non-existent port > and the system will hang at very early stage of boot. > > --- > > Because boot2 is size constrained we can not use very sophisticated > detection logic there, what I did is to use something like: > > outb(line control register, word) > if (inb(line control register) != word) > Disable the serial port read/write > > For loader I'm not sure if we should use better detection logic. By the > way, it seems that the system may force using the default console in > loader regardless if the detection logic said no, if it decides that's > the only usable one. > > So what would be the right way to solve these issue? Have you tried out Andriy's commit yet to loader(8) (r241301)? Cheers, -Garrett