Re: ntpd(8) option to provide time even when not being synced

2012-09-08 Thread Stuart Henderson
On 2012/09/07 20:16, Mike. wrote:
 On 9/7/2012 at 6:35 PM Patrick Wildt wrote:
 
 |I have machines which might not have an internet connection, but still
 |need to
 |be synchronized,
 |even if the time's not correct. What's important is, that every
 machine in
 |the
 |network has the
 |same time. Also the ntp server doesn't have a sensor to synchronize
 to.
 ===
 
 
 
 Comments in the context of RFC5905...
 
 
 Instead of sending out stratum 10, it may be better to send out stratum
 16 per the RFC, indicating the clock is unsynchronized.

I agree, but there is a client issue with doing this for Patrick's
use case.

rdate -n clients don't accept time from a stratum 15, and OpenNTPd
clients don't accept time from a stratum 16.

Apart from being different numbers (which should probably be the
same between the two clients), I think this is sane as a default, I
don't believe they should accept time from an unsynchronised time
server by default. However there are cases where it might be useful
to make this configurable.

 You are effectively sync'ing to the local clock.  What will you be
 sending out for the reference ID to the clients that sync up to the
 server?   I would suggest either 127.0.0.1, formatted appropriately, or
 you might use the four characters XLCL to indicate you are using the
 LoCaL clock.

Agreed.



Re: Use ACPI to detect secondary PCI root segments on x86

2012-09-08 Thread Mark Kettenis
 Date: Thu, 6 Sep 2012 11:24:01 +0200
 From: Christian Ehrhardt ehrha...@genua.de
 
 Hi,
 
 most modern x86 hardware includes more than one PCI root segement.
 E.g. a hardware that I have here has three PCI root segemnts with bus
 numbers 0, 0x7f, 0x80 and 0xff respectively. (0x7f and 0xff host the
 uncore devices of each processor).

Well, machines with multiple host bridges have been around for a
while.  Some of them even pre-date ACPI.

 
 These segments are already detected by APCI but this information is not
 used when attaching PCI busses to the mainbus. Below is a patch that
 should solve the PCI bus detection problem in a robust way.

I hate ACPI!  It's full of lies; I don't trust it.  It is much better
to detect these additional PCI busses by looking at actual hardware
registers.  So before we go down this path, can you investigate that?
It seems the bus number for the additional Uncore devices of the
Xeon E5 1600/2600 CPUs is available in config register 0x108 of device
0:5:0.  But I haven't figured how to find the bus number for the
second socket.  Looking at the AML for this machine and determining
how it detects these additional busses might provide some clues.  Feel
free to send me the acpidump output for this box.

 There's a small problem though: Some of the secondary PCI segments
 can show up as busses behind some kind of host bridge device dowstream
 of pci bus 0, too. These PCI busses would be attached twice, now. Thus we
 keep track of attached root segemnents in the ACPI code.

Yup.  Since we have code to detect additional host bridges some of
them may already have been attached.  And it would be a good way to
defend against ACPI lying to us.  However, please keep the ACPI hooks
out of the MI PCI code.  It'd be better if you used pci_attach_hook(),
which lives in arch/pci/pci_machdep.c.


 Index: arch/i386/i386/mainbus.c
 ===
 RCS file: /cvs/src/sys/arch/i386/i386/mainbus.c,v
 retrieving revision 1.48
 diff -u -r1.48 mainbus.c
 --- arch/i386/i386/mainbus.c  3 Nov 2010 10:15:23 -   1.48
 +++ arch/i386/i386/mainbus.c  6 Sep 2012 08:58:38 -
 @@ -244,6 +244,9 @@
   mba.mba_pba.pba_domain = pci_ndomains++;
   mba.mba_pba.pba_bus = 0;
   config_found(self, mba.mba_pba, mainbus_print);
 +#if NACPI  0
 + acpi_pciroots_attach(self, mba.mba_pba, mainbus_print);
 +#endif
   }
  #endif
  
 Index: dev/acpi/acpi.c
 ===
 RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
 retrieving revision 1.238
 diff -u -r1.238 acpi.c
 --- dev/acpi/acpi.c   13 Jul 2012 11:51:41 -  1.238
 +++ dev/acpi/acpi.c   6 Sep 2012 08:58:39 -
 @@ -392,6 +392,8 @@
  
  TAILQ_HEAD(, acpi_pci) acpi_pcidevs =
  TAILQ_HEAD_INITIALIZER(acpi_pcidevs);
 +TAILQ_HEAD(, acpi_pci) acpi_pcirootdevs = 
 +TAILQ_HEAD_INITIALIZER(acpi_pcirootdevs);
  
  int acpi_getpci(struct aml_node *node, void *arg);
  int acpi_getminbus(union acpi_resource *crs, void *arg);
 @@ -480,6 +482,7 @@
   node-pci = pci;
   dnprintf(10, found PCI root: %s %d\n,
   aml_nodename(node), pci-bus);
 + TAILQ_INSERT_TAIL(acpi_pcirootdevs, pci, next);
   }
   aml_freevalue(res);
   return 0;
 @@ -548,6 +551,31 @@
   dev-dv_xname, aml_nodename(pdev-node));
   pdev-device = dev;
   }
 + }
 +}
 +
 +void
 +acpi_pciroot_match(struct device *dev, int bus)
 +{
 + struct acpi_pci *pdev;
 +
 + TAILQ_FOREACH(pdev, acpi_pcirootdevs, next) {
 + if (pdev-bus == bus)
 + pdev-device = dev;
 + }
 +}
 +
 +void
 +acpi_pciroots_attach(struct device *dev, void *aux, cfprint_t pr)
 +{
 + struct acpi_pci *pdev;
 + struct pcibus_attach_args   *pba = aux;
 +
 + TAILQ_FOREACH(pdev, acpi_pcirootdevs, next) {
 + if (pdev-device)   /* Already attached */
 + continue;
 + pba-pba_bus = pdev-bus;
 + config_found(dev, pba, pr);
   }
  }
  
 Index: dev/acpi/acpivar.h
 ===
 RCS file: /cvs/src/sys/dev/acpi/acpivar.h,v
 retrieving revision 1.71
 diff -u -r1.71 acpivar.h
 --- dev/acpi/acpivar.h15 Apr 2011 17:34:51 -  1.71
 +++ dev/acpi/acpivar.h6 Sep 2012 08:58:39 -
 @@ -322,6 +322,9 @@
  void acpi_powerdown_task(void *, int);
  void acpi_sleep_task(void *, int);
  
 +void acpi_pciroot_match(struct device *, int);
 +void acpi_pciroots_attach(struct device *, void *, cfprint_t);
 +
  #endif
  
  #endif /* !_ACPI_WAKECODE */
 Index: dev/pci/pci.c
 ===
 RCS file: /cvs/src/sys/dev/pci/pci.c,v
 retrieving revision 1.94
 diff -u -r1.94 pci.c
 --- 

FTDI FT2232H

2012-09-08 Thread Raphael Graf
This adds support for the FT2232H and FT4232H serial adapters.
(FT2232H found on the BeagleBone).

These devices have a 120MHz base clock for the baud rate generator
and need a different encoding for the baud rate divisor.
The values for ibufsize/obufsize are now taken from the endpoint descriptors.

I can't be sure that this does not break anything. It would have to be
tested on various devices.

Regards
Raphael


Index: sys/dev/usb/uftdireg.h
===
RCS file: /cvs/src/sys/dev/usb/uftdireg.h,v
retrieving revision 1.12
diff -u -p -r1.12 uftdireg.h
--- sys/dev/usb/uftdireg.h  5 Jul 2008 14:41:28 -   1.12
+++ sys/dev/usb/uftdireg.h  8 Sep 2012 14:32:13 -
@@ -35,7 +35,8 @@

 enum uftdi_type {
UFTDI_TYPE_SIO,
-   UFTDI_TYPE_8U232AM
+   UFTDI_TYPE_8U232AM,
+   UFTDI_TYPE_2232H
 };

 /*
@@ -91,7 +92,8 @@ enum {
ftdi_sio_b115200 = 9
 };

-#define FTDI_8U232AM_FREQ 300
+#define FTDI_8U232AM_FREQ 300 /* (48MHz / 16) */
+#define FTDI_2232H_FREQ 1200 /* (120MHz / 10) */

 /* Bounds for normal divisors as 4-bit fixed precision ints. */
 #define FTDI_8U232AM_MIN_DIV 0x20
Index: sys/dev/usb/uftdi.c
===
RCS file: /cvs/src/sys/dev/usb/uftdi.c,v
retrieving revision 1.62
diff -u -p -r1.62 uftdi.c
--- sys/dev/usb/uftdi.c 28 Oct 2011 01:45:55 -  1.62
+++ sys/dev/usb/uftdi.c 8 Sep 2012 14:32:14 -
@@ -105,6 +105,7 @@ voiduftdi_write(void *sc, int portno, u
u_int32_t *count);
 void   uftdi_break(void *sc, int portno, int onoff);
 intuftdi_8u232am_getrate(speed_t speed, int *rate);
+intuftdi_2232h_getrate(speed_t speed, int *rate);

 struct ucom_methods uftdi_methods = {
uftdi_get_status,
@@ -824,6 +825,9 @@ uftdi_attach(struct device *parent, stru
if (uaa-release  0x0200) {
sc-sc_type = UFTDI_TYPE_SIO;
sc-sc_hdrlen = 1;
+   } else if (uaa-release == 0x0700  || uaa-release == 0x0800) {
+   sc-sc_type = UFTDI_TYPE_2232H;
+   sc-sc_hdrlen = 0;
} else {
sc-sc_type = UFTDI_TYPE_8U232AM;
sc-sc_hdrlen = 0;
@@ -842,11 +846,16 @@ uftdi_attach(struct device *parent, stru
addr = ed-bEndpointAddress;
dir = UE_GET_DIR(ed-bEndpointAddress);
attr = ed-bmAttributes  UE_XFERTYPE;
-   if (dir == UE_DIR_IN  attr == UE_BULK)
+   if (dir == UE_DIR_IN  attr == UE_BULK) {
uca.bulkin = addr;
-   else if (dir == UE_DIR_OUT  attr == UE_BULK)
+   uca.ibufsize = (UGETW(ed-wMaxPacketSize)  0) ?
+   UGETW(ed-wMaxPacketSize) : UFTDIIBUFSIZE;
+   } else if (dir == UE_DIR_OUT  attr == UE_BULK) {
uca.bulkout = addr;
-   else {
+   uca.obufsize = (UGETW(ed-wMaxPacketSize)  0) ?
+   UGETW(ed-wMaxPacketSize) : UFTDIOBUFSIZE;
+   uca.obufsize-= sc-sc_hdrlen;
+   } else {
printf(%s: unexpected endpoint\n, devname);
goto bad;
}
@@ -867,9 +876,7 @@ uftdi_attach(struct device *parent, stru
else
uca.portno = FTDI_PIT_SIOA + id-bInterfaceNumber;
/* bulkin, bulkout set above */
-   uca.ibufsize = UFTDIIBUFSIZE;
-   uca.obufsize = UFTDIOBUFSIZE - sc-sc_hdrlen;
-   uca.ibufsizepad = UFTDIIBUFSIZE;
+   uca.ibufsizepad = uca.ibufsize;
uca.opkthdrlen = sc-sc_hdrlen;
uca.device = dev;
uca.iface = iface;
@@ -1076,11 +1083,15 @@ uftdi_param(void *vsc, int portno, struc
if (uftdi_8u232am_getrate(t-c_ospeed, rate) == -1)
return (EINVAL);
break;
+   case UFTDI_TYPE_2232H:
+   if (uftdi_2232h_getrate(t-c_ospeed, rate) == -1)
+return (EINVAL);
+   break;
}
req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
req.bRequest = FTDI_SIO_SET_BAUD_RATE;
USETW(req.wValue, rate);
-   USETW(req.wIndex, portno);
+   USETW(req.wIndex, ((rate  8)  0xFF00) | portno);
USETW(req.wLength, 0);
DPRINTFN(2,(uftdi_param: reqtype=0x%02x req=0x%02x value=0x%04x 
index=0x%04x len=%d\n, req.bmRequestType, req.bRequest,
@@ -1249,4 +1260,34 @@ uftdi_8u232am_getrate(speed_t speed, int
 done:
*rate = result;
return (0);
+}
+
+int
+uftdi_2232h_getrate(speed_t speed, int *rate)
+{
+   char sub[8] = {0, 3, 2, 4, 1, 5, 6, 7};
+   int n = (FTDI_2232H_FREQ  3) / speed;
+   int s = n  7;
+   int result = (n  3) | (sub[s]  14);
+   int resultspeed, accuracy;
+
+   /* Special cases */
+   if (result == 1)
+   result = 0;
+   else if 

Биллборды на Октябрь-Ноябрь

2012-09-08 Thread Валентина
Äåíü äîáðûé, íà îêòÿáðü åùå îñòàëèñü íåïëîõèå áîðäû, êàê ïî Êèåâó òàê è ïî
Óêðàèíå.
Áîðäû Êèåâ - îò 2500ãðí.
Ñèòèëàéòû - îò 900ãðí.
Òðîëû - îò 1900ãðí.
Ìîñòû - îò 4000ãðí.
Öåíû ïî ðåãèîíàì óòî÷íÿéòå ó ìåíåäæåðîâ.
Äëÿ çàïðîñà àäðåñíîé ïðîãðàììû çâîíèòå íàì â îôèñ.

[demime 1.01d removed an attachment of type image/bmp which had a name of 
ckm.bmp]



remove mapstore

2012-09-08 Thread Tobias Ulmer
mapstore looks like an old error handling artifact. No binary change on
amd64.

Index: alpha/dev/bus_dma.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/alpha/dev/bus_dma.c,v
retrieving revision 1.31
diff -u -p -r1.31 bus_dma.c
--- alpha/dev/bus_dma.c 23 Jun 2011 20:44:38 -  1.31
+++ alpha/dev/bus_dma.c 8 Sep 2012 23:32:56 -
@@ -64,7 +64,6 @@ _bus_dmamap_create(t, size, nsegments, m
bus_dmamap_t *dmamp;
 {
struct alpha_bus_dmamap *map;
-   void *mapstore;
size_t mapsize;
 
/*
@@ -81,11 +80,10 @@ _bus_dmamap_create(t, size, nsegments, m
 */
mapsize = sizeof(struct alpha_bus_dmamap) +
(sizeof(bus_dma_segment_t) * (nsegments - 1));
-   if ((mapstore = malloc(mapsize, M_DEVBUF, (flags  BUS_DMA_NOWAIT) ?
+   if ((map = malloc(mapsize, M_DEVBUF, (flags  BUS_DMA_NOWAIT) ?
(M_NOWAIT | M_ZERO) : (M_WAITOK | M_ZERO))) == NULL)
return (ENOMEM);
 
-   map = (struct alpha_bus_dmamap *)mapstore;
map-_dm_size = size;
map-_dm_segcnt = nsegments;
map-_dm_maxsegsz = maxsegsz;
Index: amd64/amd64/bus_dma.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/amd64/amd64/bus_dma.c,v
retrieving revision 1.38
diff -u -p -r1.38 bus_dma.c
--- amd64/amd64/bus_dma.c   3 Jul 2011 18:31:02 -   1.38
+++ amd64/amd64/bus_dma.c   8 Sep 2012 23:32:58 -
@@ -125,7 +125,6 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamp)
 {
struct bus_dmamap *map;
-   void *mapstore;
size_t mapsize;
 
/*
@@ -142,12 +141,11 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 */
mapsize = sizeof(struct bus_dmamap) +
(sizeof(bus_dma_segment_t) * (nsegments - 1));
-   if ((mapstore = malloc(mapsize, M_DEVBUF,
+   if ((map = malloc(mapsize, M_DEVBUF,
(flags  BUS_DMA_NOWAIT) ?
(M_NOWAIT|M_ZERO) : (M_WAITOK|M_ZERO))) == NULL)
return (ENOMEM);
 
-   map = (struct bus_dmamap *)mapstore;
map-_dm_size = size;
map-_dm_segcnt = nsegments;
map-_dm_maxsegsz = maxsegsz;
Index: arm/arm/bus_dma.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/arm/arm/bus_dma.c,v
retrieving revision 1.21
diff -u -p -r1.21 bus_dma.c
--- arm/arm/bus_dma.c   23 Jun 2011 20:44:39 -  1.21
+++ arm/arm/bus_dma.c   8 Sep 2012 23:33:00 -
@@ -86,7 +86,6 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamp)
 {
struct arm32_bus_dmamap *map;
-   void *mapstore;
size_t mapsize;
 
 #ifdef DEBUG_DMA
@@ -108,11 +107,10 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 */
mapsize = sizeof(struct arm32_bus_dmamap) +
(sizeof(bus_dma_segment_t) * (nsegments - 1));
-   if ((mapstore = malloc(mapsize, M_DEVBUF, (flags  BUS_DMA_NOWAIT) ?
+   if ((map = malloc(mapsize, M_DEVBUF, (flags  BUS_DMA_NOWAIT) ?
(M_NOWAIT | M_ZERO) : (M_WAITOK | M_ZERO))) == NULL)
return (ENOMEM);
 
-   map = (struct arm32_bus_dmamap *)mapstore;
map-_dm_size = size;
map-_dm_segcnt = nsegments;
map-_dm_maxsegsz = maxsegsz;
Index: aviion/aviion/bus_dma.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/aviion/aviion/bus_dma.c,v
retrieving revision 1.5
diff -u -p -r1.5 bus_dma.c
--- aviion/aviion/bus_dma.c 9 Oct 2011 17:08:21 -   1.5
+++ aviion/aviion/bus_dma.c 8 Sep 2012 23:33:03 -
@@ -70,7 +70,6 @@ bus_dmamap_create(t, size, nsegments, ma
 bus_dmamap_t *dmamp;
 {
 struct m88k_bus_dmamap *map;
-void *mapstore;
 size_t mapsize;
 
 /*
@@ -87,11 +86,10 @@ bus_dmamap_create(t, size, nsegments, ma
  */
 mapsize = sizeof(struct m88k_bus_dmamap) +
 (sizeof(bus_dma_segment_t) * (nsegments - 1));
-if ((mapstore = malloc(mapsize, M_DEVBUF, (flags  BUS_DMA_NOWAIT) ?
+if ((map = malloc(mapsize, M_DEVBUF, (flags  BUS_DMA_NOWAIT) ?
(M_NOWAIT | M_ZERO) : (M_WAITOK | M_ZERO))) == NULL)
 return (ENOMEM);
 
-map = (struct m88k_bus_dmamap *)mapstore;
 map-_dm_size = size;
 map-_dm_segcnt = nsegments;
 map-_dm_maxsegsz = maxsegsz;
Index: i386/i386/bus_dma.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/i386/i386/bus_dma.c,v
retrieving revision 1.25
diff -u -p -r1.25 bus_dma.c
--- i386/i386/bus_dma.c 23 Jun 2011 20:44:39 -  1.25
+++ i386/i386/bus_dma.c 8 Sep 2012 23:33:20 -
@@ -90,7 +90,6 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_