svn commit: r349714 - head/sys/dev/proto

2019-07-03 Thread Marcel Moolenaar
Author: marcel
Date: Thu Jul  4 02:51:34 2019
New Revision: 349714
URL: https://svnweb.freebsd.org/changeset/base/349714

Log:
  Lock busdma operations and serialize detach against open/close
  
  Use sx to allow M_WAITOK allocations (suggested by markj).
  
  admbugs: 782
  Reviewed by:  markj

Modified:
  head/sys/dev/proto/proto.h
  head/sys/dev/proto/proto_busdma.c
  head/sys/dev/proto/proto_busdma.h
  head/sys/dev/proto/proto_core.c

Modified: head/sys/dev/proto/proto.h
==
--- head/sys/dev/proto/proto.h  Wed Jul  3 22:41:54 2019(r349713)
+++ head/sys/dev/proto/proto.h  Thu Jul  4 02:51:34 2019(r349714)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2014, 2015 Marcel Moolenaar
+ * Copyright (c) 2014, 2015, 2019 Marcel Moolenaar
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,7 +36,8 @@
 #definePROTO_RES_BUSDMA11
 
 struct proto_res {
-   int r_type;
+   u_int   r_type:8;
+   u_int   r_opened:1;
int r_rid;
union {
struct resource *res;
@@ -47,13 +48,14 @@ struct proto_res {
void*cookie;
struct cdev *cdev;
} r_u;
-   uintptr_t   r_opened;
 };
 
 struct proto_softc {
device_tsc_dev;
struct proto_res sc_res[PROTO_RES_MAX];
int sc_rescnt;
+   int sc_opencnt;
+   struct mtx  sc_mtx;
 };
 
 extern devclass_t proto_devclass;

Modified: head/sys/dev/proto/proto_busdma.c
==
--- head/sys/dev/proto/proto_busdma.c   Wed Jul  3 22:41:54 2019
(r349713)
+++ head/sys/dev/proto/proto_busdma.c   Thu Jul  4 02:51:34 2019
(r349714)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2015 Marcel Moolenaar
+ * Copyright (c) 2015, 2019 Marcel Moolenaar
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -355,6 +356,7 @@ proto_busdma_attach(struct proto_softc *sc)
struct proto_busdma *busdma;
 
busdma = malloc(sizeof(*busdma), M_PROTO_BUSDMA, M_WAITOK | M_ZERO);
+   sx_init(>sxlck, "proto-busdma");
return (busdma);
 }
 
@@ -363,6 +365,7 @@ proto_busdma_detach(struct proto_softc *sc, struct pro
 {
 
proto_busdma_cleanup(sc, busdma);
+   sx_destroy(>sxlck);
free(busdma, M_PROTO_BUSDMA);
return (0);
 }
@@ -373,10 +376,12 @@ proto_busdma_cleanup(struct proto_softc *sc, struct pr
struct proto_md *md, *md1;
struct proto_tag *tag, *tag1;
 
+   sx_xlock(>sxlck);
LIST_FOREACH_SAFE(md, >mds, mds, md1)
proto_busdma_md_destroy_internal(busdma, md);
LIST_FOREACH_SAFE(tag, >tags, tags, tag1)
proto_busdma_tag_destroy(busdma, tag);
+   sx_xunlock(>sxlck);
return (0);
 }
 
@@ -388,6 +393,8 @@ proto_busdma_ioctl(struct proto_softc *sc, struct prot
struct proto_md *md;
int error;
 
+   sx_xlock(>sxlck);
+
error = 0;
switch (ioc->request) {
case PROTO_IOC_BUSDMA_TAG_CREATE:
@@ -470,6 +477,9 @@ proto_busdma_ioctl(struct proto_softc *sc, struct prot
error = EINVAL;
break;
}
+
+   sx_xunlock(>sxlck);
+
return (error);
 }
 
@@ -477,11 +487,20 @@ int
 proto_busdma_mmap_allowed(struct proto_busdma *busdma, vm_paddr_t physaddr)
 {
struct proto_md *md;
+   int result;
 
+   sx_xlock(>sxlck);
+
+   result = 0;
LIST_FOREACH(md, >mds, mds) {
if (physaddr >= trunc_page(md->physaddr) &&
-   physaddr <= trunc_page(md->physaddr + md->tag->maxsz))
-   return (1);
+   physaddr <= trunc_page(md->physaddr + md->tag->maxsz)) {
+   result = 1;
+   break;
+   }
}
-   return (0);
+
+   sx_xunlock(>sxlck);
+
+   return (result);
 }

Modified: head/sys/dev/proto/proto_busdma.h
==
--- head/sys/dev/proto/proto_busdma.h   Wed Jul  3 22:41:54 2019
(r349713)
+++ head/sys/dev/proto/proto_busdma.h   Thu Jul  4 02:51:34 2019
(r349714)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2015 Marcel Moolenaar
+ * Copyright (c) 2015, 2019 Marcel Moolenaar
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -60,6 +60,7 @@ struct proto_busdma {
LIST_HEAD(,proto_tag)   tags;
LIST_HEAD(,proto_md)mds;
bus_dma_tag_t   bd_r

svn commit: r349551 - in head/tools/bus_space: Python examples

2019-06-29 Thread Marcel Moolenaar
Author: marcel
Date: Sun Jun 30 02:29:12 2019
New Revision: 349551
URL: https://svnweb.freebsd.org/changeset/base/349551

Log:
  Add support for Python 3 and make it the default.
  
  Python 2.7 will retire on Januari 1, 2020.

Modified:
  head/tools/bus_space/Python/Makefile
  head/tools/bus_space/Python/lang.c
  head/tools/bus_space/examples/am79c900_diag.py

Modified: head/tools/bus_space/Python/Makefile
==
--- head/tools/bus_space/Python/MakefileSun Jun 30 02:08:13 2019
(r349550)
+++ head/tools/bus_space/Python/MakefileSun Jun 30 02:29:12 2019
(r349551)
@@ -3,7 +3,11 @@
 SHLIB_NAME=bus.so
 SRCS=  lang.c
 
-CFLAGS+= -I${.CURDIR}/.. -I/usr/local/include/python2.7
-LDFLAGS+= -L/usr/local/lib -lpython2.7
+# Set PYTHON to the version to compile against.
+# E.g. "python2.7", "python3.6", etc...
+PYTHON=python3.6m
+
+CFLAGS+= -I${.CURDIR}/.. -I/usr/local/include/${PYTHON}
+LDFLAGS+= -L/usr/local/lib -l${PYTHON}
 
 .include 

Modified: head/tools/bus_space/Python/lang.c
==
--- head/tools/bus_space/Python/lang.c  Sun Jun 30 02:08:13 2019
(r349550)
+++ head/tools/bus_space/Python/lang.c  Sun Jun 30 02:29:12 2019
(r349551)
@@ -412,6 +412,12 @@ busdma_sync_range(PyObject *self, PyObject *args)
Py_RETURN_NONE;
 }
 
+/*
+ * Module methods and initialization.
+ */
+
+static char bus_docstr[] = "Access to H/W bus memory and register areas.";
+
 static PyMethodDef bus_methods[] = {
 { "read_1", bus_read_1, METH_VARARGS, "Read a 1-byte data item." },
 { "read_2", bus_read_2, METH_VARARGS, "Read a 2-byte data item." },
@@ -431,6 +437,9 @@ static PyMethodDef bus_methods[] = {
 { NULL, NULL, 0, NULL }
 };
 
+static char busdma_docstr[] = "A bus- and device-independent interface"
+" to Direct Memory Access (DMA) mechanisms.";
+
 static PyMethodDef busdma_methods[] = {
 { "tag_create", busdma_tag_create, METH_VARARGS,
"Create a root tag." },
@@ -470,18 +479,12 @@ static PyMethodDef busdma_methods[] = {
 { NULL, NULL, 0, NULL }
 };
 
-PyMODINIT_FUNC
-initbus(void)
+static PyObject *
+module_initialize(PyObject *bus, PyObject *busdma)
 {
-   PyObject *bus, *busdma;
 
-   bus = Py_InitModule("bus", bus_methods);
-   if (bus == NULL)
-   return;
-   busdma = Py_InitModule("busdma", busdma_methods);
-   if (busdma == NULL)
-   return;
-   PyModule_AddObject(bus, "dma", busdma);
+   if (bus == NULL || busdma == NULL)
+   return (NULL);
 
PyModule_AddObject(busdma, "MD_BUS_SPACE", Py_BuildValue("i", 0));
PyModule_AddObject(busdma, "MD_PHYS_SPACE", Py_BuildValue("i", 1));
@@ -491,4 +494,49 @@ initbus(void)
PyModule_AddObject(busdma, "SYNC_POSTREAD", Py_BuildValue("i", 2));
PyModule_AddObject(busdma, "SYNC_PREWRITE", Py_BuildValue("i", 4));
PyModule_AddObject(busdma, "SYNC_POSTWRITE", Py_BuildValue("i", 8));
+
+   PyModule_AddObject(bus, "dma", busdma);
+   return (bus);
 }
+
+#if PY_MAJOR_VERSION >= 3
+
+static struct PyModuleDef bus_module = {
+   PyModuleDef_HEAD_INIT,
+   "bus",
+   bus_docstr,
+-1,
+   bus_methods,
+};
+
+static struct PyModuleDef busdma_module = {
+   PyModuleDef_HEAD_INIT,
+   "busdma",
+   busdma_docstr,
+-1,
+   busdma_methods,
+};
+
+PyMODINIT_FUNC
+PyInit_bus(void)
+{
+   PyObject *bus, *busdma;
+
+   bus = PyModule_Create(_module);
+   busdma = PyModule_Create(_module);
+   return (module_initialize(bus, busdma));
+}
+
+#else /* PY_MAJOR_VERSION >= 3 */
+
+PyMODINIT_FUNC
+initbus(void)
+{
+   PyObject *bus, *busdma;
+
+   bus = Py_InitModule3("bus", bus_methods, bus_docstr);
+   busdma = Py_InitModule3("busdma", busdma_methods, busdma_docstr);
+   (void)module_initialize(bus, busdma);
+}
+
+#endif /* PY_MAJOR_VERSION >= 3 */

Modified: head/tools/bus_space/examples/am79c900_diag.py
==
--- head/tools/bus_space/examples/am79c900_diag.py  Sun Jun 30 02:08:13 
2019(r349550)
+++ head/tools/bus_space/examples/am79c900_diag.py  Sun Jun 30 02:29:12 
2019(r349551)
@@ -54,7 +54,7 @@ import time
 sys.path.append('/usr/lib')
 
 import bus
-import busdma
+from bus import dma as busdma
 
 
 # ILACC initialization block definition
@@ -161,7 +161,7 @@ def ip_str(a):
 
 
 def mac_is(l, r):
-for i in xrange(6):
+for i in range(6):
 if l[i] != r[i]:
 return False
 return True
@@ -203,7 +203,7 @@ def stop():
 
 mac = ()
 bcast = ()
-for o in xrange(6):
+for o in range(6):
 mac += (bus.read_1(io, o),)
 bcast += (0xff,)
 logging.info('ethernet address = ' + MACFMT % mac)
@@ -237,23 +237,23 @@ addr_txbufs = addr_rxbufs + bufsize * nrxbufs
 
 ib = 

svn commit: r344957 - head/usr.bin/mkimg/tests

2019-03-08 Thread Marcel Moolenaar
Author: marcel
Date: Sat Mar  9 02:03:07 2019
New Revision: 344957
URL: https://svnweb.freebsd.org/changeset/base/344957

Log:
  Don't compress and uuencode the "hexdump -C" output files.  Just
  save them with the $FreeBSD$ tag prepended.  Changes to these
  files are now a lot easier to comprehend, which makes diffs also
  reviewable.

Added:
  head/usr.bin/mkimg/tests/img-1x1-4096-apm.qcow.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-apm.qcow2.hex   (contents, props 
changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-apm.raw.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-apm.vhd.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-apm.vhdf.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-apm.vmdk.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-bsd.qcow.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-bsd.qcow2.hex   (contents, props 
changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-bsd.raw.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-bsd.vhd.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-bsd.vhdf.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-bsd.vmdk.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-ebr.qcow.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-ebr.qcow2.hex   (contents, props 
changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-ebr.raw.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-ebr.vhd.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-ebr.vhdf.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-ebr.vmdk.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow2.hex   (contents, props 
changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-gpt.raw.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhd.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhdf.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-gpt.vmdk.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-mbr.qcow.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-mbr.qcow2.hex   (contents, props 
changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-mbr.raw.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-mbr.vhd.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-mbr.vhdf.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-mbr.vmdk.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.qcow.hex   (contents, props 
changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.qcow2.hex   (contents, props 
changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.raw.hex   (contents, props 
changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.vhd.hex   (contents, props 
changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.vhdf.hex   (contents, props 
changed)
  head/usr.bin/mkimg/tests/img-1x1-4096-vtoc8.vmdk.hex   (contents, props 
changed)
  head/usr.bin/mkimg/tests/img-1x1-512-apm.qcow.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-apm.qcow2.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-apm.raw.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-apm.vhd.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-apm.vhdf.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-apm.vmdk.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-bsd.qcow.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-bsd.qcow2.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-bsd.raw.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-bsd.vhd.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-bsd.vhdf.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-bsd.vmdk.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-ebr.qcow.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-ebr.qcow2.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-ebr.raw.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-ebr.vhd.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-ebr.vhdf.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-ebr.vmdk.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-gpt.qcow.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-gpt.qcow2.hex   (contents, props changed)
  head/usr.bin/mkimg/tests/img-1x1-512-gpt.raw.hex   (contents, props changed)
  

svn commit: r344826 - in head/usr.bin/mkimg: . tests

2019-03-05 Thread Marcel Moolenaar
Author: marcel
Date: Tue Mar  5 22:55:33 2019
New Revision: 344826
URL: https://svnweb.freebsd.org/changeset/base/344826

Log:
  Round # partitions up to fill the last GPT table sector
  
  Set the number of partitions entries in the GPT header to a
  multiple of the number of entries that fit in a sector.
  
  PR:   236238
  Reviewed by:  imp
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D19465

Modified:
  head/usr.bin/mkimg/gpt.c
  head/usr.bin/mkimg/tests/Makefile
  head/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow.gz.uu
  head/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow2.gz.uu
  head/usr.bin/mkimg/tests/img-1x1-4096-gpt.raw.gz.uu
  head/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhd.gz.uu
  head/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhdf.gz.uu
  head/usr.bin/mkimg/tests/img-1x1-4096-gpt.vmdk.gz.uu
  head/usr.bin/mkimg/tests/img-1x1-512-gpt.qcow.gz.uu
  head/usr.bin/mkimg/tests/img-1x1-512-gpt.qcow2.gz.uu
  head/usr.bin/mkimg/tests/img-1x1-512-gpt.raw.gz.uu
  head/usr.bin/mkimg/tests/img-1x1-512-gpt.vhd.gz.uu
  head/usr.bin/mkimg/tests/img-1x1-512-gpt.vhdf.gz.uu
  head/usr.bin/mkimg/tests/img-1x1-512-gpt.vmdk.gz.uu
  head/usr.bin/mkimg/tests/img-63x255-4096-gpt.qcow.gz.uu
  head/usr.bin/mkimg/tests/img-63x255-4096-gpt.qcow2.gz.uu
  head/usr.bin/mkimg/tests/img-63x255-4096-gpt.raw.gz.uu
  head/usr.bin/mkimg/tests/img-63x255-4096-gpt.vhd.gz.uu
  head/usr.bin/mkimg/tests/img-63x255-4096-gpt.vhdf.gz.uu
  head/usr.bin/mkimg/tests/img-63x255-4096-gpt.vmdk.gz.uu
  head/usr.bin/mkimg/tests/img-63x255-512-gpt.qcow.gz.uu
  head/usr.bin/mkimg/tests/img-63x255-512-gpt.qcow2.gz.uu
  head/usr.bin/mkimg/tests/img-63x255-512-gpt.raw.gz.uu
  head/usr.bin/mkimg/tests/img-63x255-512-gpt.vhd.gz.uu
  head/usr.bin/mkimg/tests/img-63x255-512-gpt.vhdf.gz.uu
  head/usr.bin/mkimg/tests/img-63x255-512-gpt.vmdk.gz.uu

Modified: head/usr.bin/mkimg/gpt.c
==
--- head/usr.bin/mkimg/gpt.cTue Mar  5 22:04:23 2019(r344825)
+++ head/usr.bin/mkimg/gpt.cTue Mar  5 22:55:33 2019(r344826)
@@ -259,9 +259,9 @@ gpt_write(lba_t imgsz, void *bootcode)
le64enc(>hdr_lba_end, imgsz - tblsz - 2);
mkimg_uuid();
mkimg_uuid_enc(>hdr_uuid, );
-   le32enc(>hdr_entries, nparts);
+   le32enc(>hdr_entries, tblsz * secsz / sizeof(struct gpt_ent));
le32enc(>hdr_entsz, sizeof(struct gpt_ent));
-   crc = crc32(tbl, nparts * sizeof(struct gpt_ent));
+   crc = crc32(tbl, tblsz * secsz);
le32enc(>hdr_crc_table, crc);
error = gpt_write_hdr(hdr, 1, imgsz - 1, 2);
if (!error)

Modified: head/usr.bin/mkimg/tests/Makefile
==
--- head/usr.bin/mkimg/tests/Makefile   Tue Mar  5 22:04:23 2019
(r344825)
+++ head/usr.bin/mkimg/tests/Makefile   Tue Mar  5 22:55:33 2019
(r344826)
@@ -18,6 +18,6 @@ $f: $f.gz.uu
 CLEANFILES+=   ${${PACKAGE}FILES}}
 
 rebase: .PHONY
-   (cd ${.CURDIR}; atf-sh ${_REBASE_SCRIPT}.sh rebase)
+   (cd ${.CURDIR}; /usr/libexec/atf-sh ${_REBASE_SCRIPT}.sh rebase)
 
 .include 

Modified: head/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow.gz.uu
==
--- head/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow.gz.uuTue Mar  5 
22:04:23 2019(r344825)
+++ head/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow.gz.uuTue Mar  5 
22:55:33 2019(r344826)
@@ -1,132 +1,132 @@
 # $FreeBSD$
 begin 644 img-1x1-4096-gpt.qcow.gz
-M'XL(",]Q+ED``VEM9RTQ>#$M-#`Y-BUG<'0N<6-O=RYO=70`K9W+CAS7L47G
-M^HKDFVR2S8J(S*Q,OFW`!CR3C7MG]P+.Y]`HS_GQ[NH^C^ZHO1D6V!(A4"!R
-MH^IP]2I*6CH\'.[^:)I.FK9OVK'9Y^;F[],W:>[]S<-OS8^___5OU_?_^/';
-MW9@Y`3Y%N).0NQ$^1;B3D+L)/D6XDY"[
-M&3Y%N).0NP4^1;B3D+L5/D6XTY"[#3Y%N".?%_>XV^%3A#N-N!/\%.%.(^X$
-M^4X9=QIQ)\AWRKC3B#M!OE/<"?*=,NXTXDZ0[Y1Q9Q%W@GQGC#N+N!/D
-M.V/<6<@=\ITQ[BSD#OG.&'<6*GR+]:QET;<:?(=RWCKHNX4^2[CG'71=PI\EW'N.M"[I#O.L9=%W*'?-'
-MW"'?S8R[.>0.^6YFW,TA=\AW,^-N#KE#OIL9=W/('?+=S+B;0^Z0[V;)R
-MAWRW,.Z6D#ODNX5QMT3<]?@IPMT2<=^6QAW2\1=CWRW,.Z6
-MB+L>^6YAW"T1=SWRW<*X6R/N>N2[E7'2O\/G@._D0+B30\@=\)T<"'=RB+@;\%.8
-M.PG[NP'X3EA_)V%_-P#?">OO).SO!N`[8?V=A/W=`'PGK+^3L+\;@.^$]7<2
-M]G<#\)VP_D["_FX`OA/6WTG8WPW`=\+Z.PG[NP'X3EA_)V%_-P#?">OO).SO
-M!N`[8?V=A/W=`'PGK+^3L+\;@.^$]7<2]G<#\AWK[R3L[P;D.];?2=C?C?@I
-MPEW8WXW(=ZR_D["_'O6'\G87\W(M^Q_D["_FY$OF/]G83]W8A\Q_H["?N[
-M$?F.]7<2]G]8?R=A?SOO).SO)OP4X2[L[R;D
-M.];?2=C?3OO).SO)N0[UM])V-]-R'>LOY.POYN0[UA_)V%_-R'?
-ML?Y.POYN0KYC_9V$_=V$?,?Z.PG[NPGYCO5W$O9W,WZ*OO).SO
-M9N0[UM])V-_-R'>LOY.POYN1[UA_)V%_-R/?L?Y.POYN1KYC_9V$_=V,?,?Z
-M.PG[NQGYCO5W$O9W,_(=Z^\D[.]FY#O6WTG8W\W(=ZR_D["_FY'O6'\G87\W
-M(]^Q_D["_FY/]G83]W8Q\Q_H["?N[!3]%N`O[NP7YCO5W$O9W"_(=Z^\D
-M[.\6Y#O6WTG8WRW(=ZR_D["_6Y#O6'\G87^W(-^Q_D["_FY!OF/]G83]W8)\
-MQ_H["?N[!?F.]7<2]G<+\AWK[R3L[Q;D.];?2=C?+]8?R=A?[OO).SO5N0[UM])V-^MR'>LOY.POUN1[UA_

svn commit: r344790 - head/sys/geom/part

2019-03-04 Thread Marcel Moolenaar
Author: marcel
Date: Tue Mar  5 04:15:34 2019
New Revision: 344790
URL: https://svnweb.freebsd.org/changeset/base/344790

Log:
  Revert revision 254095
  
  In revision 254095, gpt_entries is not set to match the on-disk
  hdr_entries, but rather is computed based on available space.
  There are 2 problems with this:
  
  1.  The GPT backend respects hdr_entries and only reads and writes
  that number of partition entries.  On top of that, CRC32 is
  computed over the table that has hdr_entries elements.  When
  the common code works on what is possibly a larger number, the
  behaviour becomes inconsistent and problematic.  In particular,
  it would be possible to add a new partition that on a reboot
  isn't there anymore.
  2.  The calculation of gpt_entries is based on flawed assumptions.
  The GPT specification does not dictate that sectors are layed
  out in a particular way that the available space can be
  determined by looking at LBAs.  In practice, implementations
  do the same thing, because there's no reason to do it any
  other way.  Still, GPT allows certain freedoms that can be
  exploited in some form or shape if the need arises.
  
  PR:   229977
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D19438

Modified:
  head/sys/geom/part/g_part_gpt.c

Modified: head/sys/geom/part/g_part_gpt.c
==
--- head/sys/geom/part/g_part_gpt.c Tue Mar  5 03:27:32 2019
(r344789)
+++ head/sys/geom/part/g_part_gpt.c Tue Mar  5 04:15:34 2019
(r344790)
@@ -990,10 +990,9 @@ g_part_gpt_read(struct g_part_table *basetable, struct
 
basetable->gpt_first = table->hdr->hdr_lba_start;
basetable->gpt_last = table->hdr->hdr_lba_end;
-   basetable->gpt_entries = (table->hdr->hdr_lba_start - 2) *
-   pp->sectorsize / table->hdr->hdr_entsz;
+   basetable->gpt_entries = table->hdr->hdr_entries;
 
-   for (index = table->hdr->hdr_entries - 1; index >= 0; index--) {
+   for (index = basetable->gpt_entries - 1; index >= 0; index--) {
if (EQUUID([index].ent_type, _uuid_unused))
continue;
entry = (struct g_part_gpt_entry *)g_part_new_entry(
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r326045 - head/sys/powerpc/booke

2017-11-20 Thread Marcel Moolenaar


> On Nov 20, 2017, at 7:12 PM, Justin Hibbits <jhibb...@freebsd.org> wrote:
> 
> Author: jhibbits
> Date: Tue Nov 21 03:12:16 2017
> New Revision: 326045
> URL: https://svnweb.freebsd.org/changeset/base/326045
> 
> Log:
>  Check the page table before TLB1 in pmap_kextract()
> 
>  The vast majority of pmap_kextract() calls are looking for a physical memory
>  address, not a device address.  By checking the page table first this saves
>  the formerly inevitable 64 (on e500mc and derivatives) iteration loop
>  through TLB1 in the most common cases.
> 
>  Benchmarking this on the P5020 (e5500 core) yields a 300% throughput
>  improvement on dtsec(4) (115Mbit/s -> 460Mbit/s) measured with iperf.
> 
>  Benchmarked on the P1022 (e500v2 core, 16 TLB1 entries) yields a 50%
>  throughput improvement on tsec(4) (~93Mbit/s -> 165Mbit/s) measured with
>  iperf.

Nice!

-- 
Marcel Moolenaar
mar...@xcllnt.net


___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r324369 - head/sbin/geom/class/part

2017-10-06 Thread Marcel Moolenaar
Author: marcel
Date: Fri Oct  6 16:38:00 2017
New Revision: 324369
URL: https://svnweb.freebsd.org/changeset/base/324369

Log:
  Fix alignment of 'last' in autofill.
  
  'last' is the sector number of the last usable sector. Sector
  numbers start with 0. As such, 'last' is always 1 less than
  the count of sectors and aligning 'last' down as-is means that
  the number of free sectors is pessimized by 'alignment - 1' if
  the number of usable sectors was already a multiple of the
  alignment. Consequently, gpart(8) failed to create a partition
  when the alignment and size were such that it would extend to
  the end of the disk.

Modified:
  head/sbin/geom/class/part/geom_part.c

Modified: head/sbin/geom/class/part/geom_part.c
==
--- head/sbin/geom/class/part/geom_part.c   Fri Oct  6 15:46:11 2017
(r324368)
+++ head/sbin/geom/class/part/geom_part.c   Fri Oct  6 16:38:00 2017
(r324369)
@@ -547,7 +547,7 @@ gpart_autofill(struct gctl_req *req)
last = (off_t)strtoimax(s, NULL, 0);
grade = ~0ULL;
a_first = ALIGNUP(first + offset, alignment);
-   last = ALIGNDOWN(last + offset, alignment);
+   last = ALIGNDOWN(last + offset + 1, alignment) - 1;
if (a_first < start)
a_first = start;
while ((pp = find_provider(gp, first)) != NULL) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r319295 - head/usr.bin/mkimg/tests

2017-06-01 Thread Marcel Moolenaar

> On Jun 1, 2017, at 8:32 AM, Alan Somers <asom...@freebsd.org> wrote:
> 
> On Thu, Jun 1, 2017 at 9:11 AM, Marcel Moolenaar <mar...@xcllnt.net> wrote:
>> 
>> On May 31, 2017, at 11:06 PM, Ngie Cooper (yaneurabeya)
>> <yaneurab...@gmail.com> wrote:
>> 
>> 
>> On May 31, 2017, at 10:03 PM, Brooks Davis <bro...@freebsd.org> wrote:
>> 
>> On Wed, May 31, 2017 at 08:01:12AM +, Ngie Cooper wrote:
>> 
>> Author: ngie
>> Date: Wed May 31 08:01:12 2017
>> New Revision: 319295
>> URL: https://svnweb.freebsd.org/changeset/base/319295
>> 
>> Log:
>> Update the usr.bin/mkimg golden test output files after ^/head@r319125
>> 
>> ^/head@r319125 changed the location of the backup pmbr, requiring the
>> output files to be regenerated, since they're binary disk dumps.
>> 
>> The output files were regenerated with "make rebase"--fixed in
>> ^/head@r319294.
>> 
>> 
>> These should not be stored uuencoded.  It serves no purpose other
>> than bloating the repo and causing spammy commit mails like this one
>> where we got a huge tail of garbage output.
>> 
>> 
>> Hi Brooks,
>> I’m not entirely sure why the files were uuencoded to be honest. I think
>> that’s a good question for Marcel and some of the folks at Juniper, since
>> they wrote the tool/tests.
>> 
>> 
>> Result files used to start off as binary files.  uuencoding is a given in
>> that case.  I eventually switched to using hexdump -C, because that makes it
>> easier to analyze and understand differences.  The uuencoding was kept to
>> remain independent of version control system, file attributes and
>> end-of-line characteristics of the host machine: nothing more annoying that
>> checking out textual result files and have test failures because ‘\n’ was
>> replaced by ‘\r\n’.
>> 
>> Even if the files aren’t unencoded, there’s always someone who treats it as
>> spammy and a tail of garbage. It’s just a knee-jerk reaction to seeing
>> something that isn’t understood, I think. As such, there’s no reason to
>> change — in fact, changing would be bloating the repo.
>> 
>> --
>> Marcel Moolenaar
>> mar...@xcllnt.net
> 
> If the files are binary, then why not store them as binary files?

A 100MB image, committed as binary file is 100MB of data. The hexdump -C
equivalent is often only a few hundred bytes (due to the many zeroes).
The repo bloat argument has grounds for binary files.

-- 
Marcel Moolenaar
mar...@xcllnt.net


___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Re: svn commit: r319295 - head/usr.bin/mkimg/tests

2017-06-01 Thread Marcel Moolenaar

> On May 31, 2017, at 11:06 PM, Ngie Cooper (yaneurabeya) 
> <yaneurab...@gmail.com> wrote:
> 
> 
>> On May 31, 2017, at 10:03 PM, Brooks Davis <bro...@freebsd.org> wrote:
>> 
>> On Wed, May 31, 2017 at 08:01:12AM +, Ngie Cooper wrote:
>>> Author: ngie
>>> Date: Wed May 31 08:01:12 2017
>>> New Revision: 319295
>>> URL: https://svnweb.freebsd.org/changeset/base/319295
>>> 
>>> Log:
>>> Update the usr.bin/mkimg golden test output files after ^/head@r319125
>>> 
>>> ^/head@r319125 changed the location of the backup pmbr, requiring the
>>> output files to be regenerated, since they're binary disk dumps.
>>> 
>>> The output files were regenerated with "make rebase"--fixed in
>>> ^/head@r319294.
>> 
>> These should not be stored uuencoded.  It serves no purpose other
>> than bloating the repo and causing spammy commit mails like this one
>> where we got a huge tail of garbage output.
> 
> Hi Brooks,
>   I’m not entirely sure why the files were uuencoded to be honest. I 
> think that’s a good question for Marcel and some of the folks at Juniper, 
> since they wrote the tool/tests.

Result files used to start off as binary files.  uuencoding is a given in that 
case.  I eventually switched to using hexdump -C, because that makes it easier 
to analyze and understand differences.  The uuencoding was kept to remain 
independent of version control system, file attributes and end-of-line 
characteristics of the host machine: nothing more annoying that checking out 
textual result files and have test failures because ‘\n’ was replaced by ‘\r\n’.

Even if the files aren’t unencoded, there’s always someone who treats it as 
spammy and a tail of garbage. It’s just a knee-jerk reaction to seeing 
something that isn’t understood, I think. As such, there’s no reason to change 
— in fact, changing would be bloating the repo.

-- 
Marcel Moolenaar
mar...@xcllnt.net


___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

svn commit: r309787 - head/sys/netpfil/pf

2016-12-09 Thread Marcel Moolenaar
Author: marcel
Date: Sat Dec 10 03:31:38 2016
New Revision: 309787
URL: https://svnweb.freebsd.org/changeset/base/309787

Log:
  Improve upon r309394
  
  Instead of taking an extra reference to deal with pfsync_q_ins()
  and pfsync_q_del() taken and dropping a reference (resp,) make
  it optional of those functions to take or drop a reference by
  passing an extra argument.
  
  Submitted by: glebius@

Modified:
  head/sys/netpfil/pf/if_pfsync.c

Modified: head/sys/netpfil/pf/if_pfsync.c
==
--- head/sys/netpfil/pf/if_pfsync.c Sat Dec 10 03:13:11 2016
(r309786)
+++ head/sys/netpfil/pf/if_pfsync.c Sat Dec 10 03:31:38 2016
(r309787)
@@ -161,8 +161,8 @@ static struct pfsync_q pfsync_qs[] = {
{ pfsync_out_del,   sizeof(struct pfsync_del_c),   PFSYNC_ACT_DEL_C }
 };
 
-static voidpfsync_q_ins(struct pf_state *, int);
-static voidpfsync_q_del(struct pf_state *);
+static voidpfsync_q_ins(struct pf_state *, int, bool);
+static voidpfsync_q_del(struct pf_state *, bool);
 
 static voidpfsync_update_state(struct pf_state *);
 
@@ -542,7 +542,7 @@ pfsync_state_import(struct pfsync_state 
if (!(flags & PFSYNC_SI_IOCTL)) {
st->state_flags &= ~PFSTATE_NOSYNC;
if (st->state_flags & PFSTATE_ACK) {
-   pfsync_q_ins(st, PFSYNC_S_IACK);
+   pfsync_q_ins(st, PFSYNC_S_IACK, true);
pfsync_push(sc);
}
}
@@ -1668,7 +1668,7 @@ pfsync_insert_state(struct pf_state *st)
if (sc->sc_len == PFSYNC_MINPKT)
callout_reset(>sc_tmo, 1 * hz, pfsync_timeout, V_pfsyncif);
 
-   pfsync_q_ins(st, PFSYNC_S_INS);
+   pfsync_q_ins(st, PFSYNC_S_INS, true);
PFSYNC_UNLOCK(sc);
 
st->sync_updates = 0;
@@ -1789,7 +1789,7 @@ static void
 pfsync_update_state(struct pf_state *st)
 {
struct pfsync_softc *sc = V_pfsyncif;
-   int sync = 0;
+   bool sync = false, ref = true;
 
PF_STATE_LOCK_ASSERT(st);
PFSYNC_LOCK(sc);
@@ -1798,7 +1798,7 @@ pfsync_update_state(struct pf_state *st)
pfsync_undefer_state(st, 0);
if (st->state_flags & PFSTATE_NOSYNC) {
if (st->sync_state != PFSYNC_S_NONE)
-   pfsync_q_del(st);
+   pfsync_q_del(st, true);
PFSYNC_UNLOCK(sc);
return;
}
@@ -1815,14 +1815,17 @@ pfsync_update_state(struct pf_state *st)
if (st->key[PF_SK_WIRE]->proto == IPPROTO_TCP) {
st->sync_updates++;
if (st->sync_updates >= sc->sc_maxupdates)
-   sync = 1;
+   sync = true;
}
break;
 
case PFSYNC_S_IACK:
-   pfsync_q_del(st);
+   pfsync_q_del(st, false);
+   ref = false;
+   /* FALLTHROUGH */
+
case PFSYNC_S_NONE:
-   pfsync_q_ins(st, PFSYNC_S_UPD_C);
+   pfsync_q_ins(st, PFSYNC_S_UPD_C, ref);
st->sync_updates = 0;
break;
 
@@ -1880,13 +1883,14 @@ static void
 pfsync_update_state_req(struct pf_state *st)
 {
struct pfsync_softc *sc = V_pfsyncif;
+   bool ref = true;
 
PF_STATE_LOCK_ASSERT(st);
PFSYNC_LOCK(sc);
 
if (st->state_flags & PFSTATE_NOSYNC) {
if (st->sync_state != PFSYNC_S_NONE)
-   pfsync_q_del(st);
+   pfsync_q_del(st, true);
PFSYNC_UNLOCK(sc);
return;
}
@@ -1894,9 +1898,12 @@ pfsync_update_state_req(struct pf_state 
switch (st->sync_state) {
case PFSYNC_S_UPD_C:
case PFSYNC_S_IACK:
-   pfsync_q_del(st);
+   pfsync_q_del(st, false);
+   ref = false;
+   /* FALLTHROUGH */
+
case PFSYNC_S_NONE:
-   pfsync_q_ins(st, PFSYNC_S_UPD);
+   pfsync_q_ins(st, PFSYNC_S_UPD, ref);
pfsync_push(sc);
break;
 
@@ -1917,13 +1924,14 @@ static void
 pfsync_delete_state(struct pf_state *st)
 {
struct pfsync_softc *sc = V_pfsyncif;
+   bool ref = true;
 
PFSYNC_LOCK(sc);
if (st->state_flags & PFSTATE_ACK)
pfsync_undefer_state(st, 1);
if (st->state_flags & PFSTATE_NOSYNC) {
if (st->sync_state != PFSYNC_S_NONE)
-   pfsync_q_del(st);
+   pfsync_q_del(st, true);
PFSYNC_UNLOCK(sc);
return;
}
@@ -1931,30 +1939,27 @@ pfsync_delete_state(struct pf_state *st)
if (sc->sc_len == PFSYNC_MINPKT)
callout_reset(>sc_tmo, 1 * hz, pfsync_timeout, V_pfsyncif);
 
-   pf_ref_state(st);
-
switch (st->sync_state) {
case PFSYNC_S_INS:

Re: svn commit: r309394 - head/sys/netpfil/pf

2016-12-09 Thread Marcel Moolenaar

> On Dec 8, 2016, at 2:48 PM, Gleb Smirnoff <gleb...@freebsd.org 
> <mailto:gleb...@freebsd.org>> wrote:
> 
>  Marcel,
> 
> On Wed, Dec 07, 2016 at 05:06:08PM -0800, Marcel Moolenaar wrote:
> M> >  thanks for the fixes. While the problem with the first chunk
> M> > in pfsync_sendout() is obvious, the problem you are fixing in th
> M> > second chunk in the pfsync_delete_state() is not clear to me.
> M> > Can you please explain what scenario are you fixing there?
> M> 
> M> State updates may be pending for state being deleted. This
> M> means that the state is still sitting on either the PFSYNC_S_UPD
> M> or PFSYNC_S_UPD_C queues. What pfsync(4) does in that case is
> M> simply remove the state from those queues and add it to the
> M> PFSYNC_S_DEL queue.
> M> 
> M> But, pf(4) has already dropped the reference count for state
> M> that’s deleted and the only reference is by pfsync(4) by virtue
> M> of being on the PFSYNC_S_UPD or PFSYNC_S_UPD_C queues. When the
> M> state gets dequeued from those queues, the reference count drops
> M> to 0 and the state is deleted (read: memory freed). But the same
> M> state is subsequently added to the PFSYNC_S_DEL queue — i.e.
> M> after the memory was freed.
> 
> Thanks for explanation, Marcel! Potentially this problem also exists
> in pfsync_update_state() and in pfsync_update_state_req().
> 
> Your patch introduces extra unnecessary atomic operations, so let
> me suggest another patch. It should be applied on top of yours, and
> it also addresses pfsync_update_state() and in pfsync_update_state_req().
> 
> It isn't tested, but is pretty straightforward. 

I’ll give it a spin and commit.

-- 
Marcel Moolenaar
mar...@xcllnt.net <mailto:mar...@xcllnt.net>


___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Re: svn commit: r309394 - head/sys/netpfil/pf

2016-12-07 Thread Marcel Moolenaar

> On Dec 7, 2016, at 1:08 PM, Gleb Smirnoff <gleb...@freebsd.org 
> <mailto:gleb...@freebsd.org>> wrote:
> 
>  Marcel,
> 
>  thanks for the fixes. While the problem with the first chunk
> in pfsync_sendout() is obvious, the problem you are fixing in th
> second chunk in the pfsync_delete_state() is not clear to me.
> Can you please explain what scenario are you fixing there?

State updates may be pending for state being deleted. This
means that the state is still sitting on either the PFSYNC_S_UPD
or PFSYNC_S_UPD_C queues. What pfsync(4) does in that case is
simply remove the state from those queues and add it to the
PFSYNC_S_DEL queue.

But, pf(4) has already dropped the reference count for state
that’s deleted and the only reference is by pfsync(4) by virtue
of being on the PFSYNC_S_UPD or PFSYNC_S_UPD_C queues. When the
state gets dequeued from those queues, the reference count drops
to 0 and the state is deleted (read: memory freed). But the same
state is subsequently added to the PFSYNC_S_DEL queue — i.e.
after the memory was freed.

HTH,

-- 
Marcel Moolenaar
mar...@xcllnt.net <mailto:mar...@xcllnt.net>

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Re: svn commit: r309394 - head/sys/netpfil/pf

2016-12-07 Thread Marcel Moolenaar

> On Dec 7, 2016, at 1:08 PM, Gleb Smirnoff <gleb...@freebsd.org 
> <mailto:gleb...@freebsd.org>> wrote:
> 
>  Marcel,
> 
>  thanks for the fixes. While the problem with the first chunk
> in pfsync_sendout() is obvious, the problem you are fixing in th
> second chunk in the pfsync_delete_state() is not clear to me.
> Can you please explain what scenario are you fixing there?

State updates may be pending for state being deleted. This
means that the state is still sitting on either the PFSYNC_S_UPD
or PFSYNC_S_UPD_C queues. What pfsync(4) does in that case is
simply remove the state from those queues and add it to the
PFSYNC_S_DEL queue.

But, pf(4) has already dropped the reference count for state
that’s deleted and the only reference is by pfsync(4) by virtue
of being on the PFSYNC_S_UPD or PFSYNC_S_UPD_C queues. When the
state gets dequeued from those queues, the reference count drops
to 0 and the state is deleted (read: memory freed). But the same
state is subsequently added to the PFSYNC_S_DEL queue — i.e.
after the memory was freed.

HTH,

-- 
Marcel Moolenaar
mar...@xcllnt.net <mailto:mar...@xcllnt.net>

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

svn commit: r309394 - head/sys/netpfil/pf

2016-12-01 Thread Marcel Moolenaar
Author: marcel
Date: Fri Dec  2 06:15:59 2016
New Revision: 309394
URL: https://svnweb.freebsd.org/changeset/base/309394

Log:
  Fix use-after-free bugs in pfsync(4)
  
  Use after free happens for state that is deleted. The reference
  count is what prevents the state from being freed. When the
  state is dequeued, the reference count is dropped and the memory
  freed. We can't dereference the next pointer or re-queue the
  state.
  
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D8671

Modified:
  head/sys/netpfil/pf/if_pfsync.c

Modified: head/sys/netpfil/pf/if_pfsync.c
==
--- head/sys/netpfil/pf/if_pfsync.c Fri Dec  2 06:07:27 2016
(r309393)
+++ head/sys/netpfil/pf/if_pfsync.c Fri Dec  2 06:15:59 2016
(r309394)
@@ -1509,7 +1509,7 @@ pfsync_sendout(int schedswi)
struct ip *ip;
struct pfsync_header *ph;
struct pfsync_subheader *subh;
-   struct pf_state *st;
+   struct pf_state *st, *st_next;
struct pfsync_upd_req_item *ur;
int offset;
int q, count = 0;
@@ -1559,7 +1559,7 @@ pfsync_sendout(int schedswi)
offset += sizeof(*subh);
 
count = 0;
-   TAILQ_FOREACH(st, >sc_qs[q], sync_list) {
+   TAILQ_FOREACH_SAFE(st, >sc_qs[q], sync_list, st_next) {
KASSERT(st->sync_state == q,
("%s: st->sync_state == q",
__func__));
@@ -1931,6 +1931,8 @@ pfsync_delete_state(struct pf_state *st)
if (sc->sc_len == PFSYNC_MINPKT)
callout_reset(>sc_tmo, 1 * hz, pfsync_timeout, V_pfsyncif);
 
+   pf_ref_state(st);
+
switch (st->sync_state) {
case PFSYNC_S_INS:
/* We never got to tell the world so just forget about it. */
@@ -1950,6 +1952,9 @@ pfsync_delete_state(struct pf_state *st)
default:
panic("%s: unexpected sync state %d", __func__, st->sync_state);
}
+
+   pf_release_state(st);
+
PFSYNC_UNLOCK(sc);
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r308344 - head/usr.sbin/makefs

2016-11-05 Thread Marcel Moolenaar
Author: marcel
Date: Sat Nov  5 16:23:33 2016
New Revision: 308344
URL: https://svnweb.freebsd.org/changeset/base/308344

Log:
  Assign a random number to di_gen (for FFS), instead of extracting it
  from struct stat.  We don't necessarily have permissions to see the
  generation number and the host OS may not have st_gen in struct stat
  anyway.  Since the kernel assigns random numbers, there's nothing
  meaningful about the generation that requires us to preserve it when
  the file system image is created.  With this change, all generation
  numbers come from random() and that makes it easier to add support
  for reproducible builds at some time in the future (i.e. by adding
  an argument to makefs that changes the behaviour of random() so that
  it always returns 0 or some predictable sequence).
  
  Differential Revision:https://reviews.freebsd.org/D8418

Modified:
  head/usr.sbin/makefs/Makefile
  head/usr.sbin/makefs/ffs.c

Modified: head/usr.sbin/makefs/Makefile
==
--- head/usr.sbin/makefs/Makefile   Sat Nov  5 16:17:07 2016
(r308343)
+++ head/usr.sbin/makefs/Makefile   Sat Nov  5 16:23:33 2016
(r308344)
@@ -20,7 +20,6 @@ WARNS?=   2
 .include "${SRCDIR}/ffs/Makefile.inc"
 
 CFLAGS+=-DHAVE_STRUCT_STAT_ST_FLAGS=1
-CFLAGS+=-DHAVE_STRUCT_STAT_ST_GEN=1
 
 .PATH: ${SRCTOP}/contrib/mtree
 CFLAGS+=-I${SRCTOP}/contrib/mtree

Modified: head/usr.sbin/makefs/ffs.c
==
--- head/usr.sbin/makefs/ffs.c  Sat Nov  5 16:17:07 2016(r308343)
+++ head/usr.sbin/makefs/ffs.c  Sat Nov  5 16:23:33 2016(r308344)
@@ -666,9 +666,7 @@ ffs_build_dinode1(struct ufs1_dinode *di
 #if HAVE_STRUCT_STAT_ST_FLAGS
dinp->di_flags = cur->inode->st.st_flags;
 #endif
-#if HAVE_STRUCT_STAT_ST_GEN
-   dinp->di_gen = cur->inode->st.st_gen;
-#endif
+   dinp->di_gen = random();
dinp->di_uid = cur->inode->st.st_uid;
dinp->di_gid = cur->inode->st.st_gid;
 
@@ -716,9 +714,7 @@ ffs_build_dinode2(struct ufs2_dinode *di
 #if HAVE_STRUCT_STAT_ST_FLAGS
dinp->di_flags = cur->inode->st.st_flags;
 #endif
-#if HAVE_STRUCT_STAT_ST_GEN
-   dinp->di_gen = cur->inode->st.st_gen;
-#endif
+   dinp->di_gen = random();
dinp->di_uid = cur->inode->st.st_uid;
dinp->di_gid = cur->inode->st.st_gid;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r307967 - head/usr.sbin/config

2016-10-26 Thread Marcel Moolenaar
Author: marcel
Date: Wed Oct 26 15:58:41 2016
New Revision: 307967
URL: https://svnweb.freebsd.org/changeset/base/307967

Log:
  Allow config to be compiled from another source directory, such as one
  for building tools. This boils down to replacing ${.CURDIR} with
  ${SRCDIR}, where the latter is the directory in which this makefile
  lives.
  
  Also allow overriding where file2c comes from using ${FILE2C}.

Modified:
  head/usr.sbin/config/Makefile

Modified: head/usr.sbin/config/Makefile
==
--- head/usr.sbin/config/Makefile   Wed Oct 26 15:19:18 2016
(r307966)
+++ head/usr.sbin/config/Makefile   Wed Oct 26 15:58:41 2016
(r307967)
@@ -1,15 +1,20 @@
 #  @(#)Makefile8.1 (Berkeley) 6/6/93
 # $FreeBSD$
 
+SRCDIR:=${.PARSEDIR:tA}
+
 PROG=  config
 MAN=   config.5 config.8
 SRCS=  config.y main.c lang.l mkmakefile.c mkheaders.c \
mkoptions.c y.tab.h kernconf.c
 
+FILE2C?=file2c
+
 kernconf.c: kernconf.tmpl
-   file2c 'char kernconfstr[] = {' ',0};' < ${.CURDIR}/kernconf.tmpl > 
kernconf.c
+   ${FILE2C} 'char kernconfstr[] = {' ',0};' < \
+   ${SRCDIR}/kernconf.tmpl > kernconf.c
 
-CFLAGS+= -I. -I${.CURDIR}
+CFLAGS+= -I. -I${SRCDIR}
 
 NO_WMISSING_VARIABLE_DECLARATIONS=
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r307927 - in head/usr.sbin/makefs: . cd9660 ffs

2016-10-25 Thread Marcel Moolenaar
Author: marcel
Date: Tue Oct 25 16:29:15 2016
New Revision: 307927
URL: https://svnweb.freebsd.org/changeset/base/307927

Log:
  Be more precise when including headers so that we're less likely to
  depend on namespace pollution and as such become more portable. This
  means including headers like  or , but also
  making sure we include system/host headers before local headers.
  
  While here: define ENOATTR as ENOMSG in mtree.c. There is no ENOATTR
  on Linux.
  
  With this, makefs is ready for compilation on macOS and Linux.

Modified:
  head/usr.sbin/makefs/cd9660.c
  head/usr.sbin/makefs/cd9660/cd9660_archimedes.c
  head/usr.sbin/makefs/cd9660/iso9660_rrip.c
  head/usr.sbin/makefs/ffs/ffs_bswap.c
  head/usr.sbin/makefs/ffs/ffs_subr.c
  head/usr.sbin/makefs/mtree.c
  head/usr.sbin/makefs/walk.c

Modified: head/usr.sbin/makefs/cd9660.c
==
--- head/usr.sbin/makefs/cd9660.c   Tue Oct 25 16:28:30 2016
(r307926)
+++ head/usr.sbin/makefs/cd9660.c   Tue Oct 25 16:29:15 2016
(r307927)
@@ -98,10 +98,11 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
-#include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include "makefs.h"
 #include "cd9660.h"

Modified: head/usr.sbin/makefs/cd9660/cd9660_archimedes.c
==
--- head/usr.sbin/makefs/cd9660/cd9660_archimedes.c Tue Oct 25 16:28:30 
2016(r307926)
+++ head/usr.sbin/makefs/cd9660/cd9660_archimedes.c Tue Oct 25 16:29:15 
2016(r307927)
@@ -40,9 +40,11 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "makefs.h"

Modified: head/usr.sbin/makefs/cd9660/iso9660_rrip.c
==
--- head/usr.sbin/makefs/cd9660/iso9660_rrip.c  Tue Oct 25 16:28:30 2016
(r307926)
+++ head/usr.sbin/makefs/cd9660/iso9660_rrip.c  Tue Oct 25 16:29:15 2016
(r307927)
@@ -35,14 +35,16 @@
  * defined in iso9660_rrip.h
  */
 
-#include "makefs.h"
-#include "cd9660.h"
-#include "iso9660_rrip.h"
+#include 
+__FBSDID("$FreeBSD$");
+
 #include 
+#include 
 #include 
 
-#include 
-__FBSDID("$FreeBSD$");
+#include "makefs.h"
+#include "cd9660.h"
+#include "iso9660_rrip.h"
 
 static void cd9660_rrip_initialize_inode(cd9660node *);
 static int cd9660_susp_handle_continuation(cd9660node *);

Modified: head/usr.sbin/makefs/ffs/ffs_bswap.c
==
--- head/usr.sbin/makefs/ffs/ffs_bswap.cTue Oct 25 16:28:30 2016
(r307926)
+++ head/usr.sbin/makefs/ffs/ffs_bswap.cTue Oct 25 16:29:15 2016
(r307927)
@@ -38,18 +38,19 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 
-#include 
-#include "ffs/ufs_bswap.h"
-#include 
-
 #if !defined(_KERNEL)
 #include 
+#include 
 #include 
 #include 
 #include 
 #define panic(x)   printf("%s\n", (x)), abort()
 #endif
 
+#include 
+#include "ffs/ufs_bswap.h"
+#include 
+
 #definefs_old_postblofffs_spare5[0]
 #definefs_old_rotbloff fs_spare5[1]
 #definefs_old_postbl_start fs_maxbsize

Modified: head/usr.sbin/makefs/ffs/ffs_subr.c
==
--- head/usr.sbin/makefs/ffs/ffs_subr.c Tue Oct 25 16:28:30 2016
(r307926)
+++ head/usr.sbin/makefs/ffs/ffs_subr.c Tue Oct 25 16:29:15 2016
(r307927)
@@ -35,6 +35,7 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 
 #include 
 #include 

Modified: head/usr.sbin/makefs/mtree.c
==
--- head/usr.sbin/makefs/mtree.cTue Oct 25 16:28:30 2016
(r307926)
+++ head/usr.sbin/makefs/mtree.cTue Oct 25 16:29:15 2016
(r307927)
@@ -44,10 +44,15 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "makefs.h"
 
+#ifndef ENOATTR
+#defineENOATTR ENOMSG
+#endif
+
 #defineIS_DOT(nm)  ((nm)[0] == '.' && (nm)[1] == '\0')
 #defineIS_DOTDOT(nm)   ((nm)[0] == '.' && (nm)[1] == '.' && (nm)[2] == 
'\0')
 

Modified: head/usr.sbin/makefs/walk.c
==
--- head/usr.sbin/makefs/walk.c Tue Oct 25 16:28:30 2016(r307926)
+++ head/usr.sbin/makefs/walk.c Tue Oct 25 16:29:15 2016(r307927)
@@ -40,6 +40,7 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 
 #include 
 #include 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r307923 - in head/usr.sbin/makefs: . cd9660 ffs

2016-10-25 Thread Marcel Moolenaar
Author: marcel
Date: Tue Oct 25 16:21:38 2016
New Revision: 307923
URL: https://svnweb.freebsd.org/changeset/base/307923

Log:
  Allow building makefs(8) from another Makefile (such as one in
  a seperate directory hierarchy used to build tools). This boils
  down to replacing the use of ${.CURDIR} with either ${SRCDIR}
  or ${SRCTOP}. SRCDIR is defined as the directory in which the
  Makefile lives that bmake(1) is currently reading. Use SRCTOP
  when reaching outside of makefs's directory.

Modified:
  head/usr.sbin/makefs/Makefile
  head/usr.sbin/makefs/cd9660/Makefile.inc
  head/usr.sbin/makefs/ffs/Makefile.inc

Modified: head/usr.sbin/makefs/Makefile
==
--- head/usr.sbin/makefs/Makefile   Tue Oct 25 16:14:11 2016
(r307922)
+++ head/usr.sbin/makefs/Makefile   Tue Oct 25 16:21:38 2016
(r307923)
@@ -1,10 +1,12 @@
 #  $FreeBSD$
 
+SRCDIR:=${.PARSEDIR:tA}
+
 .include 
 
 PROG=  makefs
 
-CFLAGS+=-I${.CURDIR}
+CFLAGS+=-I${SRCDIR}
 
 SRCS=  cd9660.c ffs.c \
makefs.c \
@@ -14,24 +16,24 @@ MAN=makefs.8
 
 WARNS?=2
 
-.include "${.CURDIR}/cd9660/Makefile.inc"
-.include "${.CURDIR}/ffs/Makefile.inc"
+.include "${SRCDIR}/cd9660/Makefile.inc"
+.include "${SRCDIR}/ffs/Makefile.inc"
 
 CFLAGS+=-DHAVE_STRUCT_STAT_ST_FLAGS=1
 CFLAGS+=-DHAVE_STRUCT_STAT_ST_GEN=1
 
-.PATH: ${.CURDIR}/../../contrib/mtree
-CFLAGS+=-I${.CURDIR}/../../contrib/mtree
+.PATH: ${SRCTOP}/contrib/mtree
+CFLAGS+=-I${SRCTOP}/contrib/mtree
 SRCS+= getid.c misc.c spec.c
 
-.PATH: ${.CURDIR}/../../contrib/mknod
-CFLAGS+=-I${.CURDIR}/../../contrib/mknod
+.PATH: ${SRCTOP}/contrib/mknod
+CFLAGS+=-I${SRCTOP}/contrib/mknod
 SRCS+= pack_dev.c
 
-.PATH: ${.CURDIR}/../../sys/ufs/ffs
+.PATH: ${SRCTOP}/sys/ufs/ffs
 SRCS+= ffs_tables.c
 
-CFLAGS+=   -I${.CURDIR}/../../lib/libnetbsd
+CFLAGS+=   -I${SRCTOP}/lib/libnetbsd
 LIBADD=netbsd util sbuf
 
 .if ${MK_TESTS} != "no"

Modified: head/usr.sbin/makefs/cd9660/Makefile.inc
==
--- head/usr.sbin/makefs/cd9660/Makefile.incTue Oct 25 16:14:11 2016
(r307922)
+++ head/usr.sbin/makefs/cd9660/Makefile.incTue Oct 25 16:21:38 2016
(r307923)
@@ -1,9 +1,9 @@
 #  $FreeBSD$
 #
 
-.PATH: ${.CURDIR}/cd9660 ${.CURDIR}/../../sys/fs/cd9660/
+.PATH: ${SRCDIR}/cd9660 ${SRCTOP}/sys/fs/cd9660/
 
-CFLAGS+=-I${.CURDIR}/../../sys/fs/cd9660/
+CFLAGS+=-I${SRCTOP}/sys/fs/cd9660/
 
 SRCS+= cd9660_strings.c cd9660_debug.c cd9660_eltorito.c \
cd9660_write.c cd9660_conversion.c iso9660_rrip.c cd9660_archimedes.c

Modified: head/usr.sbin/makefs/ffs/Makefile.inc
==
--- head/usr.sbin/makefs/ffs/Makefile.inc   Tue Oct 25 16:14:11 2016
(r307922)
+++ head/usr.sbin/makefs/ffs/Makefile.inc   Tue Oct 25 16:21:38 2016
(r307923)
@@ -1,9 +1,9 @@
 #  $FreeBSD$
 #
 
-.PATH: ${.CURDIR}/ffs ${.CURDIR}/../../sys/ufs/ffs
+.PATH: ${SRCDIR}/ffs ${SRCTOP}/sys/ufs/ffs
 
-CFLAGS+=   -I${.CURDIR}/../../sys/ufs/ffs
+CFLAGS+=   -I${SRCTOP}/sys/ufs/ffs
 
 SRCS+= ffs_alloc.c ffs_balloc.c ffs_bswap.c ffs_subr.c ufs_bmap.c
 SRCS+= buf.c mkfs.c
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r307874 - head/sys/ufs/ffs

2016-10-24 Thread Marcel Moolenaar
Author: marcel
Date: Mon Oct 24 18:12:57 2016
New Revision: 307874
URL: https://svnweb.freebsd.org/changeset/base/307874

Log:
  Include  explicitly instead of depending on that
  header being included by . When compiled as part
  of makefs(8) and on macOS or Linux,  is not our
  own.

Modified:
  head/sys/ufs/ffs/ffs_tables.c

Modified: head/sys/ufs/ffs/ffs_tables.c
==
--- head/sys/ufs/ffs/ffs_tables.c   Mon Oct 24 18:03:04 2016
(r307873)
+++ head/sys/ufs/ffs/ffs_tables.c   Mon Oct 24 18:12:57 2016
(r307874)
@@ -33,6 +33,7 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 #include 
 #include 
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r307873 - head/sys/kern

2016-10-24 Thread Marcel Moolenaar
Author: marcel
Date: Mon Oct 24 18:03:04 2016
New Revision: 307873
URL: https://svnweb.freebsd.org/changeset/base/307873

Log:
  Include  instead of  when compiled as
  part of libsbuf. The former is the standard header, and allows us
  to compile libsbuf on macOS/linux.

Modified:
  head/sys/kern/subr_prf.c

Modified: head/sys/kern/subr_prf.c
==
--- head/sys/kern/subr_prf.cMon Oct 24 17:59:25 2016(r307872)
+++ head/sys/kern/subr_prf.cMon Oct 24 18:03:04 2016(r307873)
@@ -72,7 +72,11 @@ __FBSDID("$FreeBSD$");
  * Note that stdarg.h and the ANSI style va_start macro is used for both
  * ANSI and traditional C compilers.
  */
+#ifdef _KERNEL
 #include 
+#else
+#include 
+#endif
 
 #ifdef _KERNEL
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r307872 - head/share/mk

2016-10-24 Thread Marcel Moolenaar
Author: marcel
Date: Mon Oct 24 17:59:25 2016
New Revision: 307872
URL: https://svnweb.freebsd.org/changeset/base/307872

Log:
  Detect clang on macOS. The version string is slightly different.

Modified:
  head/share/mk/bsd.compiler.mk

Modified: head/share/mk/bsd.compiler.mk
==
--- head/share/mk/bsd.compiler.mk   Mon Oct 24 17:57:46 2016
(r307871)
+++ head/share/mk/bsd.compiler.mk   Mon Oct 24 17:59:25 2016
(r307872)
@@ -147,7 +147,7 @@ ${X_}COMPILER_TYPE:=clang
 ${X_}COMPILER_TYPE:=   gcc
 . elif ${_v:M\(GCC\)}
 ${X_}COMPILER_TYPE:=   gcc
-. elif ${_v:Mclang}
+. elif ${_v:Mclang} || ${_v:M(clang-*.*.*)}
 ${X_}COMPILER_TYPE:=   clang
 . else
 .error Unable to determine compiler type for ${cc}=${${cc}}.  Consider setting 
${X_}COMPILER_TYPE.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r307871 - head/lib/libnetbsd

2016-10-24 Thread Marcel Moolenaar
Author: marcel
Date: Mon Oct 24 17:57:46 2016
New Revision: 307871
URL: https://svnweb.freebsd.org/changeset/base/307871

Log:
  Include "util.h", not . The header is in the same directory
  as the C file. There may be a  on the host when compiling
  on macOS or Linux, causing conflicts.

Modified:
  head/lib/libnetbsd/util.c

Modified: head/lib/libnetbsd/util.c
==
--- head/lib/libnetbsd/util.c   Mon Oct 24 17:56:08 2016(r307870)
+++ head/lib/libnetbsd/util.c   Mon Oct 24 17:57:46 2016(r307871)
@@ -36,7 +36,8 @@
 #include 
 #include 
 #include 
-#include 
+
+#include "util.h"
 
 char *
 flags_to_string(u_long flags, const char *def)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r307870 - head/lib/libnetbsd/sys

2016-10-24 Thread Marcel Moolenaar
Author: marcel
Date: Mon Oct 24 17:56:08 2016
New Revision: 307870
URL: https://svnweb.freebsd.org/changeset/base/307870

Log:
  When compiling on macOS or Linux, __dead can be defined already.
  Conditionally define __dead.

Modified:
  head/lib/libnetbsd/sys/cdefs.h

Modified: head/lib/libnetbsd/sys/cdefs.h
==
--- head/lib/libnetbsd/sys/cdefs.h  Mon Oct 24 17:37:21 2016
(r307869)
+++ head/lib/libnetbsd/sys/cdefs.h  Mon Oct 24 17:56:08 2016
(r307870)
@@ -35,11 +35,13 @@
 
 #include_next 
 
+#ifndef __dead
 #ifdef __dead2
 #define __dead __dead2
 #else
 #define __dead
 #endif
+#endif /* !__dead */
 
 /*
  * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r307544 - head/usr.bin/mkimg

2016-10-17 Thread Marcel Moolenaar
On October 17, 2016 at 8:34:11 PM, Ngie Cooper (yaneurab...@gmail.com) wrote:

> On Oct 17, 2016, at 18:55, Marcel Moolenaar <mar...@freebsd.org> wrote: 
>
*snip*

> +CFLAGS+=-I${SRCTOP}/sys/sys/disk 

Isn't it a better app idea to maintain the disk/ namespace for includes? 
Thanks! 
You mean, add -I${SRCTOP}//sys/sys on the compile line and change the code to 
use #include ?

Unfortunately, that creates conflicts with header files that are included as 
 and match headers we have under sys/sys.




signature.asc
Description: Message signed with OpenPGP using AMPGpg


svn commit: r307544 - head/usr.bin/mkimg

2016-10-17 Thread Marcel Moolenaar
void *buf, size_t sz)
return (crc ^ ~0U);
 }
 
-static void
-gpt_uuid_enc(void *buf, const uuid_t *uuid)
-{
-   uint8_t *p = buf;
-   int i;
-
-   le32enc(p, uuid->time_low);
-   le16enc(p + 4, uuid->time_mid);
-   le16enc(p + 6, uuid->time_hi_and_version);
-   p[8] = uuid->clock_seq_hi_and_reserved;
-   p[9] = uuid->clock_seq_low;
-   for (i = 0; i < _UUID_NODE_LEN; i++)
-   p[10 + i] = uuid->node[i];
-}
-
 static u_int
 gpt_tblsz(void)
 {
@@ -194,7 +178,7 @@ gpt_write_pmbr(lba_t blks, void *bootcod
 static struct gpt_ent *
 gpt_mktbl(u_int tblsz)
 {
-   uuid_t uuid;
+   mkimg_uuid_t uuid;
struct gpt_ent *tbl, *ent;
struct part *part;
int c, idx;
@@ -205,9 +189,9 @@ gpt_mktbl(u_int tblsz)
 
TAILQ_FOREACH(part, , link) {
ent = tbl + part->index;
-   gpt_uuid_enc(>ent_type, ALIAS_TYPE2PTR(part->type));
+   mkimg_uuid_enc(>ent_type, ALIAS_TYPE2PTR(part->type));
mkimg_uuid();
-   gpt_uuid_enc(>ent_uuid, );
+   mkimg_uuid_enc(>ent_uuid, );
le64enc(>ent_lba_start, part->block);
le64enc(>ent_lba_end, part->block + part->size - 1);
if (part->label != NULL) {
@@ -238,7 +222,7 @@ gpt_write_hdr(struct gpt_hdr *hdr, uint6
 static int
 gpt_write(lba_t imgsz, void *bootcode)
 {
-   uuid_t uuid;
+   mkimg_uuid_t uuid;
struct gpt_ent *tbl;
struct gpt_hdr *hdr;
uint32_t crc;
@@ -275,7 +259,7 @@ gpt_write(lba_t imgsz, void *bootcode)
le64enc(>hdr_lba_start, 2 + tblsz);
le64enc(>hdr_lba_end, imgsz - tblsz - 2);
mkimg_uuid();
-   gpt_uuid_enc(>hdr_uuid, );
+   mkimg_uuid_enc(>hdr_uuid, );
le32enc(>hdr_entries, nparts);
le32enc(>hdr_entsz, sizeof(struct gpt_ent));
crc = crc32(tbl, nparts * sizeof(struct gpt_ent));

Modified: head/usr.bin/mkimg/mbr.c
==
--- head/usr.bin/mkimg/mbr.cTue Oct 18 01:42:42 2016(r307543)
+++ head/usr.bin/mkimg/mbr.cTue Oct 18 01:55:07 2016(r307544)
@@ -33,7 +33,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
+#include 
 
 #include "endian.h"
 #include "image.h"

Modified: head/usr.bin/mkimg/mkimg.c
==
--- head/usr.bin/mkimg/mkimg.c  Tue Oct 18 01:42:42 2016(r307543)
+++ head/usr.bin/mkimg/mkimg.c  Tue Oct 18 01:55:07 2016(r307544)
@@ -28,7 +28,6 @@
 __FBSDID("$FreeBSD$");
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -374,22 +373,6 @@ mkimg_chs(lba_t lba, u_int maxcyl, u_int
*secp = sec;
 }
 
-void
-mkimg_uuid(struct uuid *uuid)
-{
-   static uint8_t gen[sizeof(struct uuid)];
-   u_int i;
-
-   if (!unit_testing) {
-   uuidgen(uuid, 1);
-   return;
-   }
-
-   for (i = 0; i < sizeof(gen); i++)
-   gen[i]++;
-   memcpy(uuid, gen, sizeof(uuid_t));
-}
-
 static int
 capacity_resize(lba_t end)
 {

Modified: head/usr.bin/mkimg/mkimg.h
==
--- head/usr.bin/mkimg/mkimg.h  Tue Oct 18 01:42:42 2016(r307543)
+++ head/usr.bin/mkimg/mkimg.h  Tue Oct 18 01:55:07 2016(r307544)
@@ -30,6 +30,7 @@
 #define_MKIMG_MKIMG_H_
 
 #include 
+#include 
 
 struct part {
TAILQ_ENTRY(part) link;
@@ -89,7 +90,17 @@ ssize_t sparse_write(int, const void *, 
 
 void mkimg_chs(lba_t, u_int, u_int *, u_int *, u_int *);
 
-struct uuid;
-void mkimg_uuid(struct uuid *);
+struct mkimg_uuid {
+   uint32_ttime_low;
+   uint16_ttime_mid;
+   uint16_ttime_hi_and_version;
+   uint8_t clock_seq_hi_and_reserved;
+   uint8_t clock_seq_low;
+   uint8_t node[6];
+};
+typedef struct mkimg_uuid mkimg_uuid_t;
+
+void mkimg_uuid(mkimg_uuid_t *);
+void mkimg_uuid_enc(void *, const mkimg_uuid_t *);
 
 #endif /* _MKIMG_MKIMG_H_ */

Modified: head/usr.bin/mkimg/pc98.c
==
--- head/usr.bin/mkimg/pc98.c   Tue Oct 18 01:42:42 2016(r307543)
+++ head/usr.bin/mkimg/pc98.c   Tue Oct 18 01:55:07 2016(r307544)
@@ -33,7 +33,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
+#include 
 
 #include "endian.h"
 #include "image.h"

Added: head/usr.bin/mkimg/uuid.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.bin/mkimg/uuid.c   Tue Oct 18 01:55:07 2016(r307544)
@@ -0,0 +1,125 @@
+/*-
+ * Copyright (c) 2016 Marcel Moolenaar
+ * All rights rese

svn commit: r307543 - head/share/mk

2016-10-17 Thread Marcel Moolenaar
Author: marcel
Date: Tue Oct 18 01:42:42 2016
New Revision: 307543
URL: https://svnweb.freebsd.org/changeset/base/307543

Log:
  Add LORDER, TSORT and TSORTFLAGS variables and replace the
  hardcoded utility names and tsort flags.

Modified:
  head/share/mk/bsd.lib.mk
  head/share/mk/sys.mk

Modified: head/share/mk/bsd.lib.mk
==
--- head/share/mk/bsd.lib.mkTue Oct 18 00:55:15 2016(r307542)
+++ head/share/mk/bsd.lib.mkTue Oct 18 01:42:42 2016(r307543)
@@ -178,7 +178,8 @@ _LIBS=  lib${LIB_PRIVATE}${LIB}.a
 lib${LIB_PRIVATE}${LIB}.a: ${OBJS} ${STATICOBJS}
@${ECHO} building static ${LIB} library
@rm -f ${.TARGET}
-   ${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' NMFLAGS='${NMFLAGS}' lorder 
${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
+   ${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' NMFLAGS='${NMFLAGS}' \
+   ${LORDER} ${OBJS} ${STATICOBJS} | ${TSORT} ${TSORTFLAGS}` ${ARADD}
${RANLIB} ${RANLIBFLAGS} ${.TARGET}
 .endif
 
@@ -193,7 +194,8 @@ CLEANFILES+=${POBJS}
 lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS}
@${ECHO} building profiled ${LIB} library
@rm -f ${.TARGET}
-   ${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' NMFLAGS='${NMFLAGS}' lorder 
${POBJS} | tsort -q` ${ARADD}
+   ${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' NMFLAGS='${NMFLAGS}' \
+   ${LORDER} ${POBJS} | ${TSORT} ${TSORTFLAGS}` ${ARADD}
${RANLIB} ${RANLIBFLAGS} ${.TARGET}
 .endif
 
@@ -241,7 +243,8 @@ ${SHLIB_NAME_FULL}: ${SOBJS}
 .endif
${_LD:N${CCACHE_BIN}} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
-o ${.TARGET} -Wl,-soname,${SONAME} \
-   `NM='${NM}' NMFLAGS='${NMFLAGS}' lorder ${SOBJS} | tsort -q` 
${LDADD}
+   `NM='${NM}' NMFLAGS='${NMFLAGS}' ${LORDER} ${SOBJS} | \
+   ${TSORT} ${TSORTFLAGS}` ${LDADD}
 .if ${MK_CTF} != "no"
${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
 .endif

Modified: head/share/mk/sys.mk
==
--- head/share/mk/sys.mkTue Oct 18 00:55:15 2016(r307542)
+++ head/share/mk/sys.mkTue Oct 18 01:42:42 2016(r307543)
@@ -229,6 +229,8 @@ LINTLIBFLAGS?=  -cghapbxu -C ${LIB}
 MAKE   ?=  make
 
 .if !defined(%POSIX)
+LORDER ?=  lorder
+
 NM ?=  nm
 NMFLAGS?=
 
@@ -242,6 +244,9 @@ PFLAGS  ?=
 
 RC ?=  f77
 RFLAGS ?=
+
+TSORT  ?=  tsort
+TSORTFLAGS ?=  -q
 .endif
 
 SHELL  ?=  sh
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r307387 - head/usr.bin/mkimg

2016-10-15 Thread Marcel Moolenaar
Author: marcel
Date: Sun Oct 16 02:55:52 2016
New Revision: 307387
URL: https://svnweb.freebsd.org/changeset/base/307387

Log:
  Switch to using the portable partition scheme headers.

Modified:
  head/usr.bin/mkimg/Makefile
  head/usr.bin/mkimg/apm.c
  head/usr.bin/mkimg/bsd.c
  head/usr.bin/mkimg/ebr.c
  head/usr.bin/mkimg/gpt.c
  head/usr.bin/mkimg/mbr.c
  head/usr.bin/mkimg/pc98.c
  head/usr.bin/mkimg/vtoc8.c

Modified: head/usr.bin/mkimg/Makefile
==
--- head/usr.bin/mkimg/Makefile Sun Oct 16 02:43:51 2016(r307386)
+++ head/usr.bin/mkimg/Makefile Sun Oct 16 02:55:52 2016(r307387)
@@ -11,6 +11,7 @@ mkimg.o: Makefile
 
 CFLAGS+=-DMKIMG_VERSION=${MKIMG_VERSION}
 CFLAGS+=-DSPARSE_WRITE
+CFLAGS+=-I${.CURDIR:H:H}/sys
 
 # List of formats to support
 SRCS+= \

Modified: head/usr.bin/mkimg/apm.c
==
--- head/usr.bin/mkimg/apm.cSun Oct 16 02:43:51 2016(r307386)
+++ head/usr.bin/mkimg/apm.cSun Oct 16 02:55:52 2016(r307387)
@@ -33,20 +33,13 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
+#include 
 
 #include "endian.h"
 #include "image.h"
 #include "mkimg.h"
 #include "scheme.h"
 
-#ifndef APM_ENT_TYPE_APPLE_BOOT
-#defineAPM_ENT_TYPE_APPLE_BOOT "Apple_Bootstrap"
-#endif
-#ifndef APM_ENT_TYPE_FREEBSD_NANDFS
-#defineAPM_ENT_TYPE_FREEBSD_NANDFS "FreeBSD-nandfs"
-#endif
-
 static struct mkimg_alias apm_aliases[] = {
 {  ALIAS_FREEBSD, ALIAS_PTR2TYPE(APM_ENT_TYPE_FREEBSD) },
 {  ALIAS_FREEBSD_BOOT, ALIAS_PTR2TYPE(APM_ENT_TYPE_APPLE_BOOT) },

Modified: head/usr.bin/mkimg/bsd.c
==
--- head/usr.bin/mkimg/bsd.cSun Oct 16 02:43:51 2016(r307386)
+++ head/usr.bin/mkimg/bsd.cSun Oct 16 02:55:52 2016(r307387)
@@ -33,17 +33,13 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
+#include 
 
 #include "endian.h"
 #include "image.h"
 #include "mkimg.h"
 #include "scheme.h"
 
-#ifndef FS_NANDFS
-#defineFS_NANDFS   30
-#endif
-
 static struct mkimg_alias bsd_aliases[] = {
 {  ALIAS_FREEBSD_NANDFS, ALIAS_INT2TYPE(FS_NANDFS) },
 {  ALIAS_FREEBSD_SWAP, ALIAS_INT2TYPE(FS_SWAP) },
@@ -58,7 +54,7 @@ bsd_metadata(u_int where, lba_t blk)
 {
 
if (where == SCHEME_META_IMG_START)
-   blk += BBSIZE / secsz;
+   blk += BSD_BOOTBLOCK_SIZE / secsz;
else if (where == SCHEME_META_IMG_END)
blk = round_cylinder(blk);
else
@@ -76,21 +72,21 @@ bsd_write(lba_t imgsz, void *bootcode)
int bsdparts, error, n;
uint16_t checksum;
 
-   buf = malloc(BBSIZE);
+   buf = malloc(BSD_BOOTBLOCK_SIZE);
if (buf == NULL)
return (ENOMEM);
if (bootcode != NULL) {
-   memcpy(buf, bootcode, BBSIZE);
+   memcpy(buf, bootcode, BSD_BOOTBLOCK_SIZE);
memset(buf + secsz, 0, sizeof(struct disklabel));
} else
-   memset(buf, 0, BBSIZE);
+   memset(buf, 0, BSD_BOOTBLOCK_SIZE);
 
bsdparts = nparts + 1;  /* Account for c partition */
-   if (bsdparts < MAXPARTITIONS)
-   bsdparts = MAXPARTITIONS;
+   if (bsdparts < BSD_NPARTS_MIN)
+   bsdparts = BSD_NPARTS_MIN;
 
d = (void *)(buf + secsz);
-   le32enc(>d_magic, DISKMAGIC);
+   le32enc(>d_magic, BSD_MAGIC);
le32enc(>d_secsize, secsz);
le32enc(>d_nsectors, nsecs);
le32enc(>d_ntracks, nheads);
@@ -98,14 +94,14 @@ bsd_write(lba_t imgsz, void *bootcode)
le32enc(>d_secpercyl, nsecs * nheads);
le32enc(>d_secperunit, imgsz);
le16enc(>d_rpm, 3600);
-   le32enc(>d_magic2, DISKMAGIC);
+   le32enc(>d_magic2, BSD_MAGIC);
le16enc(>d_npartitions, bsdparts);
-   le32enc(>d_bbsize, BBSIZE);
+   le32enc(>d_bbsize, BSD_BOOTBLOCK_SIZE);
 
-   dp = >d_partitions[RAW_PART];
+   dp = >d_partitions[BSD_PART_RAW];
le32enc(>p_size, imgsz);
TAILQ_FOREACH(part, , link) {
-   n = part->index + ((part->index >= RAW_PART) ? 1 : 0);
+   n = part->index + ((part->index >= BSD_PART_RAW) ? 1 : 0);
dp = >d_partitions[n];
le32enc(>p_size, part->size);
le32enc(>p_offset, part->block);
@@ -121,7 +117,7 @@ bsd_write(lba_t imgsz, void *bootcode)
checksum ^= le16dec(p);
le16enc(>d_checksum, checksum);
 
-   error = image_write(0, buf, BBSIZE / secsz);
+   error = image_write(0, buf, BSD_BOOTBLOCK_SIZE / secsz);
free(buf);
return (error);
 }
@@ -132,8 +128,8 @@ static struct mkimg_scheme bsd_scheme = 
.aliases = bsd_aliases,
.metadata = bsd_metadata,
.write = bsd_write,
-   .nparts = 19,
-   .bootcode = BBSIZE,
+   

svn commit: r307386 - in head: etc/mtree include sys/sys sys/sys/disk

2016-10-15 Thread Marcel Moolenaar
Author: marcel
Date: Sun Oct 16 02:43:51 2016
New Revision: 307386
URL: https://svnweb.freebsd.org/changeset/base/307386

Log:
  Re-apply change 306811 or alternatively, revert change 307385.

Added:
  head/sys/sys/disk/
  head/sys/sys/disk/apm.h
 - copied, changed from r307385, head/sys/sys/apm.h
  head/sys/sys/disk/bsd.h
 - copied, changed from r307385, head/sys/sys/disklabel.h
  head/sys/sys/disk/gpt.h
 - copied, changed from r307385, head/sys/sys/gpt.h
  head/sys/sys/disk/mbr.h
 - copied, changed from r307385, head/sys/sys/diskmbr.h
  head/sys/sys/disk/pc98.h
 - copied, changed from r307385, head/sys/sys/diskpc98.h
  head/sys/sys/disk/vtoc.h
 - copied, changed from r307385, head/sys/sys/vtoc.h
Modified:
  head/etc/mtree/BSD.include.dist
  head/include/Makefile
  head/sys/sys/apm.h
  head/sys/sys/disklabel.h
  head/sys/sys/diskmbr.h
  head/sys/sys/diskpc98.h
  head/sys/sys/gpt.h
  head/sys/sys/vtoc.h

Modified: head/etc/mtree/BSD.include.dist
==
--- head/etc/mtree/BSD.include.dist Sun Oct 16 02:05:22 2016
(r307385)
+++ head/etc/mtree/BSD.include.dist Sun Oct 16 02:43:51 2016
(r307386)
@@ -336,6 +336,8 @@
 ssp
 ..
 sys
+disk
+..
 ..
 teken
 ..

Modified: head/include/Makefile
==
--- head/include/Makefile   Sun Oct 16 02:05:22 2016(r307385)
+++ head/include/Makefile   Sun Oct 16 02:43:51 2016(r307386)
@@ -59,6 +59,7 @@ LSUBDIRS= cam/ata cam/nvme cam/scsi \
security/audit \
security/mac_biba security/mac_bsdextended security/mac_lomac \
security/mac_mls security/mac_partition \
+   sys/disk \
ufs/ffs ufs/ufs
 
 LSUBSUBDIRS=   dev/mpt/mpilib

Modified: head/sys/sys/apm.h
==
--- head/sys/sys/apm.h  Sun Oct 16 02:05:22 2016(r307385)
+++ head/sys/sys/apm.h  Sun Oct 16 02:43:51 2016(r307386)
@@ -1,69 +1,5 @@
 /*-
- * Copyright (c) 2007 Marcel Moolenaar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
+ * This file is in the public domain.
  */
-
-#ifndef _SYS_APM_H_
-#define_SYS_APM_H_
-
-/* Driver Descriptor Record. */
-struct apm_ddr {
-   uint16_tddr_sig;
-#defineAPM_DDR_SIG 0x4552
-   uint16_tddr_blksize;
-   uint32_tddr_blkcount;
-};
-
-#defineAPM_ENT_NAMELEN 32
-#defineAPM_ENT_TYPELEN 32
-
-/* Partition Map Entry Record. */
-struct apm_ent {
-   uint16_tent_sig;
-#defineAPM_ENT_SIG 0x504d
-   uint16_t_pad_;
-   uint32_tent_pmblkcnt;
-   uint32_tent_start;
-   uint32_tent_size;
-   charent_name[APM_ENT_NAMELEN];
-   charent_type[APM_ENT_TYPELEN];
-};
-
-#defineAPM_ENT_TYPE_SELF   "Apple_partition_map"
-#defineAPM_ENT_TYPE_UNUSED "Apple_Free"
-
-#defineAPM_ENT_TYPE_FREEBSD"FreeBSD"
-#defineAPM_ENT_TYPE_FREEBSD_NANDFS "FreeBSD-nandfs"
-#defineAPM_ENT_TYPE_FREEBSD_SWAP   "FreeBSD-swap"
-#defineAPM_ENT_TYPE_FREEBSD_UFS"FreeBSD-UFS"
-#defineAPM_ENT_TYPE_FREEBSD_VINUM  "FreeBSD-Vinum"
-#defineAPM_ENT_TYPE_FREEBSD_ZFS"FreeBSD-ZFS"
-
-#defineAPM_ENT_TYPE_APPLE_BOOT "Apple_Bootstrap"
-#defineAPM_ENT_TYPE_APPLE_HFS  "Apple_

svn commit: r307385 - in head: etc/mtree include sys/sys sys/sys/disk

2016-10-15 Thread Marcel Moolenaar
Author: marcel
Date: Sun Oct 16 02:05:22 2016
New Revision: 307385
URL: https://svnweb.freebsd.org/changeset/base/307385

Log:
  Revert change 306811 so that the change can be re-done using
  svn copy instead of svn move.  This to preserve history on
  the originals headers as well.

Replaced:
  head/sys/sys/apm.h
 - copied unchanged from r306810, head/sys/sys/apm.h
  head/sys/sys/disklabel.h
 - copied unchanged from r306810, head/sys/sys/disklabel.h
  head/sys/sys/diskmbr.h
 - copied unchanged from r306810, head/sys/sys/diskmbr.h
  head/sys/sys/diskpc98.h
 - copied unchanged from r306810, head/sys/sys/diskpc98.h
  head/sys/sys/gpt.h
 - copied unchanged from r306810, head/sys/sys/gpt.h
  head/sys/sys/vtoc.h
 - copied unchanged from r306810, head/sys/sys/vtoc.h
Deleted:
  head/sys/sys/disk/
Modified:
  head/etc/mtree/BSD.include.dist
  head/include/Makefile

Modified: head/etc/mtree/BSD.include.dist
==
--- head/etc/mtree/BSD.include.dist Sat Oct 15 23:46:55 2016
(r307384)
+++ head/etc/mtree/BSD.include.dist Sun Oct 16 02:05:22 2016
(r307385)
@@ -336,8 +336,6 @@
 ssp
 ..
 sys
-disk
-..
 ..
 teken
 ..

Modified: head/include/Makefile
==
--- head/include/Makefile   Sat Oct 15 23:46:55 2016(r307384)
+++ head/include/Makefile   Sun Oct 16 02:05:22 2016(r307385)
@@ -59,7 +59,6 @@ LSUBDIRS= cam/ata cam/nvme cam/scsi \
security/audit \
security/mac_biba security/mac_bsdextended security/mac_lomac \
security/mac_mls security/mac_partition \
-   sys/disk \
ufs/ffs ufs/ufs
 
 LSUBSUBDIRS=   dev/mpt/mpilib

Copied: head/sys/sys/apm.h (from r306810, head/sys/sys/apm.h)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/sys/apm.h  Sun Oct 16 02:05:22 2016(r307385, copy of 
r306810, head/sys/sys/apm.h)
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2007 Marcel Moolenaar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _SYS_APM_H_
+#define_SYS_APM_H_
+
+/* Driver Descriptor Record. */
+struct apm_ddr {
+   uint16_tddr_sig;
+#defineAPM_DDR_SIG 0x4552
+   uint16_tddr_blksize;
+   uint32_tddr_blkcount;
+};
+
+#defineAPM_ENT_NAMELEN 32
+#defineAPM_ENT_TYPELEN 32
+
+/* Partition Map Entry Record. */
+struct apm_ent {
+   uint16_tent_sig;
+#defineAPM_ENT_SIG 0x504d
+   uint16_t_pad_;
+   uint32_tent_pmblkcnt;
+   uint32_tent_start;
+   uint32_tent_size;
+   charent_name[APM_ENT_NAMELEN];
+   charent_type[APM_ENT_TYPELEN];
+};
+
+#defineAPM_ENT_TYPE_SELF   "Apple_partition_map"
+#defineAPM_ENT_TYPE_UNUSED "Apple_Free"
+
+#defineAPM_ENT_TYPE_FREEBSD"FreeBSD"
+#defineAPM_ENT_TYPE_FREEBSD_NANDFS "FreeBSD-nandfs"
+#defineAPM_ENT_TYPE_FREEBSD_SWAP   "FreeBSD-swap"
+#defineAPM_ENT_TYPE_FREEBSD_UFS"FreeBSD-UFS"
+#defineAPM_ENT_TYPE_FREEBSD_VINUM  "FreeBSD-Vinum"
+#defineAPM_ENT_TYPE_FREEBSD_ZFS"FreeBSD-ZFS"
+
+#defineAPM_ENT_TYPE_APPLE_BOOT "Apple_Bootstrap"
+#defineAPM_ENT_TYPE_APPLE_HFS  "Apple_HFS"
+#defin

Re: svn commit: r306811 - in head: etc/mtree include sys/sys sys/sys/disk

2016-10-07 Thread Marcel Moolenaar
On October 7, 2016 at 5:13:10 PM, Julian Elischer (jul...@freebsd.org) wrote:
On 7/10/2016 4:29 PM, Marcel Moolenaar wrote:
On October 7, 2016 at 4:18:31 PM, Julian Elischer (jul...@freebsd.org) wrote:
On 7/10/2016 4:12 PM, Marcel Moolenaar wrote:
On October 7, 2016 at 3:18:10 PM, John Baldwin (j...@freebsd.org) wrote:
On Friday, October 07, 2016 01:16:59 PM Marcel Moolenaar wrote: 
> On October 7, 2016 at 11:02:44 AM, John Baldwin (j...@freebsd.org) wrote: 
> On Friday, October 07, 2016 03:42:21 PM Marcel Moolenaar wrote: 
> *snip* 
> 
> > Author: marcel 
> > Date: Fri Oct 7 15:42:20 2016 
> > New Revision: 306811 
> > URL: https://svnweb.freebsd.org/changeset/base/306811 
> > 
> > Added: 
> > head/sys/sys/disk/ 
> > head/sys/sys/disk/apm.h 
> > - copied, changed from r306810, head/sys/sys/apm.h 
> > head/sys/sys/disk/bsd.h 
> > - copied, changed from r306810, head/sys/sys/disklabel.h 
> > head/sys/sys/disk/gpt.h 
> > - copied, changed from r306810, head/sys/sys/gpt.h 
> > head/sys/sys/disk/mbr.h 
> > - copied, changed from r306810, head/sys/sys/diskmbr.h 
> > head/sys/sys/disk/pc98.h 
> > - copied, changed from r306810, head/sys/sys/diskpc98.h 
> > head/sys/sys/disk/vtoc.h 
> > - copied, changed from r306810, head/sys/sys/vtoc.h 
> > Replaced: 
> > head/sys/sys/apm.h (contents, props changed) 
> > head/sys/sys/disklabel.h (contents, props changed) 
> > head/sys/sys/diskmbr.h (contents, props changed) 
> > head/sys/sys/diskpc98.h (contents, props changed) 
> > head/sys/sys/gpt.h (contents, props changed) 
> > head/sys/sys/vtoc.h (contents, props changed) 
> 
> Somehow this destroyed the history on these files. They showed up as 
> deleted and then added instead of modified. If you 'svn log' on them 
> now you only get this commit and none of the previous history. I've 
> no idea if there's a way to recover this? Had you originally done an 
> 'svn mv' in your checkout and then copied the files back over or some 
> such? 
> I did a move from sys/X.h to sys/disk/X.h. The history moved to sys/disk/X.h. 
> New files were put where the old files used to be. 
> 
> Should I have done a svn copy? 

I think a copy would have been best. There is content in the sys/foo.h files 
still that has valid history (not all the lines were moved). Even if you had 
moved it all, I think a copy would still be best. I would only use a move 
if you are completely removing the original file. I'm not sure if there's a 
non-unfun way to recover from this. You might be able to copy the files from 
the previous revision, reapply your changes and then commit that. 
Ok. I’ll work on recovering the history of the original files.

Maybe the repo masters can undo/delete the commit easily and I’ll just 
recommit. Avoids polluting the history…



I'll keep an eye out for my svn -> p4 mirror importer exploding in that area in 
the near future.
this sort of thing makes it very ill, especially files going away and coming 
back.
I just asked svnadm@ for advice. I’m sure they can suggest a way that doesn’t 
blow things up downstream consumers. I’m fine with the manual labor if that’s 
preferred...



I run a svn-> P4 imoprter that is importign at 1:1..  so change 30 in SVN 
is 30 in p4.
If we end up making extra or missing revisions, I'll lose that 1:1 feature 
..e.g.  if 35 in svn maps to 350001  or 34 in p4 that's  a lot less 
useful to me..
I’ll keep that in mind. If svnadm@ has no strong opinions, I’ll manually fix it 
up using commits.

Thanks for the info,




signature.asc
Description: Message signed with OpenPGP using AMPGpg


Re: svn commit: r306811 - in head: etc/mtree include sys/sys sys/sys/disk

2016-10-07 Thread Marcel Moolenaar
On October 7, 2016 at 4:18:31 PM, Julian Elischer (jul...@freebsd.org) wrote:
On 7/10/2016 4:12 PM, Marcel Moolenaar wrote:
On October 7, 2016 at 3:18:10 PM, John Baldwin (j...@freebsd.org) wrote:
On Friday, October 07, 2016 01:16:59 PM Marcel Moolenaar wrote: 
> On October 7, 2016 at 11:02:44 AM, John Baldwin (j...@freebsd.org) wrote: 
> On Friday, October 07, 2016 03:42:21 PM Marcel Moolenaar wrote: 
> *snip* 
> 
> > Author: marcel 
> > Date: Fri Oct 7 15:42:20 2016 
> > New Revision: 306811 
> > URL: https://svnweb.freebsd.org/changeset/base/306811 
> > 
> > Added: 
> > head/sys/sys/disk/ 
> > head/sys/sys/disk/apm.h 
> > - copied, changed from r306810, head/sys/sys/apm.h 
> > head/sys/sys/disk/bsd.h 
> > - copied, changed from r306810, head/sys/sys/disklabel.h 
> > head/sys/sys/disk/gpt.h 
> > - copied, changed from r306810, head/sys/sys/gpt.h 
> > head/sys/sys/disk/mbr.h 
> > - copied, changed from r306810, head/sys/sys/diskmbr.h 
> > head/sys/sys/disk/pc98.h 
> > - copied, changed from r306810, head/sys/sys/diskpc98.h 
> > head/sys/sys/disk/vtoc.h 
> > - copied, changed from r306810, head/sys/sys/vtoc.h 
> > Replaced: 
> > head/sys/sys/apm.h (contents, props changed) 
> > head/sys/sys/disklabel.h (contents, props changed) 
> > head/sys/sys/diskmbr.h (contents, props changed) 
> > head/sys/sys/diskpc98.h (contents, props changed) 
> > head/sys/sys/gpt.h (contents, props changed) 
> > head/sys/sys/vtoc.h (contents, props changed) 
> 
> Somehow this destroyed the history on these files. They showed up as 
> deleted and then added instead of modified. If you 'svn log' on them 
> now you only get this commit and none of the previous history. I've 
> no idea if there's a way to recover this? Had you originally done an 
> 'svn mv' in your checkout and then copied the files back over or some 
> such? 
> I did a move from sys/X.h to sys/disk/X.h. The history moved to sys/disk/X.h. 
> New files were put where the old files used to be. 
> 
> Should I have done a svn copy? 

I think a copy would have been best. There is content in the sys/foo.h files 
still that has valid history (not all the lines were moved). Even if you had 
moved it all, I think a copy would still be best. I would only use a move 
if you are completely removing the original file. I'm not sure if there's a 
non-unfun way to recover from this. You might be able to copy the files from 
the previous revision, reapply your changes and then commit that. 
Ok. I’ll work on recovering the history of the original files.

Maybe the repo masters can undo/delete the commit easily and I’ll just 
recommit. Avoids polluting the history…



I'll keep an eye out for my svn -> p4 mirror importer exploding in that area in 
the near future.
this sort of thing makes it very ill, especially files going away and coming 
back.
I just asked svnadm@ for advice. I’m sure they can suggest a way that doesn’t 
blow things up downstream consumers. I’m fine with the manual labor if that’s 
preferred...




signature.asc
Description: Message signed with OpenPGP using AMPGpg


Re: svn commit: r306811 - in head: etc/mtree include sys/sys sys/sys/disk

2016-10-07 Thread Marcel Moolenaar
On October 7, 2016 at 3:18:10 PM, John Baldwin (j...@freebsd.org) wrote:
On Friday, October 07, 2016 01:16:59 PM Marcel Moolenaar wrote: 
> On October 7, 2016 at 11:02:44 AM, John Baldwin (j...@freebsd.org) wrote: 
> On Friday, October 07, 2016 03:42:21 PM Marcel Moolenaar wrote: 
> *snip* 
> 
> > Author: marcel 
> > Date: Fri Oct 7 15:42:20 2016 
> > New Revision: 306811 
> > URL: https://svnweb.freebsd.org/changeset/base/306811 
> > 
> > Added: 
> > head/sys/sys/disk/ 
> > head/sys/sys/disk/apm.h 
> > - copied, changed from r306810, head/sys/sys/apm.h 
> > head/sys/sys/disk/bsd.h 
> > - copied, changed from r306810, head/sys/sys/disklabel.h 
> > head/sys/sys/disk/gpt.h 
> > - copied, changed from r306810, head/sys/sys/gpt.h 
> > head/sys/sys/disk/mbr.h 
> > - copied, changed from r306810, head/sys/sys/diskmbr.h 
> > head/sys/sys/disk/pc98.h 
> > - copied, changed from r306810, head/sys/sys/diskpc98.h 
> > head/sys/sys/disk/vtoc.h 
> > - copied, changed from r306810, head/sys/sys/vtoc.h 
> > Replaced: 
> > head/sys/sys/apm.h (contents, props changed) 
> > head/sys/sys/disklabel.h (contents, props changed) 
> > head/sys/sys/diskmbr.h (contents, props changed) 
> > head/sys/sys/diskpc98.h (contents, props changed) 
> > head/sys/sys/gpt.h (contents, props changed) 
> > head/sys/sys/vtoc.h (contents, props changed) 
> 
> Somehow this destroyed the history on these files. They showed up as 
> deleted and then added instead of modified. If you 'svn log' on them 
> now you only get this commit and none of the previous history. I've 
> no idea if there's a way to recover this? Had you originally done an 
> 'svn mv' in your checkout and then copied the files back over or some 
> such? 
> I did a move from sys/X.h to sys/disk/X.h. The history moved to sys/disk/X.h. 
> New files were put where the old files used to be. 
> 
> Should I have done a svn copy? 

I think a copy would have been best. There is content in the sys/foo.h files 
still that has valid history (not all the lines were moved). Even if you had 
moved it all, I think a copy would still be best. I would only use a move 
if you are completely removing the original file. I'm not sure if there's a 
non-unfun way to recover from this. You might be able to copy the files from 
the previous revision, reapply your changes and then commit that. 
Ok. I’ll work on recovering the history of the original files.

Maybe the repo masters can undo/delete the commit easily and I’ll just 
recommit. Avoids polluting the history…




signature.asc
Description: Message signed with OpenPGP using AMPGpg


Re: svn commit: r306811 - in head: etc/mtree include sys/sys sys/sys/disk

2016-10-07 Thread Marcel Moolenaar
On October 7, 2016 at 11:02:44 AM, John Baldwin (j...@freebsd.org) wrote:
On Friday, October 07, 2016 03:42:21 PM Marcel Moolenaar wrote: 
*snip*

> Author: marcel 
> Date: Fri Oct 7 15:42:20 2016 
> New Revision: 306811 
> URL: https://svnweb.freebsd.org/changeset/base/306811 
> 
> Added: 
> head/sys/sys/disk/ 
> head/sys/sys/disk/apm.h 
> - copied, changed from r306810, head/sys/sys/apm.h 
> head/sys/sys/disk/bsd.h 
> - copied, changed from r306810, head/sys/sys/disklabel.h 
> head/sys/sys/disk/gpt.h 
> - copied, changed from r306810, head/sys/sys/gpt.h 
> head/sys/sys/disk/mbr.h 
> - copied, changed from r306810, head/sys/sys/diskmbr.h 
> head/sys/sys/disk/pc98.h 
> - copied, changed from r306810, head/sys/sys/diskpc98.h 
> head/sys/sys/disk/vtoc.h 
> - copied, changed from r306810, head/sys/sys/vtoc.h 
> Replaced: 
> head/sys/sys/apm.h (contents, props changed) 
> head/sys/sys/disklabel.h (contents, props changed) 
> head/sys/sys/diskmbr.h (contents, props changed) 
> head/sys/sys/diskpc98.h (contents, props changed) 
> head/sys/sys/gpt.h (contents, props changed) 
> head/sys/sys/vtoc.h (contents, props changed) 

Somehow this destroyed the history on these files. They showed up as 
deleted and then added instead of modified. If you 'svn log' on them 
now you only get this commit and none of the previous history. I've 
no idea if there's a way to recover this? Had you originally done an 
'svn mv' in your checkout and then copied the files back over or some 
such? 
I did a move from sys/X.h to sys/disk/X.h. The history moved to sys/disk/X.h. 
New files were put where the old files used to be.

Should I have done a svn copy?




signature.asc
Description: Message signed with OpenPGP using AMPGpg


svn commit: r306811 - in head: etc/mtree include sys/sys sys/sys/disk

2016-10-07 Thread Marcel Moolenaar
ribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)disklabel.h 8.2 (Berkeley) 7/10/94
+ * $FreeBSD$
+ */
+
+#ifndef _SYS_DISKMBR_H_
+#define_SYS_DISKMBR_H_
+
+#include 
+#include 
+
+void dos_partition_dec(void const *pp, struct dos_partition *d);
+void dos_partition_enc(void *pp, struct dos_partition *d);
+
+#define DIOCSMBR   _IOW('M', 129, u_char[512])
+
+#endif /* !_SYS_DISKMBR_H_ */

Added: head/sys/sys/diskpc98.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/sys/diskpc98.h Fri Oct  7 15:42:20 2016(r306811)
@@ -0,0 +1,47 @@
+/*-
+ * Copyright (c) 1987, 1988, 1993
+ * The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)disklabel.h 8.2 (Berkeley) 7/10/94
+ * $FreeBSD$
+ */
+
+#ifndef _SYS_DISKPC98_H_
+#define_SYS_DISKPC98_H_
+
+#include 
+#include 
+
+#defineDOSMID_386BSD   __DOSMID_386BSD
+#defineDOSSID_386BSD   __DOSSID_386BSD
+
+void pc98_partition_dec(void const *pp, struct pc98_partition *d);
+void pc98_partition_enc(void *pp, struct pc98_partition *d);
+
+#define DIOCSPC98  _IOW('M', 129, u_char[8192])
+
+#endif /* !_SYS_DISKPC98_H_ */

Added: head/sys/sys/gpt.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/sys/gpt.h  Fri Oct  7 15:42:20 2016(r306811)
@@ -0,0 +1,37 @@
+/*-
+ * Copyright (c) 2002 Marcel Moolenaar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of 

Re: svn commit: r306620 - head/usr.bin/mkimg

2016-10-03 Thread Marcel Moolenaar
On October 3, 2016 at 10:36:27 AM, Conrad Meyer (c...@freebsd.org) wrote:
On Sun, Oct 2, 2016 at 6:46 PM, Marcel Moolenaar <mar...@freebsd.org> wrote: 
> Author: marcel 
> Date: Mon Oct 3 01:46:47 2016 
> New Revision: 306620 
> URL: https://svnweb.freebsd.org/changeset/base/306620 
> 
> Log: 
> Replace STAILQ with TAILQ. TAILQs are portable enough that they can 
> be used on both macOS and Linux. STAILQs are not. In particular, 
> STAILQ_LAST does not next on Linux. Since neither STAILQ_FOREACH_SAFE 
> nor TAILQ_FOREACH_SAFE exist on Linux, replace its use with a regular 
> TAILQ_FOREACH. The _SAFE variant was only used for having the next 
> pointer in a local variable. 

All of these routines are available in the "libbsd" sys/queue.h. You 
might find other helpful portability/compatibility routines there, 
requiring fewer changes to the FreeBSD mkimg. 
Oh, nice. I’ll take a look.




signature.asc
Description: Message signed with OpenPGP using AMPGpg


Re: svn commit: r306622 - head/usr.bin/mkimg

2016-10-03 Thread Marcel Moolenaar



On October 2, 2016 at 11:52:33 PM, Warner Losh (i...@bsdimp.com) wrote:

Wouldn't it be better to say at the top 

#ifndef OFF_MAX 
#define OFF_MAX INT64_MAX 
#endif 
Not sure. The max is just for input checking. We do not even try to deal with 
an lseek(2) implementation that doesn’t take a 64-bit offset argument. Granted, 
the use of OFF_MAX before was based on FreeBSD’s lseek(2) implementation and 
was chosen to match it, knowing very well that it has a 64-bit offset argument. 
If lseek(2) doesn’t take a 64-bit offset then mkimg(1) fails for images larger 
than 2GB, but the problems with that run deeper than the max capacity that a 
user can specify on the mkimg command line. Not using OFF_MAX is a clear 
indication that the limit is not fully determined by lseek(2), but to a greater 
extend by the datatype used to hold the capacity.

Hence by preference for going with INT64_MAX. Easy to change if people feel I 
should keep using OFF_MAX.




signature.asc
Description: Message signed with OpenPGP using AMPGpg


svn commit: r306622 - head/usr.bin/mkimg

2016-10-02 Thread Marcel Moolenaar
Author: marcel
Date: Mon Oct  3 04:00:30 2016
New Revision: 306622
URL: https://svnweb.freebsd.org/changeset/base/306622

Log:
  Replace OFF_MAX with INT64_MAX. The former is defined on Linux.

Modified:
  head/usr.bin/mkimg/mkimg.c

Modified: head/usr.bin/mkimg/mkimg.c
==
--- head/usr.bin/mkimg/mkimg.c  Mon Oct  3 02:37:28 2016(r306621)
+++ head/usr.bin/mkimg/mkimg.c  Mon Oct  3 04:00:30 2016(r306622)
@@ -496,7 +496,7 @@ main(int argc, char *argv[])
err(EX_UNAVAILABLE, "%s", optarg);
break;
case 'c':   /* CAPACITY */
-   error = parse_uint64(, 1, OFF_MAX, optarg);
+   error = parse_uint64(, 1, INT64_MAX, optarg);
if (error)
errc(EX_DATAERR, error, "capacity in bytes");
break;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r306621 - head/usr.bin/mkimg

2016-10-02 Thread Marcel Moolenaar
Author: marcel
Date: Mon Oct  3 02:37:28 2016
New Revision: 306621
URL: https://svnweb.freebsd.org/changeset/base/306621

Log:
  Prefer  over . While here remove redundant
  inclusion of .
  
  Move the inclusion of the disk partitioning headers out of order
  and inbetween standard headers and local header. They will change
  in a subsequent commit.

Modified:
  head/usr.bin/mkimg/apm.c
  head/usr.bin/mkimg/bsd.c
  head/usr.bin/mkimg/ebr.c
  head/usr.bin/mkimg/format.c
  head/usr.bin/mkimg/gpt.c
  head/usr.bin/mkimg/image.c
  head/usr.bin/mkimg/mbr.c
  head/usr.bin/mkimg/mkimg.c
  head/usr.bin/mkimg/pc98.c
  head/usr.bin/mkimg/qcow.c
  head/usr.bin/mkimg/raw.c
  head/usr.bin/mkimg/scheme.c
  head/usr.bin/mkimg/vhd.c
  head/usr.bin/mkimg/vmdk.c
  head/usr.bin/mkimg/vtoc8.c

Modified: head/usr.bin/mkimg/apm.c
==
--- head/usr.bin/mkimg/apm.cMon Oct  3 01:46:47 2016(r306620)
+++ head/usr.bin/mkimg/apm.cMon Oct  3 02:37:28 2016(r306621)
@@ -27,13 +27,14 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 
 
+#include 
+
 #include "endian.h"
 #include "image.h"
 #include "mkimg.h"

Modified: head/usr.bin/mkimg/bsd.c
==
--- head/usr.bin/mkimg/bsd.cMon Oct  3 01:46:47 2016(r306620)
+++ head/usr.bin/mkimg/bsd.cMon Oct  3 02:37:28 2016(r306621)
@@ -27,13 +27,14 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 
 
+#include 
+
 #include "endian.h"
 #include "image.h"
 #include "mkimg.h"

Modified: head/usr.bin/mkimg/ebr.c
==
--- head/usr.bin/mkimg/ebr.cMon Oct  3 01:46:47 2016(r306620)
+++ head/usr.bin/mkimg/ebr.cMon Oct  3 02:37:28 2016(r306621)
@@ -27,13 +27,14 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 
 
+#include 
+
 #include "endian.h"
 #include "image.h"
 #include "mkimg.h"

Modified: head/usr.bin/mkimg/format.c
==
--- head/usr.bin/mkimg/format.c Mon Oct  3 01:46:47 2016(r306620)
+++ head/usr.bin/mkimg/format.c Mon Oct  3 02:37:28 2016(r306621)
@@ -27,7 +27,6 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
 #include 
 #include 
 #include 

Modified: head/usr.bin/mkimg/gpt.c
==
--- head/usr.bin/mkimg/gpt.cMon Oct  3 01:46:47 2016(r306620)
+++ head/usr.bin/mkimg/gpt.cMon Oct  3 02:37:28 2016(r306621)
@@ -27,10 +27,7 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
-#include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -38,6 +35,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+#include 
+
 #include "endian.h"
 #include "image.h"
 #include "mkimg.h"

Modified: head/usr.bin/mkimg/image.c
==
--- head/usr.bin/mkimg/image.c  Mon Oct  3 01:46:47 2016(r306620)
+++ head/usr.bin/mkimg/image.c  Mon Oct  3 02:37:28 2016(r306621)
@@ -28,9 +28,7 @@
 __FBSDID("$FreeBSD$");
 
 #include 
-#include 
 #include 
-#include 
 #include 
 #include 
 #include 

Modified: head/usr.bin/mkimg/mbr.c
==
--- head/usr.bin/mkimg/mbr.cMon Oct  3 01:46:47 2016(r306620)
+++ head/usr.bin/mkimg/mbr.cMon Oct  3 02:37:28 2016(r306621)
@@ -27,13 +27,14 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 
 
+#include 
+
 #include "endian.h"
 #include "image.h"
 #include "mkimg.h"

Modified: head/usr.bin/mkimg/mkimg.c
==
--- head/usr.bin/mkimg/mkimg.c  Mon Oct  3 01:46:47 2016(r306620)
+++ head/usr.bin/mkimg/mkimg.c  Mon Oct  3 02:37:28 2016(r306621)
@@ -27,9 +27,7 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -37,6 +35,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/usr.bin/mkimg/pc98.c
==
--- head/usr.bin/mkimg/pc98.c   Mon Oct  3 01:46:47 2016(r306620)
+++ head/usr.bin/mkimg/pc98.c   Mon Oct  3 02:37:28 2016(r306621)
@@ -27,13 +27,14 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 
 
+#include 
+
 #include "endian.h"
 #include "image.h"
 #include "mkimg.h"

Modified: head/usr.bin/mkimg/qcow.c

svn commit: r306620 - head/usr.bin/mkimg

2016-10-02 Thread Marcel Moolenaar
Author: marcel
Date: Mon Oct  3 01:46:47 2016
New Revision: 306620
URL: https://svnweb.freebsd.org/changeset/base/306620

Log:
  Replace STAILQ with TAILQ. TAILQs are portable enough that they can
  be used on both macOS and Linux. STAILQs are not. In particular,
  STAILQ_LAST does not next on Linux. Since neither STAILQ_FOREACH_SAFE
  nor TAILQ_FOREACH_SAFE exist on Linux, replace its use with a regular
  TAILQ_FOREACH. The _SAFE variant was only used for having the next
  pointer in a local variable.

Modified:
  head/usr.bin/mkimg/apm.c
  head/usr.bin/mkimg/bsd.c
  head/usr.bin/mkimg/ebr.c
  head/usr.bin/mkimg/gpt.c
  head/usr.bin/mkimg/image.c
  head/usr.bin/mkimg/mbr.c
  head/usr.bin/mkimg/mkimg.c
  head/usr.bin/mkimg/mkimg.h
  head/usr.bin/mkimg/pc98.c
  head/usr.bin/mkimg/vtoc8.c

Modified: head/usr.bin/mkimg/apm.c
==
--- head/usr.bin/mkimg/apm.cMon Oct  3 01:08:34 2016(r306619)
+++ head/usr.bin/mkimg/apm.cMon Oct  3 01:46:47 2016(r306620)
@@ -91,7 +91,7 @@ apm_write(lba_t imgsz, void *bootcode __
strncpy(ent->ent_type, APM_ENT_TYPE_SELF, sizeof(ent->ent_type));
strncpy(ent->ent_name, "Apple", sizeof(ent->ent_name));
 
-   STAILQ_FOREACH(part, , link) {
+   TAILQ_FOREACH(part, , link) {
ent = (void *)(buf + (part->index + 2) * secsz);
be16enc(>ent_sig, APM_ENT_SIG);
be32enc(>ent_pmblkcnt, nparts + 1);

Modified: head/usr.bin/mkimg/bsd.c
==
--- head/usr.bin/mkimg/bsd.cMon Oct  3 01:08:34 2016(r306619)
+++ head/usr.bin/mkimg/bsd.cMon Oct  3 01:46:47 2016(r306620)
@@ -103,7 +103,7 @@ bsd_write(lba_t imgsz, void *bootcode)
 
dp = >d_partitions[RAW_PART];
le32enc(>p_size, imgsz);
-   STAILQ_FOREACH(part, , link) {
+   TAILQ_FOREACH(part, , link) {
n = part->index + ((part->index >= RAW_PART) ? 1 : 0);
dp = >d_partitions[n];
le32enc(>p_size, part->size);

Modified: head/usr.bin/mkimg/ebr.c
==
--- head/usr.bin/mkimg/ebr.cMon Oct  3 01:08:34 2016(r306619)
+++ head/usr.bin/mkimg/ebr.cMon Oct  3 01:46:47 2016(r306620)
@@ -88,7 +88,7 @@ ebr_write(lba_t imgsz __unused, void *bo
le16enc(ebr + DOSMAGICOFFSET, DOSMAGIC);
 
error = 0;
-   STAILQ_FOREACH_SAFE(part, , link, next) {
+   TAILQ_FOREACH(part, , link) {
block = part->block - nsecs;
size = round_track(part->size);
dp = (void *)(ebr + DOSPARTOFF);
@@ -100,6 +100,7 @@ ebr_write(lba_t imgsz __unused, void *bo
le32enc(>dp_size, size);
 
/* Add link entry */
+   next = TAILQ_NEXT(part, link);
if (next != NULL) {
size = round_track(next->size);
dp++;

Modified: head/usr.bin/mkimg/gpt.c
==
--- head/usr.bin/mkimg/gpt.cMon Oct  3 01:08:34 2016(r306619)
+++ head/usr.bin/mkimg/gpt.cMon Oct  3 01:46:47 2016(r306620)
@@ -208,7 +208,7 @@ gpt_mktbl(u_int tblsz)
if (tbl == NULL)
return (NULL);
 
-   STAILQ_FOREACH(part, , link) {
+   TAILQ_FOREACH(part, , link) {
ent = tbl + part->index;
gpt_uuid_enc(>ent_type, ALIAS_TYPE2PTR(part->type));
mkimg_uuid();

Modified: head/usr.bin/mkimg/image.c
==
--- head/usr.bin/mkimg/image.c  Mon Oct  3 01:08:34 2016(r306619)
+++ head/usr.bin/mkimg/image.c  Mon Oct  3 01:46:47 2016(r306620)
@@ -60,7 +60,7 @@ __FBSDID("$FreeBSD$");
 #endif
 
 struct chunk {
-   STAILQ_ENTRY(chunk) ch_list;
+   TAILQ_ENTRY(chunk) ch_list;
size_t  ch_size;/* Size of chunk in bytes. */
lba_t   ch_block;   /* Block address in image. */
union {
@@ -78,7 +78,7 @@ struct chunk {
 #defineCH_TYPE_MEMORY  2   /* Memory-backed chunk */
 };
 
-static STAILQ_HEAD(chunk_head, chunk) image_chunks;
+static TAILQ_HEAD(chunk_head, chunk) image_chunks;
 static u_int image_nchunks;
 
 static char image_swap_file[PATH_MAX];
@@ -139,14 +139,14 @@ image_chunk_find(lba_t blk)
struct chunk *ch;
 
ch = (last != NULL && last->ch_block <= blk)
-   ? last : STAILQ_FIRST(_chunks);
+   ? last : TAILQ_FIRST(_chunks);
while (ch != NULL) {
if (ch->ch_block <= blk &&
(lba_t)(ch->ch_block + (ch->ch_size / secsz)) > blk) {
last = ch;
break;
}
-   ch = STAILQ_NEXT(ch, ch_list);
+ 

svn commit: r306333 - head/usr.bin/mkimg

2016-09-25 Thread Marcel Moolenaar
Author: marcel
Date: Mon Sep 26 04:14:00 2016
New Revision: 306333
URL: https://svnweb.freebsd.org/changeset/base/306333

Log:
  Portability changes:
  1.  macOS nor Linux have MAP_NOCORE nor MAP_NOSYNC. Define as 0.
  2.  macOS doesn't have SEEK_DATA nor SEEK_HOLE. Define as -1
  so that lseek will return -1 (with errno set to EINVAL).
  3.  gcc correctly warns that error is assigned but not used in
  image_copyout_region().  Fix by returning on the first error.

Modified:
  head/usr.bin/mkimg/image.c

Modified: head/usr.bin/mkimg/image.c
==
--- head/usr.bin/mkimg/image.c  Mon Sep 26 02:29:28 2016(r306332)
+++ head/usr.bin/mkimg/image.c  Mon Sep 26 04:14:00 2016(r306333)
@@ -45,6 +45,20 @@ __FBSDID("$FreeBSD$");
 #include "image.h"
 #include "mkimg.h"
 
+#ifndef MAP_NOCORE
+#defineMAP_NOCORE  0
+#endif
+#ifndef MAP_NOSYNC
+#defineMAP_NOSYNC  0
+#endif
+
+#ifndef SEEK_DATA
+#defineSEEK_DATA   -1
+#endif
+#ifndef SEEK_HOLE
+#defineSEEK_HOLE   -1
+#endif
+
 struct chunk {
STAILQ_ENTRY(chunk) ch_list;
size_t  ch_size;/* Size of chunk in bytes. */
@@ -582,10 +596,13 @@ image_copyout_region(int fd, lba_t blk, 
 
size *= secsz;
 
-   while (size > 0) {
+   error = 0;
+   while (!error && size > 0) {
ch = image_chunk_find(blk);
-   if (ch == NULL)
-   return (EINVAL);
+   if (ch == NULL) {
+   error = EINVAL;
+   break;
+   }
ofs = (blk - ch->ch_block) * secsz;
sz = ch->ch_size - ofs;
sz = ((lba_t)sz < size) ? sz : (size_t)size;
@@ -606,7 +623,7 @@ image_copyout_region(int fd, lba_t blk, 
size -= sz;
blk += sz / secsz;
}
-   return (0);
+   return (error);
 }
 
 int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r306330 - head/usr.bin/mkimg

2016-09-25 Thread Marcel Moolenaar



On September 25, 2016 at 7:13:21 PM, Adrian Chadd (adrian.ch...@gmail.com) 
wrote:

Hi, 

Yeah, for portable-y stuff, I'd recommend: 

#include "endian.h" -> #ifdef __FreeBSD__ #include  
#elif __Apple__ etc, etc. 

That way we don't duplicate contents. 

Same with sys/queue.h, etc. 
We may even want to do , , etc. The compat 
directory can be shared by all build utilities that need portability.  That way 
we only have to solve portability problems once.  The name compat is but a 
suggestion.




signature.asc
Description: Message signed with OpenPGP using AMPGpg


svn commit: r306330 - head/usr.bin/mkimg

2016-09-25 Thread Marcel Moolenaar
Author: marcel
Date: Mon Sep 26 01:06:32 2016
New Revision: 306330
URL: https://svnweb.freebsd.org/changeset/base/306330

Log:
  Avoid depending on the  header for le*enc and be*enc.
  Not only is the header unportable, the encoding/decoding functions
  are as well.  Instead, duplicate the handful of small inlines we
  need into a private header called endian.h.
  
  Aside: an alternative approach is to move the encoding/decoding
  functions to a separate system header.  While the header is still
  nonportable, such an approach would make it possible to re-use the
  definitions by playing games with include paths. This may be the
  preferred approach if more (build) utilities need this.  This
  change does not preclude that.  In fact, it makes it easier.

Added:
  head/usr.bin/mkimg/endian.h   (contents, props changed)
Modified:
  head/usr.bin/mkimg/apm.c
  head/usr.bin/mkimg/bsd.c
  head/usr.bin/mkimg/ebr.c
  head/usr.bin/mkimg/gpt.c
  head/usr.bin/mkimg/mbr.c
  head/usr.bin/mkimg/pc98.c
  head/usr.bin/mkimg/qcow.c
  head/usr.bin/mkimg/raw.c
  head/usr.bin/mkimg/vhd.c
  head/usr.bin/mkimg/vmdk.c
  head/usr.bin/mkimg/vtoc8.c

Modified: head/usr.bin/mkimg/apm.c
==
--- head/usr.bin/mkimg/apm.cMon Sep 26 00:41:08 2016(r306329)
+++ head/usr.bin/mkimg/apm.cMon Sep 26 01:06:32 2016(r306330)
@@ -29,12 +29,12 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 
+#include "endian.h"
 #include "image.h"
 #include "mkimg.h"
 #include "scheme.h"

Modified: head/usr.bin/mkimg/bsd.c
==
--- head/usr.bin/mkimg/bsd.cMon Sep 26 00:41:08 2016(r306329)
+++ head/usr.bin/mkimg/bsd.cMon Sep 26 01:06:32 2016(r306330)
@@ -29,12 +29,12 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 
+#include "endian.h"
 #include "image.h"
 #include "mkimg.h"
 #include "scheme.h"

Modified: head/usr.bin/mkimg/ebr.c
==
--- head/usr.bin/mkimg/ebr.cMon Sep 26 00:41:08 2016(r306329)
+++ head/usr.bin/mkimg/ebr.cMon Sep 26 01:06:32 2016(r306330)
@@ -29,12 +29,12 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 
+#include "endian.h"
 #include "image.h"
 #include "mkimg.h"
 #include "scheme.h"

Added: head/usr.bin/mkimg/endian.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.bin/mkimg/endian.h Mon Sep 26 01:06:32 2016(r306330)
@@ -0,0 +1,106 @@
+/*-
+ * Copyright (c) 2002 Thomas Moestl 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _MKIMG_ENDIAN_H_
+#define _MKIMG_ENDIAN_H_
+
+static __inline uint16_t
+be16dec(const void *pp)
+{
+   uint8_t const *p = (uint8_t const *)pp;
+
+   return ((p[0] << 8) | p[1]);
+}
+
+static __inline void
+be16enc(void *pp, uint16_t u)
+{
+   uint8_t *p = (uint8_t *)pp;
+
+   p[0] = (u >> 8) & 0xff;
+   p[1] = u & 0xff;
+}
+
+static __inline void
+be32enc(void *pp, uint32_t u)
+{
+   uint8_t *p = (uint8_t *)pp;
+
+   p[0] = (u >> 24) & 0xff;
+   p[1] = (u >> 16) & 0xff;
+   p[2] = (u >> 8) & 0xff;
+   p[3] = u & 0xff;
+}
+
+static __inline void
+be64enc(void *pp, uint64_t u)
+{
+   uint8_t *p = (uint8_t *)pp;
+
+   be32enc(p, (uint32_t)(u >> 32));
+   be32enc(p + 4, (uint32_t)(u & 

svn commit: r306329 - head/usr.bin/mkimg

2016-09-25 Thread Marcel Moolenaar
Author: marcel
Date: Mon Sep 26 00:41:08 2016
New Revision: 306329
URL: https://svnweb.freebsd.org/changeset/base/306329

Log:
  Eliminate the use of EDOOFUS.  The error code was used to signal
  programming errors, but is really a poor substitute for assert.
  And less portable as well.

Modified:
  head/usr.bin/mkimg/image.c
  head/usr.bin/mkimg/qcow.c

Modified: head/usr.bin/mkimg/image.c
==
--- head/usr.bin/mkimg/image.c  Sun Sep 25 23:48:15 2016(r306328)
+++ head/usr.bin/mkimg/image.c  Mon Sep 26 00:41:08 2016(r306329)
@@ -456,8 +456,7 @@ image_copyin_mapped(lba_t blk, int fd, u
 * I don't know what this means or whether it
 * can happen at all...
 */
-   error = EDOOFUS;
-   break;
+   assert(0);
}
}
if (error)
@@ -602,7 +601,7 @@ image_copyout_region(int fd, lba_t blk, 
error = image_copyout_memory(fd, sz, ch->ch_u.mem.ptr);
break;
default:
-   return (EDOOFUS);
+   assert(0);
}
size -= sz;
blk += sz / secsz;

Modified: head/usr.bin/mkimg/qcow.c
==
--- head/usr.bin/mkimg/qcow.c   Sun Sep 25 23:48:15 2016(r306328)
+++ head/usr.bin/mkimg/qcow.c   Mon Sep 26 00:41:08 2016(r306329)
@@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -102,7 +103,7 @@ qcow_resize(lba_t imgsz, u_int version)
clstr_log2sz = QCOW2_CLSTR_LOG2SZ;
break;
default:
-   return (EDOOFUS);
+   assert(0);
}
 
imagesz = round_clstr(imgsz * secsz);
@@ -143,8 +144,7 @@ qcow_write(int fd, u_int version)
u_int clstrsz, l1idx, l2idx;
int error;
 
-   if (clstr_log2sz == 0)
-   return (EDOOFUS);
+   assert(clstr_log2sz != 0);
 
clstrsz = 1U << clstr_log2sz;
blk_clstrsz = clstrsz / secsz;
@@ -203,7 +203,7 @@ qcow_write(int fd, u_int version)
be32enc(>u.v2.refcnt_clstrs, refcnt_clstrs);
break;
default:
-   return (EDOOFUS);
+   assert(0);
}
 
if (sparse_write(fd, hdr, clstrsz) < 0) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r306312 - head

2016-09-25 Thread Marcel Moolenaar



On September 25, 2016 at 10:41:32 AM, Andrey V. Elsukov (bu7c...@yandex.ru) 
wrote:

On 25.09.16 19:39, Marcel Moolenaar wrote: 
> +20160924: 
> + Relocatable object files with the extension of .So have been renamed 
> + to use an extension of .pico instead. The purpose of this change is 
> + to avoid a name clash with shared libraries on case-insensitive file 
> + systems. On those file systems, foo.So is the same file as foo.so. 

Hi, 

probably old *.So files now should be removed using `make delete-old` or 
something like this.
make “delete-old” is not for pruning files or directories in the object tree 
(unless that changed while I wasn’t paying attention. Has that changed?




signature.asc
Description: Message signed with OpenPGP using AMPGpg


Re: svn commit: r306325 - head/usr.bin/mkimg

2016-09-25 Thread Marcel Moolenaar



On September 25, 2016 at 4:52:17 PM, Conrad Meyer (c...@freebsd.org) wrote:

What's the motivation for this? This seems worse. 
Portability.  We need mkimg to compile on other OSes besides FreeBSD.  In 
particular, macOS and Linux.  It’s ok that constructors are not 100% portable…




signature.asc
Description: Message signed with OpenPGP using AMPGpg


svn commit: r306325 - head/usr.bin/mkimg

2016-09-25 Thread Marcel Moolenaar
Author: marcel
Date: Sun Sep 25 22:57:59 2016
New Revision: 306325
URL: https://svnweb.freebsd.org/changeset/base/306325

Log:
  Replace the use of linker sets with constructors for both the
  formats and schemes.  Formats and schemes are registered at
  runtime now, rather than collected at link time.

Modified:
  head/usr.bin/mkimg/format.c
  head/usr.bin/mkimg/format.h
  head/usr.bin/mkimg/mkimg.c
  head/usr.bin/mkimg/scheme.c
  head/usr.bin/mkimg/scheme.h

Modified: head/usr.bin/mkimg/format.c
==
--- head/usr.bin/mkimg/format.c Sun Sep 25 22:17:46 2016(r306324)
+++ head/usr.bin/mkimg/format.c Sun Sep 25 22:57:59 2016(r306325)
@@ -28,8 +28,6 @@
 __FBSDID("$FreeBSD$");
 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -42,8 +40,24 @@ __FBSDID("$FreeBSD$");
 #include "format.h"
 #include "mkimg.h"
 
+static struct mkimg_format *first;
 static struct mkimg_format *format;
 
+struct mkimg_format *
+format_iterate(struct mkimg_format *f)
+{
+
+   return ((f == NULL) ? first : f->next);
+}
+
+void
+format_register(struct mkimg_format *f)
+{
+
+   f->next = first;
+   first = f;
+}
+
 int
 format_resize(lba_t end)
 {
@@ -56,10 +70,10 @@ format_resize(lba_t end)
 int
 format_select(const char *spec)
 {
-   struct mkimg_format *f, **iter;
+   struct mkimg_format *f;
 
-   SET_FOREACH(iter, formats) {
-   f = *iter;
+   f = NULL;
+   while ((f = format_iterate(f)) != NULL) {
if (strcasecmp(spec, f->name) == 0) {
format = f;
return (0);

Modified: head/usr.bin/mkimg/format.h
==
--- head/usr.bin/mkimg/format.h Sun Sep 25 22:17:46 2016(r306324)
+++ head/usr.bin/mkimg/format.h Sun Sep 25 22:57:59 2016(r306325)
@@ -29,21 +29,24 @@
 #ifndef _MKIMG_FORMAT_H_
 #define_MKIMG_FORMAT_H_
 
-#include 
-
 struct mkimg_format {
+   struct mkimg_format *next;
const char  *name;
const char  *description;
int (*resize)(lba_t);
int (*write)(int);
 };
 
-SET_DECLARE(formats, struct mkimg_format);
-#defineFORMAT_DEFINE(nm)   DATA_SET(formats, nm)
+#defineFORMAT_DEFINE(nm)   
\
+static void format_register_##nm(void) __attribute__((constructor));   \
+static void format_register_##nm(void) { format_register(); }
 
-intformat_resize(lba_t);
+struct mkimg_format *format_iterate(struct mkimg_format *);
+void   format_register(struct mkimg_format *);
 intformat_select(const char *);
 struct mkimg_format *format_selected(void);
+
+intformat_resize(lba_t);
 intformat_write(int);
 
 #endif /* _MKIMG_FORMAT_H_ */

Modified: head/usr.bin/mkimg/mkimg.c
==
--- head/usr.bin/mkimg/mkimg.c  Sun Sep 25 22:17:46 2016(r306324)
+++ head/usr.bin/mkimg/mkimg.c  Sun Sep 25 22:57:59 2016(r306325)
@@ -27,7 +27,6 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
 #include 
 #include 
 #include 
@@ -77,20 +76,20 @@ u_int blksz = 0;
 static void
 print_formats(int usage)
 {
-   struct mkimg_format *f, **f_iter;
+   struct mkimg_format *f;
const char *sep;
 
if (usage) {
fprintf(stderr, "formats:\n");
-   SET_FOREACH(f_iter, formats) {
-   f = *f_iter;
+   f = NULL;
+   while ((f = format_iterate(f)) != NULL) {
fprintf(stderr, "\t%s\t-  %s\n", f->name,
f->description);
}
} else {
sep = "";
-   SET_FOREACH(f_iter, formats) {
-   f = *f_iter;
+   f = NULL;
+   while ((f = format_iterate(f)) != NULL) {
printf("%s%s", sep, f->name);
sep = " ";
}
@@ -101,20 +100,20 @@ print_formats(int usage)
 static void
 print_schemes(int usage)
 {
-   struct mkimg_scheme *s, **s_iter;
+   struct mkimg_scheme *s;
const char *sep;
 
if (usage) {
fprintf(stderr, "schemes:\n");
-   SET_FOREACH(s_iter, schemes) {
-   s = *s_iter;
+   s = NULL;
+   while ((s = scheme_iterate(s)) != NULL) {
fprintf(stderr, "\t%s\t-  %s\n", s->name,
s->description);
}
} else {
sep = "";
-   SET_FOREACH(s_iter, schemes) {
-   s = *s_iter;
+   s = NULL;
+   while ((s = scheme_iterate(s)) != NULL) {
printf("%s%s", sep, s->name);
sep = " ";
}


svn commit: r306313 - head/share/mk

2016-09-25 Thread Marcel Moolenaar
Author: marcel
Date: Sun Sep 25 16:50:31 2016
New Revision: 306313
URL: https://svnweb.freebsd.org/changeset/base/306313

Log:
  Document the ".pico" extension for object files.
  
  Suggested by: emaste@

Modified:
  head/share/mk/bsd.README

Modified: head/share/mk/bsd.README
==
--- head/share/mk/bsd.READMESun Sep 25 16:39:18 2016(r306312)
+++ head/share/mk/bsd.READMESun Sep 25 16:50:31 2016(r306313)
@@ -114,7 +114,7 @@ the tree where the file gets installed.
 
 The profiled libraries are no longer built in a different directory than
 the regular libraries.  A new suffix, ".po", is used to denote a profiled
-object.
+object, and ".pico" denotes a position-independent relocatable object.
 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r306312 - head

2016-09-25 Thread Marcel Moolenaar
Author: marcel
Date: Sun Sep 25 16:39:18 2016
New Revision: 306312
URL: https://svnweb.freebsd.org/changeset/base/306312

Log:
  Relocatable object files are renamed from *.So to *.pico
  
  Reminder by:  imp@

Modified:
  head/UPDATING

Modified: head/UPDATING
==
--- head/UPDATING   Sun Sep 25 16:30:29 2016(r306311)
+++ head/UPDATING   Sun Sep 25 16:39:18 2016(r306312)
@@ -31,6 +31,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20160924:
+   Relocatable object files with the extension of .So have been renamed
+   to use an extension of .pico instead.  The purpose of this change is
+   to avoid a name clash with shared libraries on case-insensitive file
+   systems.  On those file systems, foo.So is the same file as foo.so.
+
 20160918:
GNU rcs has been turned off by default.  It can (temporarily) be built
again by adding WITH_RCS knob in src.conf.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r306300 - head/contrib/ofed/usr.lib/libsdp

2016-09-24 Thread Marcel Moolenaar
Author: marcel
Date: Sat Sep 24 17:50:11 2016
New Revision: 306300
URL: https://svnweb.freebsd.org/changeset/base/306300

Log:
  When MAKEOBJDIRPREFIX points to a case-insensitive file system, the
  build can break when different source files create the same target
  files (case-insensitivity speaking).  This is the case for object
  files compiled with -fpic and shared libraries. The former uses
  an extension of ".So", and the latter an extension ".so".  Rename
  shared object files from *.So to *.pico to match what NetBSD does.
  
  Missed in r306297
  
  MFC after:1 month
  Sponsored by: Bracket Computing
  Differential Revision:https://reviews.freebsd.org/D7906

Modified:
  head/contrib/ofed/usr.lib/libsdp/Makefile

Modified: head/contrib/ofed/usr.lib/libsdp/Makefile
==
--- head/contrib/ofed/usr.lib/libsdp/Makefile   Sat Sep 24 17:29:27 2016
(r306299)
+++ head/contrib/ofed/usr.lib/libsdp/Makefile   Sat Sep 24 17:50:11 2016
(r306300)
@@ -22,4 +22,4 @@ CFLAGS+= -I${OFEDSYS}/include
 
 # Remove .[ly] since the checked-in version is preferred.
 .SUFFIXES:
-.SUFFIXES: .o .po .So .c .ln
+.SUFFIXES: .o .po .pico .c .ln
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r306299 - head/usr.bin/mkimg

2016-09-24 Thread Marcel Moolenaar
Author: marcel
Date: Sat Sep 24 17:29:27 2016
New Revision: 306299
URL: https://svnweb.freebsd.org/changeset/base/306299

Log:
  Update local variable 'block' after calling capacity_resize(),
  otherwise format_resize(), which is called right after, isn't
  getting the current/actual image size. Rather than rounding up,
  format_resize() could end up truncating the size and we don't
  allow that by design.
  
  MFC after:1 week

Modified:
  head/usr.bin/mkimg/mkimg.c

Modified: head/usr.bin/mkimg/mkimg.c
==
--- head/usr.bin/mkimg/mkimg.c  Sat Sep 24 16:46:37 2016(r306298)
+++ head/usr.bin/mkimg/mkimg.c  Sat Sep 24 17:29:27 2016(r306299)
@@ -463,13 +463,16 @@ mkimg(void)
 
block = scheme_metadata(SCHEME_META_IMG_END, block);
error = image_set_size(block);
-   if (!error)
+   if (!error) {
error = capacity_resize(block);
-   if (!error)
+   block = image_get_size();
+   }
+   if (!error) {
error = format_resize(block);
+   block = image_get_size();
+   }
if (error)
errc(EX_IOERR, error, "image sizing");
-   block = image_get_size();
ncyls = block / (nsecs * nheads);
error = scheme_write(block);
if (error)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r306297 - in head: gnu/lib/libgcc gnu/lib/libgcov lib/libedit lib/libprocstat lib/libthr/support share/mk sys/conf usr.sbin/bsnmpd/modules/snmp_hostres

2016-09-24 Thread Marcel Moolenaar
Author: marcel
Date: Sat Sep 24 15:11:27 2016
New Revision: 306297
URL: https://svnweb.freebsd.org/changeset/base/306297

Log:
  When MAKEOBJDIRPREFIX points to a case-insensitive file system, the
  build can break when different source files create the same target
  files (case-insensitivity speaking).  This is the case for object
  files compiled with -fpic and shared libraries. The former uses
  an extension of ".So", and the latter an extension ".so".  Rename
  shared object files from *.So to *.pico to match what NetBSD does.
  
  See also r305855
  
  MFC after:1 month
  Sponsored by: Bracket Computing
  Differential Revision:https://reviews.freebsd.org/D7906

Modified:
  head/gnu/lib/libgcc/Makefile
  head/gnu/lib/libgcov/Makefile
  head/lib/libedit/Makefile
  head/lib/libprocstat/Makefile
  head/lib/libthr/support/Makefile.inc
  head/share/mk/bsd.dep.mk
  head/share/mk/bsd.lib.mk
  head/share/mk/meta.autodep.mk
  head/sys/conf/kern.post.mk
  head/sys/conf/kern.pre.mk
  head/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile

Modified: head/gnu/lib/libgcc/Makefile
==
--- head/gnu/lib/libgcc/MakefileSat Sep 24 13:44:18 2016
(r306296)
+++ head/gnu/lib/libgcc/MakefileSat Sep 24 15:11:27 2016
(r306297)
@@ -258,8 +258,8 @@ OBJ_GRPS += FPBIT DPBIT
 .for T in ${OBJ_GRPS}
 ${T}_OBJS_T =  ${${T}_FUNCS:S/$/.o/}
 ${T}_OBJS_P =  ${${T}_FUNCS:S/$/.po/}
-${T}_OBJS_S =  ${${T}_FUNCS:S/$/.So/}
-SOBJS +=   ${${T}_FUNCS:S/$/.So/}
+${T}_OBJS_S =  ${${T}_FUNCS:S/$/.pico/}
+SOBJS +=   ${${T}_FUNCS:S/$/.pico/}
 
 ${${T}_OBJS_T}: ${${T}_CFILE} ${COMMONHDRS}
${CC_T} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
@@ -274,7 +274,7 @@ ${${T}_OBJS_S}: ${${T}_CFILE} ${COMMONHD
 # Extra objects coming from separate files
 #
 .if !empty(LIB2ADD)
-SOBJS +=   ${LIB2ADD:R:S/$/.So/}
+SOBJS +=   ${LIB2ADD:R:S/$/.pico/}
 .endif
 
 #---
@@ -298,9 +298,9 @@ ${STAT_OBJS_P}: ${STD_CFILE} ${COMMONHDR
 .if defined(LIB1ASMSRC)
 ASM_T =${LIB1ASMFUNCS:S/$/.o/}
 ASM_P =${LIB1ASMFUNCS:S/$/.po/}
-ASM_S =${LIB1ASMFUNCS:S/$/.So/}
+ASM_S =${LIB1ASMFUNCS:S/$/.pico/}
 ASM_V =${LIB1ASMFUNCS:S/$/.vis/}
-SOBJS +=   ${LIB1ASMFUNCS:S/$/.So/}
+SOBJS +=   ${LIB1ASMFUNCS:S/$/.pico/}
 
 ${ASM_T}: ${LIB1ASMSRC} ${.PREFIX}.vis
${CC} -x assembler-with-cpp -c ${CFLAGS} -DL${.PREFIX} \
@@ -327,7 +327,7 @@ CLEANFILES += ${ASM_V} ${ASM_V:R:S/$/.vo
 #
 EH_OBJS_T = ${LIB2ADDEHSTATIC:R:S/$/.o/}
 EH_OBJS_P = ${LIB2ADDEHSTATIC:R:S/$/.po/}
-EH_OBJS_S = ${LIB2ADDEHSHARED:R:S/$/.So/}
+EH_OBJS_S = ${LIB2ADDEHSHARED:R:S/$/.pico/}
 EH_CFLAGS = -fexceptions -D__GLIBC__=3 -DElfW=__ElfN
 .if ${TARGET_CPUARCH} != "riscv64"
 # RISCVTODO: unwinding support
@@ -341,7 +341,7 @@ ${_src:R:S/$/.po/}: ${_src} ${COMMONHDRS
${CC_P} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
 .endfor
 .for _src in ${LIB2ADDEHSHARED:M*.c}
-${_src:R:S/$/.So/}: ${_src} ${COMMONHDRS}
+${_src:R:S/$/.pico/}: ${_src} ${COMMONHDRS}
${CC_S} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
 .endfor
 

Modified: head/gnu/lib/libgcov/Makefile
==
--- head/gnu/lib/libgcov/Makefile   Sat Sep 24 13:44:18 2016
(r306296)
+++ head/gnu/lib/libgcov/Makefile   Sat Sep 24 15:11:27 2016
(r306297)
@@ -35,7 +35,7 @@ SYMS = _gcov _gcov_merge_add _gcov_merge
 OBJS=  ${SYMS:S/$/.o/}
 OBJS_T=${SYMS:S/$/.o/}
 OBJS_P=${SYMS:S/$/.po/}
-OBJS_S=${SYMS:S/$/.So/}
+OBJS_S=${SYMS:S/$/.pico/}
 
 #---
 #

Modified: head/lib/libedit/Makefile
==
--- head/lib/libedit/Makefile   Sat Sep 24 13:44:18 2016(r306296)
+++ head/lib/libedit/Makefile   Sat Sep 24 15:11:27 2016(r306297)
@@ -76,7 +76,7 @@ historyn.c: makelist Makefile
sh ${.CURDIR}/makelist -n history.c > ${.TARGET}
 
 # minimal dependency to make "make depend" optional
-editline.o editline.po editline.So editline.ln:\
+editline.o editline.po editline.pico editline.ln:  \
common.h emacs.h fcns.c fcns.h help.c help.h vi.h
 
 tc1.o: ${.CURDIR}/TEST/tc1.c

Modified: head/lib/libprocstat/Makefile
==
--- head/lib/libprocstat/Makefile   Sat Sep 24 13:44:18 2016
(r306296)
+++ head/lib/libprocstat/Makefile   Sat Sep 24 15:11:27 2016
(r306297)
@@ -58,13 +58,13 @@ MLINKS+=libprocstat.3 procstat_close.3 \
 .if ${MK_CDDL} != "no"
 CFLAGS+=   -DLIBPROCSTAT_ZFS
 OBJS+= zfs/zfs.o
-SOBJS+=zfs/zfs.So
+SOBJS+=zfs/zfs.pico
 POBJS+=  

svn commit: r305855 - head/lib/libc/stdlib

2016-09-15 Thread Marcel Moolenaar
Author: marcel
Date: Fri Sep 16 03:04:48 2016
New Revision: 305855
URL: https://svnweb.freebsd.org/changeset/base/305855

Log:
  When MAKEOBJDIRPREFIX points to a case-insensitive file system, the
  build can break when different source files create the same object
  files (case-insensitivity speaking).  This is the case for _Exit.c
  and _exit.s.  Compile _Exit.c as C99_Exit.c
  
  Reviewed by:  sjg@
  MFC after:completion
  Sponsored by: Bracket Computing
  Differential Revision:https://reviews.freebsd.org/D7893

Modified:
  head/lib/libc/stdlib/Makefile.inc

Modified: head/lib/libc/stdlib/Makefile.inc
==
--- head/lib/libc/stdlib/Makefile.inc   Fri Sep 16 01:38:22 2016
(r305854)
+++ head/lib/libc/stdlib/Makefile.inc   Fri Sep 16 03:04:48 2016
(r305855)
@@ -4,7 +4,7 @@
 # machine-independent stdlib sources
 .PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/stdlib ${LIBC_SRCTOP}/stdlib
 
-MISRCS+=_Exit.c a64l.c abort.c abs.c atexit.c atof.c atoi.c atol.c atoll.c \
+MISRCS+=C99_Exit.c a64l.c abort.c abs.c atexit.c atof.c atoi.c atol.c atoll.c \
bsearch.c cxa_thread_atexit.c div.c exit.c getenv.c getopt.c 
getopt_long.c \
getsubopt.c hcreate.c hcreate_r.c hdestroy_r.c heapsort.c heapsort_b.c \
hsearch_r.c imaxabs.c imaxdiv.c \
@@ -16,6 +16,13 @@ MISRCS+=_Exit.c a64l.c abort.c abs.c ate
strtol.c strtoll.c strtoq.c strtoul.c strtonum.c strtoull.c \
 strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c
 
+# Work around an issue on case-insensitive file systems.
+# libc has both _Exit.c and _exit.s and they both yield
+# _exit.o (case insensitively speaking).
+CLEANFILES+=C99_Exit.c
+C99_Exit.c: ${LIBC_SRCTOP}/stdlib/_Exit.c .NOMETA
+   ln -sf ${.ALLSRC} ${.TARGET}
+
 SYM_MAPS+= ${LIBC_SRCTOP}/stdlib/Symbol.map
 
 # machine-dependent stdlib sources
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r296103 - head/sys/amd64/vmm

2016-02-26 Thread Marcel Moolenaar
Author: marcel
Date: Fri Feb 26 16:18:47 2016
New Revision: 296103
URL: https://svnweb.freebsd.org/changeset/base/296103

Log:
  Bump VM_MAX_MEMSEGS from 2 to 3 to match the number of VM segment
  identifiers present in vmmapi.h. In particular, it's now possible
  to create a VM_FRAMEBUFFER segment.

Modified:
  head/sys/amd64/vmm/vmm.c

Modified: head/sys/amd64/vmm/vmm.c
==
--- head/sys/amd64/vmm/vmm.cFri Feb 26 16:15:02 2016(r296102)
+++ head/sys/amd64/vmm/vmm.cFri Feb 26 16:18:47 2016(r296103)
@@ -121,7 +121,7 @@ struct mem_seg {
boolsysmem;
struct vm_object *object;
 };
-#defineVM_MAX_MEMSEGS  2
+#defineVM_MAX_MEMSEGS  3
 
 struct mem_map {
vm_paddr_t  gpa;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r296102 - head/usr.sbin/bhyveload

2016-02-26 Thread Marcel Moolenaar
Author: marcel
Date: Fri Feb 26 16:15:02 2016
New Revision: 296102
URL: https://svnweb.freebsd.org/changeset/base/296102

Log:
  Add option -C to have the guest memory included in core files.
  This aids in debugging OS loaders.

Modified:
  head/usr.sbin/bhyveload/bhyveload.8
  head/usr.sbin/bhyveload/bhyveload.c

Modified: head/usr.sbin/bhyveload/bhyveload.8
==
--- head/usr.sbin/bhyveload/bhyveload.8 Fri Feb 26 16:12:20 2016
(r296101)
+++ head/usr.sbin/bhyveload/bhyveload.8 Fri Feb 26 16:15:02 2016
(r296102)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 7, 2015
+.Dd February 26, 2016
 .Dt BHYVELOAD 8
 .Os
 .Sh NAME
@@ -35,6 +35,7 @@
 guest inside a bhyve virtual machine
 .Sh SYNOPSIS
 .Nm
+.Op Fl C
 .Op Fl S
 .Op Fl c Ar cons-dev
 .Op Fl d Ar disk-path
@@ -125,6 +126,12 @@ respectively.
 The default value of
 .Ar mem-size
 is 256M.
+.It Fl C
+Include guest memory in the core file when
+.Nm
+dumps core.
+This is intended for debugging an OS loader as it allows inspection of
+the guest memory.
 .It Fl S
 Wire guest memory.
 .El

Modified: head/usr.sbin/bhyveload/bhyveload.c
==
--- head/usr.sbin/bhyveload/bhyveload.c Fri Feb 26 16:12:20 2016
(r296101)
+++ head/usr.sbin/bhyveload/bhyveload.c Fri Feb 26 16:15:02 2016
(r296102)
@@ -674,7 +674,7 @@ main(int argc, char** argv)
consin_fd = STDIN_FILENO;
consout_fd = STDOUT_FILENO;
 
-   while ((opt = getopt(argc, argv, "Sc:d:e:h:l:m:")) != -1) {
+   while ((opt = getopt(argc, argv, "CSc:d:e:h:l:m:")) != -1) {
switch (opt) {
case 'c':
error = altcons_open(optarg);
@@ -709,6 +709,9 @@ main(int argc, char** argv)
if (error != 0)
errx(EX_USAGE, "Invalid memsize '%s'", optarg);
break;
+   case 'C':
+   memflags |= VM_MEM_F_INCORE;
+   break;
case 'S':
memflags |= VM_MEM_F_WIRED;
break;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r296101 - head/usr.sbin/bhyveload

2016-02-26 Thread Marcel Moolenaar
Author: marcel
Date: Fri Feb 26 16:12:20 2016
New Revision: 296101
URL: https://svnweb.freebsd.org/changeset/base/296101

Log:
  Support version 4 of the userboot structure by implementing the
  vm_set_register() and vm_set_desc() callbacks.

Modified:
  head/usr.sbin/bhyveload/bhyveload.c

Modified: head/usr.sbin/bhyveload/bhyveload.c
==
--- head/usr.sbin/bhyveload/bhyveload.c Fri Feb 26 16:04:47 2016
(r296100)
+++ head/usr.sbin/bhyveload/bhyveload.c Fri Feb 26 16:12:20 2016
(r296101)
@@ -542,6 +542,21 @@ cb_getenv(void *arg, int num)
return (NULL);
 }
 
+static int
+cb_vm_set_register(void *arg, int vcpu, int reg, uint64_t val)
+{
+
+   return (vm_set_register(ctx, vcpu, reg, val));
+}
+
+static int
+cb_vm_set_desc(void *arg, int vcpu, int reg, uint64_t base, u_int limit,
+u_int access)
+{
+
+   return (vm_set_desc(ctx, vcpu, reg, base, limit, access));
+}
+
 static struct loader_callbacks cb = {
.getc = cb_getc,
.putc = cb_putc,
@@ -571,6 +586,10 @@ static struct loader_callbacks cb = {
.getmem = cb_getmem,
 
.getenv = cb_getenv,
+
+   /* Version 4 additions */
+   .vm_set_register = cb_vm_set_register,
+   .vm_set_desc = cb_vm_set_desc,
 };
 
 static int
@@ -765,7 +784,7 @@ main(int argc, char** argv)
addenv("smbios.bios.vendor=BHYVE");
addenv("boot_serial=1");
 
-   func(, NULL, USERBOOT_VERSION_3, ndisks);
+   func(, NULL, USERBOOT_VERSION_4, ndisks);
 
free(loader);
return (0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r296099 - head/sys/boot/userboot

2016-02-26 Thread Marcel Moolenaar
Author: marcel
Date: Fri Feb 26 16:00:16 2016
New Revision: 296099
URL: https://svnweb.freebsd.org/changeset/base/296099

Log:
  Add vm_set_register() and vm_set_desc() callbacks. These callbacks
  translate directly into calls to their namesake API functions in
  libvmmapi.
  
  It is an improvement over the existing setreg(), setmsr(), setcr()
  setgdt() and exec() callbacks in that the new additions give full
  control and don't assume we're booting FreeBSD, like exec() and
  don't assume one only wants to set the value of RSP, like setreg().

Modified:
  head/sys/boot/userboot/userboot.h

Modified: head/sys/boot/userboot/userboot.h
==
--- head/sys/boot/userboot/userboot.h   Fri Feb 26 15:54:34 2016
(r296098)
+++ head/sys/boot/userboot/userboot.h   Fri Feb 26 16:00:16 2016
(r296099)
@@ -34,6 +34,14 @@
 #defineUSERBOOT_VERSION_3  3
 
 /*
+ * Version 4 added more generic callbacks for setting up
+ * registers and descriptors. The callback structure is
+ * backward compatible (new callbacks have been added at
+ * the tail end).
+ */
+#defineUSERBOOT_VERSION_4  4
+
+/*
  * Exit codes from the loader
  */
 #defineUSERBOOT_EXIT_QUIT  1
@@ -195,4 +203,11 @@ struct loader_callbacks {
 * each invocation will add 1 to the previous value of 'num'.
 */
const char *(*getenv)(void *arg, int num);
+
+   /*
+* Version 4 additions.
+*/
+   int (*vm_set_register)(void *arg, int vcpu, int reg, uint64_t val);
+   int (*vm_set_desc)(void *arg, int vcpu, int reg, uint64_t base,
+   u_int limit, u_int access);
 };
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r296097 - head/sys/boot/userboot/userboot

2016-02-26 Thread Marcel Moolenaar
Author: marcel
Date: Fri Feb 26 15:52:55 2016
New Revision: 296097
URL: https://svnweb.freebsd.org/changeset/base/296097

Log:
  Check that the userboot version is at least 3, rather than
  3 exactly. The structure may be of a newer version and as
  long as it is backward compatible with 3, we can work with
  it.
  
  While here: whitespace nits.

Modified:
  head/sys/boot/userboot/userboot/main.c

Modified: head/sys/boot/userboot/userboot/main.c
==
--- head/sys/boot/userboot/userboot/main.c  Fri Feb 26 15:46:14 2016
(r296096)
+++ head/sys/boot/userboot/userboot/main.c  Fri Feb 26 15:52:55 2016
(r296097)
@@ -43,6 +43,7 @@ static void userboot_zfs_probe(void);
 static int userboot_zfs_found;
 #endif
 
+/* Minimum version required */
 #defineUSERBOOT_VERSIONUSERBOOT_VERSION_3
 
 #defineMALLOCSZ(10*1024*1024)
@@ -64,7 +65,7 @@ void
 delay(int usec)
 {
 
-CALLBACK(delay, usec);
+   CALLBACK(delay, usec);
 }
 
 void
@@ -82,11 +83,11 @@ loader_main(struct loader_callbacks *cb,
const char *var;
int i;
 
-if (version != USERBOOT_VERSION)
-abort();
+   if (version < USERBOOT_VERSION)
+   abort();
 
callbacks = cb;
-callbacks_arg = arg;
+   callbacks_arg = arg;
userboot_disk_maxunit = ndisks;
 
/*
@@ -95,9 +96,9 @@ loader_main(struct loader_callbacks *cb,
 */
setheap((void *)mallocbuf, (void *)(mallocbuf + sizeof(mallocbuf)));
 
-/*
- * Hook up the console
- */
+   /*
+* Hook up the console
+*/
cons_probe();
 
printf("\n");
@@ -192,9 +193,9 @@ extract_currdev(void)
}
 
env_setenv("currdev", EV_VOLATILE, userboot_fmtdev(),
-userboot_setcurrdev, env_nounset);
+   userboot_setcurrdev, env_nounset);
env_setenv("loaddev", EV_VOLATILE, userboot_fmtdev(),
-env_noset, env_nounset);
+   env_noset, env_nounset);
 }
 
 #if defined(USERBOOT_ZFS_SUPPORT)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r289044 - head/lib/libstand

2015-10-08 Thread Marcel Moolenaar
Author: marcel
Date: Thu Oct  8 17:59:05 2015
New Revision: 289044
URL: https://svnweb.freebsd.org/changeset/base/289044

Log:
  If we can't open the file, skip devclose() for the exclusive_file_system
  case. We never called devopen(), so we know there's nothing to close.

Modified:
  head/lib/libstand/open.c

Modified: head/lib/libstand/open.c
==
--- head/lib/libstand/open.cThu Oct  8 17:55:53 2015(r289043)
+++ head/lib/libstand/open.cThu Oct  8 17:59:05 2015(r289044)
@@ -114,7 +114,7 @@ open(const char *fname, int mode)
error = (fs->fo_open)(fname, f);
if (error == 0)
goto ok;
-   goto fail;
+   goto err;
 }
 
 error = devopen(f, fname, );
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r289001 - in head: share/examples/bhyve usr.sbin/bhyveload

2015-10-07 Thread Marcel Moolenaar
Author: marcel
Date: Thu Oct  8 02:28:22 2015
New Revision: 289001
URL: https://svnweb.freebsd.org/changeset/base/289001

Log:
  Add option -l for specifying which OS loader to dlopen(3). By default
  this is /boot/userboot.so. This option allows for the development and
  use of other OS loaders.

Modified:
  head/share/examples/bhyve/vmrun.sh
  head/usr.sbin/bhyveload/bhyveload.8
  head/usr.sbin/bhyveload/bhyveload.c

Modified: head/share/examples/bhyve/vmrun.sh
==
--- head/share/examples/bhyve/vmrun.sh  Thu Oct  8 01:17:45 2015
(r289000)
+++ head/share/examples/bhyve/vmrun.sh  Thu Oct  8 02:28:22 2015
(r289001)
@@ -48,8 +48,8 @@ usage() {
 
echo "Usage: vmrun.sh [-ahi] [-c ] [-C ] [-d ]"
echo "[-e 

Re: svn commit: r287934 - head/sys/boot/efi/loader

2015-09-24 Thread Marcel Moolenaar
> 
> The other approach I suggested earlier is to make the kernel relocatable
> (and allow the module metadata to be anywhere and live in a chain instead
> of an array) so that we can just load things wherever and leave them there
> without having to relocate.

For ia64 I linked the kernel against a virtual address. The loader
could simply allocate EFI memory as needed, and not worry about
its location. It would map that into what I called the “pre-boot
virtual address space”. When booting the kernel, the loader only
had to pass the physical address and size of the page table (the
virtual address was fixed).

With a variable size the loader would start off with a single 4KB
page table and it would grow it as needed to some arbitrary max.
The page size for the pre-boot virtual address space was 64KB (to
match the maximum alignment of segments that the toolchain allowed).

With more than 700MB of pre-boot virtual address space, one could
preload and entire installation CD if willing to wait for it being
loaded. No need to set memory aside and hope things fit...

As a nice plus: linking against a virtual address allows copying
the kernel text across the memory domains and always have it run
locally to CPUs in NUMA configurations.

--
Marcel Moolenaar
mar...@xcllnt.net



signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r287538 - head/sys/boot/efi/loader/arch/amd64

2015-09-07 Thread Marcel Moolenaar
Author: marcel
Date: Mon Sep  7 17:56:49 2015
New Revision: 287538
URL: https://svnweb.freebsd.org/changeset/base/287538

Log:
  As expected, things aren't as simple as hoped. Consequently, we have
  no option but to use the smbios information to fill in the blanks.
  It's a good thing UGA is a protocol of the past and GOP has all the
  info we need.
  
  Anyway, the logic has been tweaked a little to get the easier bits
  of information up front. This includes the resolution and the frame
  buffer address. Then we look at the smbios information and define
  expected values as well as the missing bits (frame buffer offset and
  stride). If the values obtained match the expect values, we fill in
  the blanks and return. Otherwise we use the existing detection logic
  to figure it out.
  
  Rename the environment variables from uga_framebuffer abd uga_stride
  to hw.efifb.address and hw.efifb.stride. The latter names are more
  in line with other variable names.
  
  We currently have hardcoded settings for:
  1.  Mid-2007 iMac (iMac7,1)
  2.  Late-2007 MacBook (MacBook3,1)

Modified:
  head/sys/boot/efi/loader/arch/amd64/framebuffer.c

Modified: head/sys/boot/efi/loader/arch/amd64/framebuffer.c
==
--- head/sys/boot/efi/loader/arch/amd64/framebuffer.c   Mon Sep  7 16:44:28 
2015(r287537)
+++ head/sys/boot/efi/loader/arch/amd64/framebuffer.c   Mon Sep  7 17:56:49 
2015(r287538)
@@ -269,8 +269,10 @@ efifb_from_uga(struct efi_fb *efifb, EFI
EFI_PCI_IO_PROTOCOL *pciio;
char *ev, *p;
EFI_STATUS status;
-   ssize_t ofs;
-   uint32_t np, horiz, vert, depth, refresh;
+   ssize_t offset;
+   uint64_t fbaddr, fbsize;
+   uint32_t horiz, vert, stride;
+   uint32_t np, depth, refresh;
 
status = uga->GetMode(uga, , , , );
if (EFI_ERROR(status))
@@ -285,6 +287,63 @@ efifb_from_uga(struct efi_fb *efifb, EFI
efifb_mask_from_pixfmt(efifb, PixelBlueGreenRedReserved8BitPerColor,
NULL);
 
+   /* pciio can be NULL on return! */
+   pciio = efifb_uga_get_pciio();
+
+   /* Try to find the frame buffer. */
+   status = efifb_uga_locate_framebuffer(pciio, >fb_addr,
+   >fb_size);
+   if (EFI_ERROR(status)) {
+   efifb->fb_addr = 0;
+   efifb->fb_size = 0;
+   }
+
+   /*
+* There's no reliable way to detect the frame buffer or the
+* offset within the frame buffer of the visible region, nor
+* the stride. Our only option is to look at the system and
+* fill in the blanks based on that. Luckily, UGA was mostly
+* only used on Apple hardware. 
+*/
+   offset = -1;
+   ev = getenv("smbios.system.maker");
+   if (ev != NULL && !strcmp(ev, "Apple Inc.")) {
+   ev = getenv("smbios.system.product");
+   if (ev != NULL && !strcmp(ev, "iMac7,1")) {
+   /* These are the expected values we should have. */
+   horiz = 1680;
+   vert = 1050;
+   fbaddr = 0xc000;
+   /* These are the missing bits. */
+   offset = 0x1;
+   stride = 1728;
+   } else if (ev != NULL && !strcmp(ev, "MacBook3,1")) {
+   /* These are the expected values we should have. */
+   horiz = 1280;
+   vert = 800;
+   fbaddr = 0xc000;
+   /* These are the missing bits. */
+   offset = 0x0;
+   stride = 2048;
+   }
+   }
+
+   /*
+* If this is hardware we know, make sure that it looks familiar
+* before we accept our hardcoded values.
+*/
+   if (offset >= 0 && efifb->fb_width == horiz &&
+   efifb->fb_height == vert && efifb->fb_addr == fbaddr) {
+   efifb->fb_addr += offset;
+   efifb->fb_size -= offset;
+   efifb->fb_stride = stride;
+   return (0);
+   } else if (offset >= 0) {
+   printf("Hardware make/model known, but graphics not "
+   "as expected.\n");
+   printf("Console may not work!\n");
+   }
+
/*
 * The stride is equal or larger to the width. Often it's the
 * next larger power of two. We'll start with that...
@@ -298,16 +357,11 @@ efifb_from_uga(struct efi_fb *efifb, EFI
}
} while (np);
 
-   /* pciio can be NULL on return! */
-   pciio = efifb_uga_get_pciio();
-
-   ev = getenv("uga_framebuffer");
+   ev = getenv("hw.efifb.address");
if (ev == NULL) {
-   /* Try to find the frame buffer. */
-   status = efifb_uga_locate_framebuffer(pciio, >fb_addr,
-   >fb_size);
-   if 

svn commit: r287489 - head/sys/boot/efi/loader/arch/amd64

2015-09-05 Thread Marcel Moolenaar
Author: marcel
Date: Sat Sep  5 18:24:51 2015
New Revision: 287489
URL: https://svnweb.freebsd.org/changeset/base/287489

Log:
  Auto-detect the UGA frame buffer and stride on a MacBook. We're
  striking a delicate balance between exhaustive searching and
  banking on assumptions. The environment variables can be used
  as a fall-back anyway. With this change, all known and tested
  Macs with only UGA should have a working console out of the
  box... for now...

Modified:
  head/sys/boot/efi/loader/arch/amd64/framebuffer.c

Modified: head/sys/boot/efi/loader/arch/amd64/framebuffer.c
==
--- head/sys/boot/efi/loader/arch/amd64/framebuffer.c   Sat Sep  5 17:34:49 
2015(r287488)
+++ head/sys/boot/efi/loader/arch/amd64/framebuffer.c   Sat Sep  5 18:24:51 
2015(r287489)
@@ -175,7 +175,7 @@ efifb_uga_find_pixel(EFI_UGA_DRAW_PROTOC
ofs += count;
size -= count;
}
-   printf("Couldn't find the pixel");
+   printf("No change detected in frame buffer");
 
  fail:
printf(" -- error %lu\n", status & ~EFI_ERROR_MASK);
@@ -218,18 +218,20 @@ efifb_uga_get_pciio(void)
 }
 
 static EFI_STATUS
-efifb_uga_detect_framebuffer(EFI_UGA_DRAW_PROTOCOL *uga,
-EFI_PCI_IO_PROTOCOL *pciio, uint64_t *addrp, uint64_t *sizep)
+efifb_uga_locate_framebuffer(EFI_PCI_IO_PROTOCOL *pciio, uint64_t *addrp,
+uint64_t *sizep)
 {
uint8_t *resattr;
-   uint64_t a, addr, s, size;
-   ssize_t ofs;
+   uint64_t addr, size;
EFI_STATUS status;
u_int bar;
 
+   if (pciio == NULL)
+   return (EFI_DEVICE_ERROR);
+
/* Attempt to get the frame buffer address (imprecise). */
-   addr = 0;
-   size = 0;
+   *addrp = 0;
+   *sizep = 0;
for (bar = 0; bar < 6; bar++) {
status = pciio->GetBarAttributes(pciio, bar, NULL,
(void **));
@@ -238,43 +240,27 @@ efifb_uga_detect_framebuffer(EFI_UGA_DRA
/* XXX magic offsets and constants. */
if (resattr[0] == 0x87 && resattr[3] == 0) {
/* 32-bit address space descriptor (MEMIO) */
-   a = le32dec(resattr + 10);
-   s = le32dec(resattr + 22);
+   addr = le32dec(resattr + 10);
+   size = le32dec(resattr + 22);
} else if (resattr[0] == 0x8a && resattr[3] == 0) {
/* 64-bit address space descriptor (MEMIO) */
-   a = le64dec(resattr + 14);
-   s = le64dec(resattr + 38);
+   addr = le64dec(resattr + 14);
+   size = le64dec(resattr + 38);
} else {
-   a = 0;
-   s = 0;
+   addr = 0;
+   size = 0;
}
BS->FreePool(resattr);
-   if (a == 0 || s == 0)
+   if (addr == 0 || size == 0)
continue;
 
/* We assume the largest BAR is the frame buffer. */
-   if (s > size) {
-   addr = a;
-   size = s;
+   if (size > *sizep) {
+   *addrp = addr;
+   *sizep = size;
}
}
-   if (addr == 0 || size == 0)
-   return (EFI_DEVICE_ERROR);
-
-   /*
-* The visible part of the frame buffer may not start at offset
-* 0, so try to detect it.
-*/
-   ofs = efifb_uga_find_pixel(uga, 0, pciio, addr, size);
-   if (ofs == -1)
-   return (EFI_NO_RESPONSE);
-
-   addr += ofs;
-   size -= ofs;
-
-   *addrp = addr;
-   *sizep = size;
-   return (0);
+   return ((*addrp == 0 || *sizep == 0) ? EFI_DEVICE_ERROR : 0);
 }
 
 static int
@@ -284,29 +270,75 @@ efifb_from_uga(struct efi_fb *efifb, EFI
char *ev, *p;
EFI_STATUS status;
ssize_t ofs;
-   uint32_t horiz, vert, depth, refresh;
+   uint32_t np, horiz, vert, depth, refresh;
 
status = uga->GetMode(uga, , , , );
if (EFI_ERROR(status))
return (1);
efifb->fb_height = vert;
efifb->fb_width = horiz;
+   /* Paranoia... */
+   if (efifb->fb_height == 0 || efifb->fb_width == 0)
+   return (1);
+
+   /* The color masks are fixed AFAICT. */
efifb_mask_from_pixfmt(efifb, PixelBlueGreenRedReserved8BitPerColor,
NULL);
 
+   /*
+* The stride is equal or larger to the width. Often it's the
+* next larger power of two. We'll start with that...
+*/
+   efifb->fb_stride = efifb->fb_width;
+   do {
+   np = efifb->fb_stride & (efifb->fb_stride - 1);
+   if (np) {
+   efifb->fb_stride |= (np - 1);
+ 

svn commit: r287475 - head/sys/boot/efi/loader/arch/amd64

2015-09-04 Thread Marcel Moolenaar
Author: marcel
Date: Sat Sep  5 03:27:23 2015
New Revision: 287475
URL: https://svnweb.freebsd.org/changeset/base/287475

Log:
  My MacBook has UGA only, but we fail to detect any changes
  in the frame buffer when we flip pixels. Allow the detection
  to be bypassed by setting the uga_framebuffer and uga_stride
  variables. The kernel console works fine even when we can't
  detect pixel changes in the frame buffer, which indicates
  that the problem could be with reading from the frame buffer
  and not writing to it.

Modified:
  head/sys/boot/efi/loader/arch/amd64/framebuffer.c

Modified: head/sys/boot/efi/loader/arch/amd64/framebuffer.c
==
--- head/sys/boot/efi/loader/arch/amd64/framebuffer.c   Sat Sep  5 01:00:02 
2015(r287474)
+++ head/sys/boot/efi/loader/arch/amd64/framebuffer.c   Sat Sep  5 03:27:23 
2015(r287475)
@@ -183,29 +183,24 @@ efifb_uga_find_pixel(EFI_UGA_DRAW_PROTOC
return (-1);
 }
 
-static EFI_STATUS
-efifb_uga_detect_framebuffer(EFI_UGA_DRAW_PROTOCOL *uga,
-EFI_PCI_IO_PROTOCOL **pciiop, uint64_t *addrp, uint64_t *sizep)
+static EFI_PCI_IO_PROTOCOL *
+efifb_uga_get_pciio(void)
 {
EFI_PCI_IO_PROTOCOL *pciio;
EFI_HANDLE *buf, *hp;
-   uint8_t *resattr;
-   uint64_t a, addr, s, size;
-   ssize_t ofs;
EFI_STATUS status;
UINTN bufsz;
-   u_int bar;
 
/* Get all handles that support the UGA protocol. */
bufsz = 0;
status = BS->LocateHandle(ByProtocol, _guid, NULL, , NULL);
if (status != EFI_BUFFER_TOO_SMALL)
-   return (status);
+   return (NULL);
buf = malloc(bufsz);
status = BS->LocateHandle(ByProtocol, _guid, NULL, , buf);
if (status != EFI_SUCCESS) {
free(buf);
-   return (status);
+   return (NULL);
}
bufsz /= sizeof(EFI_HANDLE);
 
@@ -213,12 +208,24 @@ efifb_uga_detect_framebuffer(EFI_UGA_DRA
pciio = NULL;
for (hp = buf; hp < buf + bufsz; hp++) {
status = BS->HandleProtocol(*hp, _guid, (void **));
-   if (status == EFI_SUCCESS)
-   break;
+   if (status == EFI_SUCCESS) {
+   free(buf);
+   return (pciio);
+   }
}
free(buf);
-   if (status != EFI_SUCCESS || pciio == NULL)
-   return (EFI_NOT_FOUND);
+   return (NULL);
+}
+
+static EFI_STATUS
+efifb_uga_detect_framebuffer(EFI_UGA_DRAW_PROTOCOL *uga,
+EFI_PCI_IO_PROTOCOL *pciio, uint64_t *addrp, uint64_t *sizep)
+{
+   uint8_t *resattr;
+   uint64_t a, addr, s, size;
+   ssize_t ofs;
+   EFI_STATUS status;
+   u_int bar;
 
/* Attempt to get the frame buffer address (imprecise). */
addr = 0;
@@ -265,7 +272,6 @@ efifb_uga_detect_framebuffer(EFI_UGA_DRA
addr += ofs;
size -= ofs;
 
-   *pciiop = pciio;
*addrp = addr;
*sizep = size;
return (0);
@@ -275,6 +281,7 @@ static int
 efifb_from_uga(struct efi_fb *efifb, EFI_UGA_DRAW_PROTOCOL *uga)
 {
EFI_PCI_IO_PROTOCOL *pciio;
+   char *ev, *p;
EFI_STATUS status;
ssize_t ofs;
uint32_t horiz, vert, depth, refresh;
@@ -287,18 +294,37 @@ efifb_from_uga(struct efi_fb *efifb, EFI
efifb_mask_from_pixfmt(efifb, PixelBlueGreenRedReserved8BitPerColor,
NULL);
 
-   /* Try and find the frame buffer. */
-   status = efifb_uga_detect_framebuffer(uga, , >fb_addr,
-   >fb_size);
-   if (EFI_ERROR(status))
+   pciio = efifb_uga_get_pciio();
+   if (pciio == NULL)
return (1);
 
-   /* Try and detect the stride. */
-   ofs = efifb_uga_find_pixel(uga, 1, pciio, efifb->fb_addr,
-   efifb->fb_size);
-   if (ofs == -1)
-   return (1);
-   efifb->fb_stride = ofs >> 2;
+   ev = getenv("uga_framebuffer");
+   if (ev == NULL) {
+   /* Try to find the frame buffer. */
+   status = efifb_uga_detect_framebuffer(uga, pciio,
+   >fb_addr, >fb_size);
+   if (EFI_ERROR(status))
+   return (1);
+   } else {
+   efifb->fb_size = horiz * vert * 4;
+   efifb->fb_addr = strtoul(ev, , 0);
+   if (*p != '\0')
+   return (1);
+   }
+
+   ev = getenv("uga_stride");
+   if (ev == NULL) {
+   /* Try to detect the stride. */
+   ofs = efifb_uga_find_pixel(uga, 1, pciio, efifb->fb_addr,
+   efifb->fb_size);
+   if (ofs == -1)
+   return (1);
+   efifb->fb_stride = ofs >> 2;
+   } else {
+   efifb->fb_stride = strtoul(ev, , 0);
+   if (*p != '\0')
+   return (1);
+   }
return (0);
 }
 

svn commit: r287422 - head/sys/boot/efi/loader/arch/amd64

2015-09-02 Thread Marcel Moolenaar
Author: marcel
Date: Thu Sep  3 04:35:17 2015
New Revision: 287422
URL: https://svnweb.freebsd.org/changeset/base/287422

Log:
  For UGA, the frame buffer address obtained by scanning the
  PCI BARs does not necessarily correspond to the upper-left
  most pixel. Scan the frame buffer for which byte changed
  when changing the pixel at (0,0).
  
  Use the same technique to determine the stride. Except for
  changing the pixel at (0,0), we change the pixel at (0,1).
  
  PR:   202730
  Tested by:hartzell (at) alerce.com

Modified:
  head/sys/boot/efi/loader/arch/amd64/framebuffer.c

Modified: head/sys/boot/efi/loader/arch/amd64/framebuffer.c
==
--- head/sys/boot/efi/loader/arch/amd64/framebuffer.c   Thu Sep  3 03:58:59 
2015(r287421)
+++ head/sys/boot/efi/loader/arch/amd64/framebuffer.c   Thu Sep  3 04:35:17 
2015(r287422)
@@ -43,6 +43,21 @@ static EFI_GUID gop_guid = EFI_GRAPHICS_
 static EFI_GUID pciio_guid = EFI_PCI_IO_PROTOCOL_GUID;
 static EFI_GUID uga_guid = EFI_UGA_DRAW_PROTOCOL_GUID;
 
+static u_int
+efifb_color_depth(struct efi_fb *efifb)
+{
+   uint32_t mask;
+   u_int depth;
+
+   mask = efifb->fb_mask_red | efifb->fb_mask_green |
+   efifb->fb_mask_blue | efifb->fb_mask_reserved;
+   if (mask == 0)
+   return (0);
+   for (depth = 1; mask != 1; depth++)
+   mask >>= 1;
+   return (depth);
+}
+
 static int
 efifb_mask_from_pixfmt(struct efi_fb *efifb, EFI_GRAPHICS_PIXEL_FORMAT pixfmt,
 EFI_PIXEL_BITMASK *pixinfo)
@@ -92,83 +107,198 @@ efifb_from_gop(struct efi_fb *efifb, EFI
return (result);
 }
 
-static int
-efifb_from_uga(struct efi_fb *efifb, EFI_UGA_DRAW_PROTOCOL *uga)
+static ssize_t
+efifb_uga_find_pixel(EFI_UGA_DRAW_PROTOCOL *uga, u_int line,
+EFI_PCI_IO_PROTOCOL *pciio, uint64_t addr, uint64_t size)
+{
+   EFI_UGA_PIXEL pix0, pix1;
+   uint8_t *data1, *data2;
+   size_t count, maxcount = 1024;
+   ssize_t ofs;
+   EFI_STATUS status;
+   u_int idx;
+
+   status = uga->Blt(uga, , EfiUgaVideoToBltBuffer,
+   0, line, 0, 0, 1, 1, 0);
+   if (EFI_ERROR(status)) {
+   printf("UGA BLT operation failed (video->buffer)");
+   return (-1);
+   }
+   pix1.Red = ~pix0.Red;
+   pix1.Green = ~pix0.Green;
+   pix1.Blue = ~pix0.Blue;
+   pix1.Reserved = 0;
+
+   data1 = calloc(maxcount, 2);
+   if (data1 == NULL) {
+   printf("Unable to allocate memory");
+   return (-1);
+   }
+   data2 = data1 + maxcount;
+
+   ofs = 0;
+   while (size > 0) {
+   count = min(size, maxcount);
+
+   status = pciio->Mem.Read(pciio, EfiPciIoWidthUint32,
+   EFI_PCI_IO_PASS_THROUGH_BAR, addr + ofs, count >> 2,
+   data1);
+   if (EFI_ERROR(status)) {
+   printf("Error reading frame buffer (before)");
+   goto fail;
+   }
+   status = uga->Blt(uga, , EfiUgaBltBufferToVideo,
+   0, 0, 0, line, 1, 1, 0);
+   if (EFI_ERROR(status)) {
+   printf("UGA BLT operation failed (modify)");
+   goto fail;
+   }
+   status = pciio->Mem.Read(pciio, EfiPciIoWidthUint32,
+   EFI_PCI_IO_PASS_THROUGH_BAR, addr + ofs, count >> 2,
+   data2);
+   if (EFI_ERROR(status)) {
+   printf("Error reading frame buffer (after)");
+   goto fail;
+   }
+   status = uga->Blt(uga, , EfiUgaBltBufferToVideo,
+   0, 0, 0, line, 1, 1, 0);
+   if (EFI_ERROR(status)) {
+   printf("UGA BLT operation failed (restore)");
+   goto fail;
+   }
+   for (idx = 0; idx < count; idx++) {
+   if (data1[idx] != data2[idx]) {
+   free(data1);
+   return (ofs + (idx & ~3));
+   }
+   }
+   ofs += count;
+   size -= count;
+   }
+   printf("Couldn't find the pixel");
+
+ fail:
+   printf(" -- error %lu\n", status & ~EFI_ERROR_MASK);
+   free(data1);
+   return (-1);
+}
+
+static EFI_STATUS
+efifb_uga_detect_framebuffer(EFI_UGA_DRAW_PROTOCOL *uga,
+EFI_PCI_IO_PROTOCOL **pciiop, uint64_t *addrp, uint64_t *sizep)
 {
-   uint8_t *buf;
EFI_PCI_IO_PROTOCOL *pciio;
-   EFI_HANDLE handle;
+   EFI_HANDLE *buf, *hp;
+   uint8_t *resattr;
+   uint64_t a, addr, s, size;
+   ssize_t ofs;
EFI_STATUS status;
-   UINTN bufofs, bufsz;
-   uint64_t address, length;
-   uint32_t horiz, vert, depth, refresh;
+   UINTN bufsz;
u_int bar;
 
-   status = 

Re: svn commit: r287299 - head/sys/boot/efi/loader/arch/amd64

2015-08-30 Thread Marcel Moolenaar

 On Aug 30, 2015, at 11:27 AM, Rui Paulo rpa...@me.com wrote:
 
 On Sun, 2015-08-30 at 01:40 +, Marcel Moolenaar wrote:
 Author: marcel
 Date: Sun Aug 30 01:39:59 2015
 New Revision: 287299
 URL: https://svnweb.freebsd.org/changeset/base/287299
 
 Log:
  Add a gop command to help diagnose VT efifb problems. The gop
  command has the following sub-commands:
list  - list all possible modes (paged)
get   - return the current mode
set mode- set the current mode to mode
 
 
 This is duplicating the functionality of the `mode' command.  Please
 remove the mode command.

It doesn’t. The mode command works on text modes only. This
command works on the Graphics Output Protocol (GOP) modes.

 
 Also, 'gop' is pretty weird for a command name.  Maybe we can change
 that to something more user friendly?

Maybe.

--
Marcel Moolenaar
mar...@xcllnt.net





signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r287317 - in head/sys/boot/efi: include loader/arch/amd64

2015-08-30 Thread Marcel Moolenaar
Author: marcel
Date: Sun Aug 30 23:58:53 2015
New Revision: 287317
URL: https://svnweb.freebsd.org/changeset/base/287317

Log:
  Add support for the UGA draw protocol. This includes adding a
  command called 'uga' to show whether UGA is implemented by the
  firmware and what the settings are. It also includes filling
  the efi_fb structure from the UGA information when GOP isn't
  implemented by the firmware.
  
  Since UGA does not provide information about the stride, we
  set the stride to the horizontal resolution. This is likely
  not correct and we should determine the stride by trial and
  error. For now, this should show something on the console
  rather than nothing.
  
  Refactor this file to maximize code reuse.
  
  PR:   202730

Added:
  head/sys/boot/efi/include/efipciio.h   (contents, props changed)
  head/sys/boot/efi/include/efiuga.h   (contents, props changed)
Modified:
  head/sys/boot/efi/loader/arch/amd64/framebuffer.c

Added: head/sys/boot/efi/include/efipciio.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/boot/efi/include/efipciio.hSun Aug 30 23:58:53 2015
(r287317)
@@ -0,0 +1,559 @@
+/* $FreeBSD$ */
+/** @file
+  EFI PCI I/O Protocol provides the basic Memory, I/O, PCI configuration, 
+  and DMA interfaces that a driver uses to access its PCI controller.
+
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.BR
+  This program and the accompanying materials  
+  are licensed and made available under the terms and conditions of the BSD 
License 
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php   
 
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN AS IS BASIS,
 
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED. 
+
+**/
+
+#ifndef __PCI_IO_H__
+#define __PCI_IO_H__
+
+///
+/// Global ID for the PCI I/O Protocol
+///
+#define EFI_PCI_IO_PROTOCOL_GUID \
+  { \
+0x4cf5b200, 0x68b8, 0x4ca5, {0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a 
} \
+  }
+
+typedef struct _EFI_PCI_IO_PROTOCOL  EFI_PCI_IO_PROTOCOL;
+
+///
+/// ***
+/// EFI_PCI_IO_PROTOCOL_WIDTH
+/// ***
+///
+typedef enum {
+  EfiPciIoWidthUint8  = 0,
+  EfiPciIoWidthUint16,
+  EfiPciIoWidthUint32,
+  EfiPciIoWidthUint64,
+  EfiPciIoWidthFifoUint8,
+  EfiPciIoWidthFifoUint16,
+  EfiPciIoWidthFifoUint32,
+  EfiPciIoWidthFifoUint64,
+  EfiPciIoWidthFillUint8,
+  EfiPciIoWidthFillUint16,
+  EfiPciIoWidthFillUint32,
+  EfiPciIoWidthFillUint64,
+  EfiPciIoWidthMaximum
+} EFI_PCI_IO_PROTOCOL_WIDTH;
+
+//
+// Complete PCI address generater
+//
+#define EFI_PCI_IO_PASS_THROUGH_BAR   0xff/// Special BAR 
that passes a memory or I/O cycle through unchanged
+#define EFI_PCI_IO_ATTRIBUTE_MASK 0x077f  /// All the 
following I/O and Memory cycles
+#define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO   0x0001  /// I/O cycles 
0x-0x00FF (10 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_ISA_IO   0x0002  /// I/O cycles 
0x0100-0x03FF or greater (10 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO   0x0004  /// I/O cycles 
0x3C6, 0x3C8, 0x3C9 (10 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY   0x0008  /// MEM cycles 
0xA-0xB (24 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_VGA_IO   0x0010  /// I/O cycles 
0x3B0-0x3BB and 0x3C0-0x3DF (10 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO   0x0020  /// I/O cycles 
0x1F0-0x1F7, 0x3F6, 0x3F7 (10 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040  /// I/O cycles 
0x170-0x177, 0x376, 0x377 (10 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080  /// Map a memory 
range so writes are combined
+#define EFI_PCI_IO_ATTRIBUTE_IO   0x0100  /// Enable the I/O 
decode bit in the PCI Config Header
+#define EFI_PCI_IO_ATTRIBUTE_MEMORY   0x0200  /// Enable the 
Memory decode bit in the PCI Config Header
+#define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER   0x0400  /// Enable the DMA 
bit in the PCI Config Header
+#define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED0x0800  /// Map a memory 
range so all r/w accesses are cached
+#define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE   0x1000  /// Disable a 
memory range
+#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE  0x2000  /// Clear for an 
add-in PCI Device
+#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000  /// Clear for a 
physical PCI Option ROM accessed through ROM BAR
+#define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE   0x8000  /// Clear for PCI 
controllers that can not genrate a DAC
+#define 

svn commit: r287299 - head/sys/boot/efi/loader/arch/amd64

2015-08-29 Thread Marcel Moolenaar
Author: marcel
Date: Sun Aug 30 01:39:59 2015
New Revision: 287299
URL: https://svnweb.freebsd.org/changeset/base/287299

Log:
  Add a gop command to help diagnose VT efifb problems. The gop
  command has the following sub-commands:
list- list all possible modes (paged)
get - return the current mode
set mode  - set the current mode to mode

Modified:
  head/sys/boot/efi/loader/arch/amd64/framebuffer.c

Modified: head/sys/boot/efi/loader/arch/amd64/framebuffer.c
==
--- head/sys/boot/efi/loader/arch/amd64/framebuffer.c   Sat Aug 29 20:41:09 
2015(r287298)
+++ head/sys/boot/efi/loader/arch/amd64/framebuffer.c   Sun Aug 30 01:39:59 
2015(r287299)
@@ -29,6 +29,7 @@
 #include sys/cdefs.h
 __FBSDID($FreeBSD$);
 
+#include bootstrap.h
 #include stand.h
 
 #include efi.h
@@ -83,3 +84,97 @@ efi_find_framebuffer(struct efi_fb *efif
}
return (0);
 }
+
+COMMAND_SET(gop, gop, graphics output protocol, command_gop);
+
+static void
+command_gop_display(u_int mode, EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info)
+{
+
+   printf(mode %u: %ux%u, stride=%u, color=, mode,
+   info-HorizontalResolution, info-VerticalResolution,
+   info-PixelsPerScanLine);
+   switch (info-PixelFormat) {
+   case PixelRedGreenBlueReserved8BitPerColor:
+   printf(32-bit (RGB));
+   break;
+   case PixelBlueGreenRedReserved8BitPerColor:
+   printf(32-bit (BGR));
+   break;
+   case PixelBitMask:
+   printf(mask (R=%x, G=%x, B=%x, X=%x),
+   info-PixelInformation.RedMask,
+   info-PixelInformation.GreenMask,
+   info-PixelInformation.BlueMask,
+   info-PixelInformation.ReservedMask);
+   break;
+   case PixelBltOnly:
+   printf(unsupported (blt only));
+   break;
+   default:
+   printf(unsupported (unknown));
+   break;
+   }
+}
+
+static int
+command_gop(int argc, char *argv[])
+{
+   EFI_GRAPHICS_OUTPUT *gop;
+   EFI_STATUS status;
+   u_int mode;
+
+   status = BS-LocateProtocol(gop_guid, NULL, (VOID **)gop);
+   if (EFI_ERROR(status)) {
+   sprintf(command_errbuf, %s: Graphics Output Protocol not 
+   present (error=%lu), argv[0], status  ~EFI_ERROR_MASK);
+   return (CMD_ERROR);
+   }
+
+   if (argc == 1)
+   goto usage;
+
+   if (!strcmp(argv[1], set)) {
+   char *cp;
+
+   if (argc != 3)
+   goto usage;
+   mode = strtol(argv[2], cp, 0);
+   if (cp[0] != '\0') {
+   sprintf(command_errbuf, mode is an integer);
+   return (CMD_ERROR);
+   }
+   status = gop-SetMode(gop, mode);
+   if (EFI_ERROR(status)) {
+   sprintf(command_errbuf, %s: Unable to set mode to 
+   %u (error=%lu), argv[0], mode,
+   status  ~EFI_ERROR_MASK);
+   return (CMD_ERROR);
+   }
+   } else if (!strcmp(argv[1], get)) {
+   command_gop_display(gop-Mode-Mode, gop-Mode-Info);
+   printf(\nframe buffer: address=%jx, size=%lx\n,
+   (uintmax_t)gop-Mode-FrameBufferBase,
+   gop-Mode-FrameBufferSize);
+   } else if (!strcmp(argv[1], list)) {
+   EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info;
+   UINTN infosz;
+
+   pager_open();
+   for (mode = 0; mode  gop-Mode-MaxMode; mode++) {
+   status = gop-QueryMode(gop, mode, infosz, info);
+   if (EFI_ERROR(status))
+   continue;
+   command_gop_display(mode, info);
+   if (pager_output(\n))
+   break;
+   }
+   pager_close();
+   }
+   return (CMD_OK);
+
+ usage:
+   sprintf(command_errbuf, usage: %s [list | get | set mode],
+   argv[0]);
+   return (CMD_ERROR);
+}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r287190 - head/sys/kern

2015-08-26 Thread Marcel Moolenaar
Author: marcel
Date: Thu Aug 27 04:25:27 2015
New Revision: 287190
URL: https://svnweb.freebsd.org/changeset/base/287190

Log:
  An error of -1 from parse_mount() indicates that the specification
  was invalid. Don't trigger a mount failure (which by default means
  a panic), but instead just move on to the next directive in the
  configuration. This typically has us ask for the root mount.
  
  PR:   163245

Modified:
  head/sys/kern/vfs_mountroot.c

Modified: head/sys/kern/vfs_mountroot.c
==
--- head/sys/kern/vfs_mountroot.c   Thu Aug 27 03:47:56 2015
(r287189)
+++ head/sys/kern/vfs_mountroot.c   Thu Aug 27 04:25:27 2015
(r287190)
@@ -791,6 +791,11 @@ retry:
break;
default:
error = parse_mount(conf);
+   if (error == -1) {
+   printf(mountroot: invalid file system 
+   specification.\n);
+   error = 0;
+   }
break;
}
if (error  0)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r287111 - in head: bin/ls bin/ps contrib/libxo contrib/libxo/bin contrib/libxo/doc contrib/libxo/encoder contrib/libxo/encoder/cbor contrib/libxo/encoder/test contrib/libxo/libxo contri...

2015-08-24 Thread Marcel Moolenaar
Author: marcel
Date: Mon Aug 24 16:26:20 2015
New Revision: 287111
URL: https://svnweb.freebsd.org/changeset/base/287111

Log:
  Upgrade libxo to 0.4.5.
  
  Local changes incorporated by 0.4.5: r284340
  Local changes retained: r276260, r282117
  
  Obtained from:https://github.com/Juniper/libxo

Added:
  head/contrib/libxo/INSTALL.md
  head/contrib/libxo/encoder/
  head/contrib/libxo/encoder/Makefile.am   (contents, props changed)
  head/contrib/libxo/encoder/cbor/
  head/contrib/libxo/encoder/cbor/Makefile.am   (contents, props changed)
  head/contrib/libxo/encoder/cbor/enc_cbor.c   (contents, props changed)
  head/contrib/libxo/encoder/test/
  head/contrib/libxo/encoder/test/Makefile.am   (contents, props changed)
  head/contrib/libxo/encoder/test/enc_test.c   (contents, props changed)
  head/contrib/libxo/libxo/add.man
  head/contrib/libxo/libxo/add.man.in   (contents, props changed)
  head/contrib/libxo/libxo/xo_buf.h   (contents, props changed)
  head/contrib/libxo/libxo/xo_config.h
 - copied, changed from r287110, head/contrib/libxo/libxo/xoconfig.h
  head/contrib/libxo/libxo/xo_emit_err.3   (contents, props changed)
  head/contrib/libxo/libxo/xo_encoder.c   (contents, props changed)
  head/contrib/libxo/libxo/xo_encoder.h   (contents, props changed)
  head/contrib/libxo/libxo/xo_humanize.h   (contents, props changed)
  head/contrib/libxo/libxo/xo_message.3   (contents, props changed)
  head/contrib/libxo/libxo/xo_set_syslog_enterprise_id.3   (contents, props 
changed)
  head/contrib/libxo/libxo/xo_syslog.3   (contents, props changed)
  head/contrib/libxo/libxo/xo_syslog.c   (contents, props changed)
  head/contrib/libxo/libxo/xo_wcwidth.h   (contents, props changed)
  head/contrib/libxo/tests/core/saved/test_01.E.err
  head/contrib/libxo/tests/core/saved/test_01.E.out
  head/contrib/libxo/tests/core/saved/test_02.E.err
  head/contrib/libxo/tests/core/saved/test_02.E.out
  head/contrib/libxo/tests/core/saved/test_03.E.err
  head/contrib/libxo/tests/core/saved/test_03.E.out
  head/contrib/libxo/tests/core/saved/test_04.E.err
  head/contrib/libxo/tests/core/saved/test_04.E.out
  head/contrib/libxo/tests/core/saved/test_05.E.err
  head/contrib/libxo/tests/core/saved/test_05.E.out   (contents, props changed)
  head/contrib/libxo/tests/core/saved/test_06.E.err
  head/contrib/libxo/tests/core/saved/test_06.E.out
  head/contrib/libxo/tests/core/saved/test_07.E.err
  head/contrib/libxo/tests/core/saved/test_07.E.out
  head/contrib/libxo/tests/core/saved/test_08.E.err
  head/contrib/libxo/tests/core/saved/test_08.E.out
  head/contrib/libxo/tests/core/saved/test_09.E.err
  head/contrib/libxo/tests/core/saved/test_09.E.out
  head/contrib/libxo/tests/core/saved/test_10.E.err
  head/contrib/libxo/tests/core/saved/test_10.E.out
  head/contrib/libxo/tests/core/saved/test_11.E.err
  head/contrib/libxo/tests/core/saved/test_11.E.out
  head/contrib/libxo/tests/core/saved/test_11.H.err
  head/contrib/libxo/tests/core/saved/test_11.H.out
  head/contrib/libxo/tests/core/saved/test_11.HIPx.err
  head/contrib/libxo/tests/core/saved/test_11.HIPx.out
  head/contrib/libxo/tests/core/saved/test_11.HP.err
  head/contrib/libxo/tests/core/saved/test_11.HP.out
  head/contrib/libxo/tests/core/saved/test_11.J.err
  head/contrib/libxo/tests/core/saved/test_11.J.out
  head/contrib/libxo/tests/core/saved/test_11.JP.err
  head/contrib/libxo/tests/core/saved/test_11.JP.out
  head/contrib/libxo/tests/core/saved/test_11.T.err
  head/contrib/libxo/tests/core/saved/test_11.T.out
  head/contrib/libxo/tests/core/saved/test_11.X.err
  head/contrib/libxo/tests/core/saved/test_11.X.out
  head/contrib/libxo/tests/core/saved/test_11.XP.err
  head/contrib/libxo/tests/core/saved/test_11.XP.out
  head/contrib/libxo/tests/core/test_11.c   (contents, props changed)
  head/contrib/libxo/tests/gettext/
  head/contrib/libxo/tests/gettext/Makefile.am   (contents, props changed)
  head/contrib/libxo/tests/gettext/gt_01.c   (contents, props changed)
  head/contrib/libxo/tests/gettext/gt_01.pot
  head/contrib/libxo/tests/gettext/ldns.pot
  head/contrib/libxo/tests/gettext/po/
  head/contrib/libxo/tests/gettext/po/pig_latin/
  head/contrib/libxo/tests/gettext/po/pig_latin/gt_01.po
  head/contrib/libxo/tests/gettext/po/pig_latin/ldns.po
  head/contrib/libxo/tests/gettext/po/pig_latin/strerror.po
  head/contrib/libxo/tests/gettext/saved/
  head/contrib/libxo/tests/gettext/saved/gt_01.H.err
  head/contrib/libxo/tests/gettext/saved/gt_01.H.out
  head/contrib/libxo/tests/gettext/saved/gt_01.HIPx.err
  head/contrib/libxo/tests/gettext/saved/gt_01.HIPx.out
  head/contrib/libxo/tests/gettext/saved/gt_01.HP.err
  head/contrib/libxo/tests/gettext/saved/gt_01.HP.out
  head/contrib/libxo/tests/gettext/saved/gt_01.J.err
  head/contrib/libxo/tests/gettext/saved/gt_01.J.out
  head/contrib/libxo/tests/gettext/saved/gt_01.JP.err
  head/contrib/libxo/tests/gettext/saved/gt_01.JP.out
  head/contrib/libxo/tests/gettext/saved/gt_01.T.err
  

svn commit: r287114 - head/contrib/libxo/libxo

2015-08-24 Thread Marcel Moolenaar
Author: marcel
Date: Mon Aug 24 17:58:11 2015
New Revision: 287114
URL: https://svnweb.freebsd.org/changeset/base/287114

Log:
  Fix build for architectures that define wchar_t as an unsigned int.
  
  Reported by: bz@

Modified:
  head/contrib/libxo/libxo/xo_wcwidth.h

Modified: head/contrib/libxo/libxo/xo_wcwidth.h
==
--- head/contrib/libxo/libxo/xo_wcwidth.h   Mon Aug 24 17:28:19 2015
(r287113)
+++ head/contrib/libxo/libxo/xo_wcwidth.h   Mon Aug 24 17:58:11 2015
(r287114)
@@ -62,8 +62,8 @@
 #include wchar.h
 
 struct interval {
-  int first;
-  int last;
+  wchar_t first;
+  wchar_t last;
 };
 
 /* auxiliary function for binary search in interval table */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r287111 - in head: bin/ls bin/ps contrib/libxo contrib/libxo/bin contrib/libxo/doc contrib/libxo/encoder contrib/libxo/encoder/cbor contrib/libxo/encoder/test contrib/libxo/libxo contr

2015-08-24 Thread Marcel Moolenaar

 On Aug 24, 2015, at 10:07 AM, Bjoern A. Zeeb b...@freebsd.org wrote:
 
 
 On 24 Aug 2015, at 16:26 , Marcel Moolenaar mar...@freebsd.org wrote:
 
 Author: marcel
 Date: Mon Aug 24 16:26:20 2015
 New Revision: 287111
 URL: https://svnweb.freebsd.org/changeset/base/287111
 
 Log:
 Upgrade libxo to 0.4.5.
 
 Local changes incorporated by 0.4.5: r284340
 Local changes retained: r276260, r282117
 
 Obtained from:   https://github.com/Juniper/libxo
 
 
 arm* broke with a couple of those:
 
 In file included from /scratch/tmp/bz/head.svn/contrib/libxo/libxo/libxo.c:73:
 /scratch/tmp/bz/head.svn/contrib/libxo/libxo/xo_wcwidth.h:76:11: error: 
 comparison of integers of different signs: 'wchar_t' (aka 'unsigned int') and 
 'const int' [-Werror,-Wsign-compare]
  if (ucs  table[0].first || ucs  table[max].last)
  ~~~ ^ ~~

Ugh. Thanks,

--
Marcel Moolenaar
mar...@xcllnt.net





signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r286867 - in head/sys/dev/vt: . hw/fb

2015-08-17 Thread Marcel Moolenaar
Author: marcel
Date: Tue Aug 18 00:47:02 2015
New Revision: 286867
URL: https://svnweb.freebsd.org/changeset/base/286867

Log:
  Support frame buffers that are larger than the default screen
  size as defined by VT_FB_DEFAULT_WIDTH and VT_FB_DEFAULT_HEIGHT
  (at this time 2048x1200). The default is really a max. We cap
  the height and width to those defaults and position the screen
  in the center of the frame buffer.
  
  Ideally we use a bigger font to utility the entire real estate
  that is the frame buffer, but that's seen as an improvement over
  making it work first.
  
  PR:   193745

Modified:
  head/sys/dev/vt/hw/fb/vt_fb.c
  head/sys/dev/vt/vt.h

Modified: head/sys/dev/vt/hw/fb/vt_fb.c
==
--- head/sys/dev/vt/hw/fb/vt_fb.c   Tue Aug 18 00:21:25 2015
(r286866)
+++ head/sys/dev/vt/hw/fb/vt_fb.c   Tue Aug 18 00:47:02 2015
(r286867)
@@ -294,6 +294,7 @@ vt_fb_bitblt_bitmap(struct vt_device *vd
if (mask != NULL  (mask[byte]  bit) == 0)
continue;
o = (y + yi) * info-fb_stride + (x + xi) * bpp;
+   o += vd-vd_transpose;
cc = pattern[byte]  bit ? fgc : bgc;
 
switch(bpp) {
@@ -411,11 +412,16 @@ int
 vt_fb_init(struct vt_device *vd)
 {
struct fb_info *info;
+   u_int margin;
int err;
 
info = vd-vd_softc;
-   vd-vd_height = info-fb_height;
-   vd-vd_width = info-fb_width;
+   vd-vd_height = MIN(VT_FB_DEFAULT_HEIGHT, info-fb_height);
+   margin = (info-fb_height - vd-vd_height)  1;
+   vd-vd_transpose = margin * info-fb_stride;
+   vd-vd_width = MIN(VT_FB_DEFAULT_WIDTH, info-fb_width);
+   margin = (info-fb_width - vd-vd_width)  1;
+   vd-vd_transpose += margin * (info-fb_bpp / NBBY);
vd-vd_video_dev = info-fb_video_dev;
 
if (info-fb_size == 0)

Modified: head/sys/dev/vt/vt.h
==
--- head/sys/dev/vt/vt.hTue Aug 18 00:21:25 2015(r286866)
+++ head/sys/dev/vt/vt.hTue Aug 18 00:47:02 2015(r286867)
@@ -140,6 +140,7 @@ struct vt_device {
uint32_t vd_mstate; /* (?) Mouse state. */
vt_axis_tvd_width;  /* (?) Screen width. */
vt_axis_tvd_height; /* (?) Screen height. */
+   size_t   vd_transpose;  /* (?) Screen offset in FB */
struct mtx   vd_lock;   /* Per-device lock. */
struct cvvd_winswitch;  /* (d) Window switch notify. */
struct callout   vd_timer;  /* (d) Display timer. */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286868 - head/sys/amd64/amd64

2015-08-17 Thread Marcel Moolenaar
Author: marcel
Date: Tue Aug 18 01:53:41 2015
New Revision: 286868
URL: https://svnweb.freebsd.org/changeset/base/286868

Log:
  Add 24 more page table pages we allocate on boot-up. 16MB slop
  is a little tight in and by itself, but severily insufficient
  when one needs to map a large frame buffer as part of console
  initialization. 64MB slop should be enough for a while. As an
  example: a 15 MacBook Pro with retina display needs ~28MB of
  KVA for the frame buffer.
  
  PR:   193745

Modified:
  head/sys/amd64/amd64/pmap.c

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Tue Aug 18 00:47:02 2015(r286867)
+++ head/sys/amd64/amd64/pmap.c Tue Aug 18 01:53:41 2015(r286868)
@@ -699,8 +699,14 @@ nkpt_init(vm_paddr_t addr)
 * pmap_growkernel() will need to allocate page table pages to map
 * the entire 512GB of KVA space which is an unnecessary tax on
 * physical memory.
+*
+* Secondly, device memory mapped as part of setting up the low-
+* level console(s) is taken from KVA, starting at virtual_avail.
+* This is because cninit() is called after pmap_bootstrap() but
+* before vm_init() and pmap_init(). 20MB for a frame buffer is
+* not uncommon.
 */
-   pt_pages += 8;  /* 16MB additional slop for kernel modules */
+   pt_pages += 32; /* 64MB additional slop. */
 #endif
nkpt = pt_pages;
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286808 - head/sys/dev/vt

2015-08-15 Thread Marcel Moolenaar
Author: marcel
Date: Sat Aug 15 15:44:09 2015
New Revision: 286808
URL: https://svnweb.freebsd.org/changeset/base/286808

Log:
  Improve the VT initialization message: have it say what the
  resolution is. For text mode this is the number of columns
  by the number of rows. Include the name of the driver in a
  much less prominent way.

Modified:
  head/sys/dev/vt/vt_core.c

Modified: head/sys/dev/vt/vt_core.c
==
--- head/sys/dev/vt/vt_core.c   Sat Aug 15 15:42:21 2015(r286807)
+++ head/sys/dev/vt/vt_core.c   Sat Aug 15 15:44:09 2015(r286808)
@@ -264,8 +264,9 @@ vt_update_static(void *dummy)
if (!vty_enabled(VTY_VT))
return;
if (main_vd-vd_driver != NULL)
-   printf(VT: running with driver \%s\.\n,
-   main_vd-vd_driver-vd_name);
+   printf(VT(%s): %s %ux%u\n, main_vd-vd_driver-vd_name,
+   (main_vd-vd_flags  VDF_TEXTMODE) ? text : resolution,
+   main_vd-vd_width, main_vd-vd_height);
else
printf(VT: init without driver.\n);
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286809 - head/sys/dev/vt/hw/efifb

2015-08-15 Thread Marcel Moolenaar
Author: marcel
Date: Sat Aug 15 16:13:28 2015
New Revision: 286809
URL: https://svnweb.freebsd.org/changeset/base/286809

Log:
  Improve support for Macs that have a stride not equal to the
  horizonal resolution (width). In those cases fb_bpp ended up
  completely wrong -- as in 6 bytes per pixel or something like
  that. Since we already have a way to calculate fb_depth given
  the masks and fb_bpp is effectively the same as fb_depth, all
  we need to do is make sure fb_bpp is rounded to the next
  multiple of the number of bits in a byte -- we assume we can
  divide by the number of bits in a byte throughout vt(4).
  While here:
  -   simplify how we calculate fb_depth.
  -   use fb_bpp instead of fb_depth to calculate fb_stride;
  we know we can divide fb_bpp.
  -   don't limit fb_width and fb_height by VT_FB_DEFAULT_WIDTH
  and VT_FB_DEFAULT_HEIGHT (resp.). Those constants have
  not relation to the size of the frame buffer.
  
  This at least fixes lower-resolution Macs. We're talking
  1280x1024 or so. There still is a problem with 27 Macs,
  which typically have a horizontal resolution over 2K.
  
  PR:   193745 (partial)
  Ok'd by:  emaste@

Modified:
  head/sys/dev/vt/hw/efifb/efifb.c

Modified: head/sys/dev/vt/hw/efifb/efifb.c
==
--- head/sys/dev/vt/hw/efifb/efifb.cSat Aug 15 15:44:09 2015
(r286808)
+++ head/sys/dev/vt/hw/efifb/efifb.cSat Aug 15 16:13:28 2015
(r286809)
@@ -96,7 +96,6 @@ vt_efifb_probe(struct vt_device *vd)
 static int
 vt_efifb_init(struct vt_device *vd)
 {
-   int depth, d;
struct fb_info  *info;
struct efi_fb   *efifb;
caddr_t kmdp;
@@ -116,16 +115,13 @@ vt_efifb_init(struct vt_device *vd)
info-fb_height = efifb-fb_height;
info-fb_width = efifb-fb_width;
 
-   depth = fls(efifb-fb_mask_red);
-   d = fls(efifb-fb_mask_green);
-   depth = d  depth ? d : depth;
-   d = fls(efifb-fb_mask_blue);
-   depth = d  depth ? d : depth;
-   d = fls(efifb-fb_mask_reserved);
-   depth = d  depth ? d : depth;
-   info-fb_depth = depth;
+   info-fb_depth = fls(efifb-fb_mask_red | efifb-fb_mask_green |
+   efifb-fb_mask_blue | efifb-fb_mask_reserved);
+   /* Round to a multiple of the bits in a byte. */
+   info-fb_bpp = (info-fb_depth + NBBY - 1)  ~(NBBY - 1);
 
-   info-fb_stride = efifb-fb_stride * (depth / 8);
+   /* Stride in bytes, not pixels */
+   info-fb_stride = efifb-fb_stride * (info-fb_bpp / NBBY);
 
vt_generate_cons_palette(info-fb_cmap, COLOR_FORMAT_RGB,
efifb-fb_mask_red, ffs(efifb-fb_mask_red) - 1,
@@ -137,16 +133,6 @@ vt_efifb_init(struct vt_device *vd)
info-fb_vbase = (intptr_t)pmap_mapdev_attr(info-fb_pbase,
info-fb_size, VM_MEMATTR_WRITE_COMBINING);
 
-   /* Get pixel storage size. */
-   info-fb_bpp = info-fb_stride / info-fb_width * 8;
-
-   /*
-* Early FB driver work with static window buffer, so reduce to minimal
-* size, buffer or screen.
-*/
-   info-fb_width = MIN(info-fb_width, VT_FB_DEFAULT_WIDTH);
-   info-fb_height = MIN(info-fb_height, VT_FB_DEFAULT_HEIGHT);
-
vt_fb_init(vd);
 
return (CN_INTERNAL);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286725 - in head/sys/arm: arm include

2015-08-13 Thread Marcel Moolenaar
Author: marcel
Date: Thu Aug 13 14:50:11 2015
New Revision: 286725
URL: https://svnweb.freebsd.org/changeset/base/286725

Log:
  The Broadcom BCM56060 chip has a Cortex-A9R4 core.
  
  Submitted by: Steve Kiernan ste...@juniper.net
  Reviewed by:  imp@
  Differential Revision:https://reviews.freebsd.org/D3357

Modified:
  head/sys/arm/arm/cpufunc.c
  head/sys/arm/arm/identcpu.c
  head/sys/arm/include/armreg.h

Modified: head/sys/arm/arm/cpufunc.c
==
--- head/sys/arm/arm/cpufunc.c  Thu Aug 13 14:43:25 2015(r286724)
+++ head/sys/arm/arm/cpufunc.c  Thu Aug 13 14:50:11 2015(r286725)
@@ -904,6 +904,7 @@ set_cpufuncs()
cputype == CPU_ID_CORTEXA9R1 ||
cputype == CPU_ID_CORTEXA9R2 ||
cputype == CPU_ID_CORTEXA9R3 ||
+   cputype == CPU_ID_CORTEXA9R4 ||
cputype == CPU_ID_CORTEXA12R0 ||
cputype == CPU_ID_CORTEXA15R0 ||
cputype == CPU_ID_CORTEXA15R1 ||

Modified: head/sys/arm/arm/identcpu.c
==
--- head/sys/arm/arm/identcpu.c Thu Aug 13 14:43:25 2015(r286724)
+++ head/sys/arm/arm/identcpu.c Thu Aug 13 14:50:11 2015(r286725)
@@ -185,6 +185,8 @@ const struct cpuidtab cpuids[] = {
  generic_steppings },
{ CPU_ID_CORTEXA9R3,CPU_CLASS_CORTEXA,  Cortex A9-r3,
  generic_steppings },
+   { CPU_ID_CORTEXA9R4,CPU_CLASS_CORTEXA,  Cortex A9-r4,
+ generic_steppings },
{ CPU_ID_CORTEXA12R0,   CPU_CLASS_CORTEXA,  Cortex A12-r0,
  generic_steppings },
{ CPU_ID_CORTEXA15R0,   CPU_CLASS_CORTEXA,  Cortex A15-r0,

Modified: head/sys/arm/include/armreg.h
==
--- head/sys/arm/include/armreg.h   Thu Aug 13 14:43:25 2015
(r286724)
+++ head/sys/arm/include/armreg.h   Thu Aug 13 14:50:11 2015
(r286725)
@@ -133,6 +133,7 @@
 #define CPU_ID_CORTEXA9R1  0x411fc090
 #define CPU_ID_CORTEXA9R2  0x412fc090
 #define CPU_ID_CORTEXA9R3  0x413fc090
+#define CPU_ID_CORTEXA9R4  0x414fc090
 #define CPU_ID_CORTEXA12R0 0x410fc0d0
 #define CPU_ID_CORTEXA15R0 0x410fc0f0
 #define CPU_ID_CORTEXA15R1 0x411fc0f0
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286726 - head/sys/arm/arm

2015-08-13 Thread Marcel Moolenaar
Author: marcel
Date: Thu Aug 13 14:53:29 2015
New Revision: 286726
URL: https://svnweb.freebsd.org/changeset/base/286726

Log:
  Instead of having separate do_sync functions for ARM_ARCH 6 vs.
  ARM_ARCH = 7, use the dmb() macro defined in machine/atomic.h
  
  Submitted by: Steve Kiernan ste...@juniper.net
  Reviewed by:  imp@
  Differential Revision:https://reviews.freebsd.org/D3355

Modified:
  head/sys/arm/arm/stdatomic.c

Modified: head/sys/arm/arm/stdatomic.c
==
--- head/sys/arm/arm/stdatomic.cThu Aug 13 14:50:11 2015
(r286725)
+++ head/sys/arm/arm/stdatomic.cThu Aug 13 14:53:29 2015
(r286726)
@@ -32,6 +32,7 @@ __FBSDID($FreeBSD$);
 #include sys/types.h
 
 #include machine/acle-compat.h
+#include machine/atomic.h
 #include machine/cpufunc.h
 #include machine/sysarch.h
 
@@ -67,19 +68,12 @@ do_sync(void)
 
__asm volatile ( : : : memory);
 }
-#elif __ARM_ARCH = 7
-static inline void
-do_sync(void)
-{
-
-   __asm volatile (dmb : : : memory);
-}
 #elif __ARM_ARCH = 6
 static inline void
 do_sync(void)
 {
 
-   __asm volatile (mcr p15, 0, %0, c7, c10, 5 : : r (0) : memory);
+   dmb();
 }
 #endif
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286723 - head/sys/dev/vt/hw/vga

2015-08-13 Thread Marcel Moolenaar
Author: marcel
Date: Thu Aug 13 14:43:11 2015
New Revision: 286723
URL: https://svnweb.freebsd.org/changeset/base/286723

Log:
  Fix text mode operation.
  
  We first map 64KB at 0xA and then determine whether to work
  in text or graphics mode.  When graphics mode, the mapping is
  precisely what we need and everything is fine.  But text mode,
  has the frame buffer relocated to 0xB8000. We didn't map that
  much to safely add 0x18000 bytes to the base address.
  
  Now we first check whether to work in text or graphics mode and
  then map the frame buffer at the right address and with the
  right size (0xA+64KB for graphics, 0xB8000+32KB for text).
  
  PR:   202276
  Tested by:ed@

Modified:
  head/sys/dev/vt/hw/vga/vt_vga.c
  head/sys/dev/vt/hw/vga/vt_vga_reg.h

Modified: head/sys/dev/vt/hw/vga/vt_vga.c
==
--- head/sys/dev/vt/hw/vga/vt_vga.c Thu Aug 13 13:38:09 2015
(r286722)
+++ head/sys/dev/vt/hw/vga/vt_vga.c Thu Aug 13 14:43:11 2015
(r286723)
@@ -883,9 +883,9 @@ vga_bitblt_text_txtmode(struct vt_device
/* Convert colors to VGA attributes. */
attr = bg  4 | fg;
 
-   MEM_WRITE1(sc, 0x18000 + (row * 80 + col) * 2 + 0,
+   MEM_WRITE1(sc, (row * 80 + col) * 2 + 0,
ch);
-   MEM_WRITE1(sc, 0x18000 + (row * 80 + col) * 2 + 1,
+   MEM_WRITE1(sc, (row * 80 + col) * 2 + 1,
attr);
}
}
@@ -1226,8 +1226,6 @@ vga_init(struct vt_device *vd)
 # error Architecture not yet supported!
 #endif
 
-   bus_space_map(sc-vga_fb_tag, VGA_MEM_BASE, VGA_MEM_SIZE, 0,
-   sc-vga_fb_handle);
bus_space_map(sc-vga_reg_tag, VGA_REG_BASE, VGA_REG_SIZE, 0,
sc-vga_reg_handle);
 
@@ -1236,9 +1234,13 @@ vga_init(struct vt_device *vd)
vd-vd_flags |= VDF_TEXTMODE;
vd-vd_width = 80;
vd-vd_height = 25;
+   bus_space_map(sc-vga_fb_tag, VGA_TXT_BASE, VGA_TXT_SIZE, 0,
+   sc-vga_fb_handle);
} else {
vd-vd_width = VT_VGA_WIDTH;
vd-vd_height = VT_VGA_HEIGHT;
+   bus_space_map(sc-vga_fb_tag, VGA_MEM_BASE, VGA_MEM_SIZE, 0,
+   sc-vga_fb_handle);
}
if (vga_initialize(vd, textmode) != 0)
return (CN_DEAD);

Modified: head/sys/dev/vt/hw/vga/vt_vga_reg.h
==
--- head/sys/dev/vt/hw/vga/vt_vga_reg.h Thu Aug 13 13:38:09 2015
(r286722)
+++ head/sys/dev/vt/hw/vga/vt_vga_reg.h Thu Aug 13 14:43:11 2015
(r286723)
@@ -49,6 +49,8 @@
 
 #defineVGA_MEM_BASE0xA
 #defineVGA_MEM_SIZE0x1
+#defineVGA_TXT_BASE0xB8000
+#defineVGA_TXT_SIZE0x08000
 #defineVGA_REG_BASE0x3c0
 #defineVGA_REG_SIZE0x10+0x0c
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286727 - in head/sys: conf dev/md

2015-08-13 Thread Marcel Moolenaar
Author: marcel
Date: Thu Aug 13 15:16:34 2015
New Revision: 286727
URL: https://svnweb.freebsd.org/changeset/base/286727

Log:
  Change md(4) to use weak symbols as start, end and size for the embedded
  root disk. The embedded image is linked into the kernel in the .mfs
  section.
  
  Add rules and variables to kern.pre.mk and kern.post.mk that handle the
  linking of the image. First objcopy is used to generate an object file.
  Then, the object file is linked into the kernel.
  
  Submitted by: Steve Kiernan ste...@juniper.net
  Reviewed by:  brooks@
  Obtained from: Juniper Networks, Inc.
  Differential Revision:https://reviews.freebsd.org/D2903

Modified:
  head/sys/conf/Makefile.arm
  head/sys/conf/kern.post.mk
  head/sys/conf/kern.pre.mk
  head/sys/dev/md/md.c

Modified: head/sys/conf/Makefile.arm
==
--- head/sys/conf/Makefile.arm  Thu Aug 13 14:53:29 2015(r286726)
+++ head/sys/conf/Makefile.arm  Thu Aug 13 15:16:34 2015(r286727)
@@ -66,10 +66,6 @@ SYSTEM_LD_TAIL +=;sed s/ + SIZEOF_HEADE
${KERNEL_KO}.bin; \
rm ${FULLKERNEL}.noheader
 
-.if defined(MFS_IMAGE)
-SYSTEM_LD_TAIL += ;sh ${S}/tools/embed_mfs.sh ${KERNEL_KO}.bin ${MFS_IMAGE};
-.endif
-
 FILES_CPU_FUNC = \
$S/$M/$M/cpufunc_asm_arm9.S \
$S/$M/$M/cpufunc_asm_arm10.S \

Modified: head/sys/conf/kern.post.mk
==
--- head/sys/conf/kern.post.mk  Thu Aug 13 14:53:29 2015(r286726)
+++ head/sys/conf/kern.post.mk  Thu Aug 13 15:16:34 2015(r286727)
@@ -121,7 +121,7 @@ gdbinit:
 .endif
 .endif
 
-${FULLKERNEL}: ${SYSTEM_DEP} vers.o ${MFS_IMAGE}
+${FULLKERNEL}: ${SYSTEM_DEP} vers.o
@rm -f ${.TARGET}
@echo linking ${.TARGET}
${SYSTEM_LD}
@@ -133,9 +133,6 @@ ${FULLKERNEL}: ${SYSTEM_DEP} vers.o ${MF
${OBJCOPY} --strip-debug ${.TARGET}
 .endif
${SYSTEM_LD_TAIL}
-.if defined(MFS_IMAGE)
-   sh ${S}/tools/embed_mfs.sh ${FULLKERNEL} ${MFS_IMAGE}
-.endif
 
 .if !exists(${.OBJDIR}/.depend)
 ${SYSTEM_OBJS}: assym.s vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
@@ -301,6 +298,27 @@ vnode_if_newproto.h:
 vnode_if_typedef.h:
${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -q
 
+.if ${MFS_IMAGE:Uno} != no
+# Generate an object file from the file system image to embed in the kernel
+# via linking. Make sure the contents are in the mfs section and rename the
+# start/end/size variables to __start_mfs, __stop_mfs, and mfs_size,
+# respectively.
+embedfs_${MFS_IMAGE:T:R}.o: ${MFS_IMAGE}
+   ${OBJCOPY} --input-target binary \
+   --output-target ${EMBEDFS_FORMAT.${MACHINE_ARCH}} \
+   --binary-architecture ${EMBEDFS_ARCH.${MACHINE_ARCH}} \
+   ${MFS_IMAGE} ${.TARGET}
+   ${OBJCOPY} \
+   --rename-section .data=mfs,contents,alloc,load,readonly,data \
+   --redefine-sym \
+   _binary_${MFS_IMAGE:C,[^[:alnum:]],_,g}_size=__mfs_root_size \
+   --redefine-sym \
+   _binary_${MFS_IMAGE:C,[^[:alnum:]],_,g}_start=mfs_root \
+   --redefine-sym \
+   _binary_${MFS_IMAGE:C,[^[:alnum:]],_,g}_end=mfs_root_end \
+   ${.TARGET}
+.endif
+
 # XXX strictly, everything depends on Makefile because changes to ${PROF}
 # only appear there, but we don't handle that.
 

Modified: head/sys/conf/kern.pre.mk
==
--- head/sys/conf/kern.pre.mk   Thu Aug 13 14:53:29 2015(r286726)
+++ head/sys/conf/kern.pre.mk   Thu Aug 13 15:16:34 2015(r286727)
@@ -191,6 +191,9 @@ SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
 SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
 SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
 SYSTEM_OBJS+= hack.So
+.if ${MFS_IMAGE:Uno} != no
+SYSTEM_OBJS+= embedfs_${MFS_IMAGE:T:R}.o
+.endif
 SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} ${_LDFLAGS} --no-warn-mismatch \
--warn-common --export-dynamic --dynamic-linker /red/herring \
-o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
@@ -222,6 +225,32 @@ MKMODULESENV+= DEBUG_FLAGS=${DEBUG}
 .endif
 MKMODULESENV+= _MPATH=${_MPATH}
 
+# Architecture and output format arguments for objdump to convert image to
+# object file
+.if ${MFS_IMAGE:Uno} != no
+
+.if !defined(EMBEDFS_FORMAT.${MACHINE_ARCH})
+EMBEDFS_FORMAT.${MACHINE_ARCH}!= awk -F'' '/OUTPUT_FORMAT/ {print $$2}' 
${LDSCRIPT}
+.if empty(EMBEDFS_FORMAT.${MACHINE_ARCH})
+.undef EMBEDFS_FORMAT.${MACHINE_ARCH}
+.endif
+.endif
+
+.if !defined(EMBEDFS_ARCH.${MACHINE_ARCH})
+EMBEDFS_ARCH.${MACHINE_ARCH}!= sed -n '/OUTPUT_ARCH/s/.*(\(.*\)).*/\1/p' 
${LDSCRIPT}
+.if empty(EMBEDFS_ARCH.${MACHINE_ARCH})
+.undef EMBEDFS_ARCH.${MACHINE_ARCH}
+.endif
+.endif
+
+EMBEDFS_FORMAT.arm?=   elf32-littlearm
+EMBEDFS_FORMAT.armv6?= elf32-littlearm
+EMBEDFS_FORMAT.mips?=  elf32-tradbigmips
+EMBEDFS_FORMAT.mipsel?=

svn commit: r286741 - head/sys/dev/md

2015-08-13 Thread Marcel Moolenaar
Author: marcel
Date: Thu Aug 13 19:12:55 2015
New Revision: 286741
URL: https://svnweb.freebsd.org/changeset/base/286741

Log:
  s/as/at/ in previous commit.
  
  Pointed out by: jmallett@

Modified:
  head/sys/dev/md/md.c

Modified: head/sys/dev/md/md.c
==
--- head/sys/dev/md/md.cThu Aug 13 19:05:18 2015(r286740)
+++ head/sys/dev/md/md.cThu Aug 13 19:12:55 2015(r286741)
@@ -1565,7 +1565,7 @@ md_preloaded(u_char *image, size_t lengt
printf(%s%d: Preloaded image %s %zd bytes at %p\n,
MD_NAME, sc-unit, name, length, image);
} else {
-   printf(%s%d: Embedded image %zd bytes as %p\n,
+   printf(%s%d: Embedded image %zd bytes at %p\n,
MD_NAME, sc-unit, length, image);
}
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286667 - in head/sys: amd64/amd64 conf dev/vt/hw/efifb dev/vt/hw/vga i386/i386 x86/include x86/x86

2015-08-12 Thread Marcel Moolenaar
 Aug 12 15:26:32 2015(r286667)
@@ -130,32 +130,15 @@
  * Map a region of device bus space into CPU virtual address space.
  */
 
-static __inline int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
- bus_size_t size, int flags,
- bus_space_handle_t *bshp);
-
-static __inline int
-bus_space_map(bus_space_tag_t t __unused, bus_addr_t addr,
- bus_size_t size __unused, int flags __unused,
- bus_space_handle_t *bshp)
-{
-
-   *bshp = addr;
-   return (0);
-}
+int bus_space_map(bus_space_tag_t tag, bus_addr_t addr, bus_size_t size,
+int flags, bus_space_handle_t *bshp);
 
 /*
  * Unmap a region of device bus space.
  */
 
-static __inline void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
-bus_size_t size);
-
-static __inline void
-bus_space_unmap(bus_space_tag_t t __unused, bus_space_handle_t bsh __unused,
-   bus_size_t size __unused)
-{
-}
+void bus_space_unmap(bus_space_tag_t tag, bus_space_handle_t bsh,
+bus_size_t size);
 
 /*
  * Get a new handle for a subregion of an already-mapped area of bus space.

Added: head/sys/x86/x86/bus_machdep.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/x86/x86/bus_machdep.c  Wed Aug 12 15:26:32 2015
(r286667)
@@ -0,0 +1,59 @@
+/*-
+ * Copyright (c) 2015 Marcel Moolenaar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include sys/cdefs.h
+__FBSDID($FreeBSD$);
+
+#include sys/param.h
+#include sys/systm.h
+#include x86/bus.h
+
+#include vm/vm.h
+#include vm/pmap.h
+
+/*
+ * Implementation of bus_space_map(), which effectively is a thin
+ * wrapper around pmap_mapdev() for memory mapped I/O space. It's
+ * implemented here and not in x86/bus.h to avoid pollution.
+ */
+int
+bus_space_map(bus_space_tag_t tag, bus_addr_t addr, bus_size_t size,
+int flags __unused, bus_space_handle_t *bshp)
+{
+
+   *bshp = (tag == X86_BUS_SPACE_MEM)
+   ? (uintptr_t)pmap_mapdev(addr, size)
+   : addr;
+   return (0);
+}
+
+void
+bus_space_unmap(bus_space_tag_t tag, bus_space_handle_t bsh, bus_size_t size)
+{
+
+   if (tag == X86_BUS_SPACE_MEM)
+   pmap_unmapdev(bsh, size);
+}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286668 - head/sys/dev/uart

2015-08-12 Thread Marcel Moolenaar
Author: marcel
Date: Wed Aug 12 15:48:14 2015
New Revision: 286668
URL: https://svnweb.freebsd.org/changeset/base/286668

Log:
  Add support for the Broadcom TruManage integrated serial port.
  
  PR:   191266

Modified:
  head/sys/dev/uart/uart_bus_pci.c

Modified: head/sys/dev/uart/uart_bus_pci.c
==
--- head/sys/dev/uart/uart_bus_pci.cWed Aug 12 15:26:32 2015
(r286667)
+++ head/sys/dev/uart/uart_bus_pci.cWed Aug 12 15:48:14 2015
(r286668)
@@ -115,6 +115,8 @@ static const struct pci_id pci_ns8250_id
0x10, 16384000 },
 { 0x1415, 0xc120, 0x, 0, Oxford Semiconductor OXPCIe952 PCIe 16950 UART,
0x10 },
+{ 0x14e4, 0x160a, 0x, 0, Broadcom TruManage UART, 0x10,
+   128 * DEFAULT_RCLK, 2},
 { 0x14e4, 0x4344, 0x, 0, Sony Ericsson GC89 PC Card, 0x10},
 { 0x151f, 0x, 0x, 0, TOPIC Semiconductor TP560 56k modem, 0x10 },
 { 0x1fd4, 0x1999, 0x1fd4, 0x0001, Sunix SER5 Serial Port, 0x10,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r286667 - in head/sys: amd64/amd64 conf dev/vt/hw/efifb dev/vt/hw/vga i386/i386 x86/include x86/x86

2015-08-12 Thread Marcel Moolenaar

 On Aug 12, 2015, at 1:17 PM, Ed Schouten e...@nuxi.nl wrote:
 
 2015-08-12 22:02 GMT+02:00 Marcel Moolenaar mar...@xcllnt.net:
 Maybe upgrading to 4.3.30 resolves the issue?
 
 I just upgraded to 4.3.30 and 5.0.0. Both fail the same way. I've just
 attached a screenshot. Will open a bug.

Thanks!

--
Marcel Moolenaar
mar...@xcllnt.net



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: svn commit: r286667 - in head/sys: amd64/amd64 conf dev/vt/hw/efifb dev/vt/hw/vga i386/i386 x86/include x86/x86

2015-08-12 Thread Marcel Moolenaar
[CC ed]

 On Aug 12, 2015, at 10:37 AM, Ed Schouten e...@nuxi.nl wrote:
 
 Hi Marcel,
 
 2015-08-12 17:26 GMT+02:00 Marcel Moolenaar mar...@freebsd.org:
  Better support memory mapped console devices, such as VGA and EFI
  frame buffers and memory mapped UARTs.
 
 This change causes my FreeBSD instance in Virtualbox 4.3.28 (OS X) to
 crash. As soon as the kernel initializes the graphics on startup
 (read: before printing any messages), I see random garbage appear on
 screen, followed by a popup dialog from Virtualbox that a fatal
 machine exception has occurred.

Would you mind creating a PR so that we can track the various
console issues pre and post this change.

Details as to how to reproduce would be much appreciated!

Thanks,

--
Marcel Moolenaar
mar...@xcllnt.net



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: svn commit: r286667 - in head/sys: amd64/amd64 conf dev/vt/hw/efifb dev/vt/hw/vga i386/i386 x86/include x86/x86

2015-08-12 Thread Marcel Moolenaar

 On Aug 12, 2015, at 10:37 AM, Ed Schouten e...@nuxi.nl wrote:
 
 Hi Marcel,
 
 2015-08-12 17:26 GMT+02:00 Marcel Moolenaar mar...@freebsd.org:
  Better support memory mapped console devices, such as VGA and EFI
  frame buffers and memory mapped UARTs.
 
 This change causes my FreeBSD instance in Virtualbox 4.3.28 (OS X) to
 crash. As soon as the kernel initializes the graphics on startup
 (read: before printing any messages), I see random garbage appear on
 screen, followed by a popup dialog from Virtualbox that a fatal
 machine exception has occurred.

No problems are seen with VB 5.0 on Mac OS X and having BIOS (don’t
know if VB even supports UEFI) and with FreeBSD/amd64.

Maybe upgrading to 4.3.30 resolves the issue?

--
Marcel Moolenaar
mar...@xcllnt.net



signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r286653 - head/sys/dev/uart

2015-08-11 Thread Marcel Moolenaar
Author: marcel
Date: Wed Aug 12 04:03:04 2015
New Revision: 286653
URL: https://svnweb.freebsd.org/changeset/base/286653

Log:
  Use bus_alloc_resource_any(), rather than bus_alloc_resource()
  with start 0 and end ~0. This avoids confusion WRT to what the
  value of length can or should be.

Modified:
  head/sys/dev/uart/uart_core.c

Modified: head/sys/dev/uart/uart_core.c
==
--- head/sys/dev/uart/uart_core.c   Wed Aug 12 03:03:51 2015
(r286652)
+++ head/sys/dev/uart/uart_core.c   Wed Aug 12 04:03:04 2015
(r286653)
@@ -474,14 +474,13 @@ uart_bus_probe(device_t dev, int regshft
 */
sc-sc_rrid = rid;
sc-sc_rtype = SYS_RES_IOPORT;
-   sc-sc_rres = bus_alloc_resource(dev, sc-sc_rtype, sc-sc_rrid,
-   0, ~0, uart_getrange(sc-sc_class), RF_ACTIVE);
+   sc-sc_rres = bus_alloc_resource_any(dev, sc-sc_rtype, sc-sc_rrid,
+   RF_ACTIVE);
if (sc-sc_rres == NULL) {
sc-sc_rrid = rid;
sc-sc_rtype = SYS_RES_MEMORY;
-   sc-sc_rres = bus_alloc_resource(dev, sc-sc_rtype,
-   sc-sc_rrid, 0, ~0, uart_getrange(sc-sc_class),
-   RF_ACTIVE);
+   sc-sc_rres = bus_alloc_resource_any(dev, sc-sc_rtype,
+   sc-sc_rrid, RF_ACTIVE);
if (sc-sc_rres == NULL)
return (ENXIO);
}
@@ -556,8 +555,8 @@ uart_bus_attach(device_t dev)
 * Re-allocate. We expect that the softc contains the information
 * collected by uart_bus_probe() intact.
 */
-   sc-sc_rres = bus_alloc_resource(dev, sc-sc_rtype, sc-sc_rrid,
-   0, ~0, uart_getrange(sc-sc_class), RF_ACTIVE);
+   sc-sc_rres = bus_alloc_resource_any(dev, sc-sc_rtype, sc-sc_rrid,
+   RF_ACTIVE);
if (sc-sc_rres == NULL) {
mtx_destroy(sc-sc_hwmtx_s);
return (ENXIO);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286439 - head/share/man/man4

2015-08-07 Thread Marcel Moolenaar
Author: marcel
Date: Sat Aug  8 04:59:27 2015
New Revision: 286439
URL: https://svnweb.freebsd.org/changeset/base/286439

Log:
  Document the application interface.

Modified:
  head/share/man/man4/proto.4

Modified: head/share/man/man4/proto.4
==
--- head/share/man/man4/proto.4 Sat Aug  8 01:45:53 2015(r286438)
+++ head/share/man/man4/proto.4 Sat Aug  8 04:59:27 2015(r286439)
@@ -25,7 +25,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd July 19, 2015
+.Dd August 7, 2015
 .Dt PROTO 4
 .Os
 .\
@@ -74,7 +74,285 @@ logic in user space.
 Especially hardware diagnostics requires a somewhat user-friendly interface
 and adequate reporting.
 Neither is done easily as kernel code.
-.\
+.Ss I/O port resources
+Device special files created for I/O port resources allow
+.Xr lseek 2 ,
+.Xr read 2 ,
+.Xr write 2
+and
+.Xr ioctl 2
+operations to be performed on them.
+The
+.Xr read 2
+and
+.Xr write 2
+system calls are used to perform input and output (resp.) on the port.
+The amount of data that can be read or written at any single time is either
+1, 2 or 4 bytes.
+While the
+.Nm
+driver does not prevent reading or writing 8 bytes at a time for some
+architectures, it should not be assumed that such actually produces
+correct results.
+The
+.Xr lseek 2
+system call is used to select the port number, relative to the I/O port
+region being represented by the device special file.
+If, for example, the device special file corresponds to an I/O port region
+from 0x3f8 to 0x3ff inclusive, then an offset of 4 given to lseek with a
+whence value of SEEK_SET will target port 0x3fc on the next read or write
+operation.
+The
+.Xr ioctl 2
+system call can be used for the
+.Dv PROTO_IOC_REGION
+request.
+This ioctl request returns the extend of the resource covered by this
+device special file. The extend is returned in the following structure:
+.Bd -literal
+struct proto_ioc_region {
+unsigned long   address;
+unsigned long   size;
+};
+.Ed
+.Ss Memory mapped I/O resources
+The device special files created for memory mapped I/O resources behave
+in the same way as those created for I/O port resources.
+Additionally, device special files for memory mapped I/O resources allow
+the memory to be mapped into the process' address space using
+.Xr mmap 2 .
+Reads and writes to the memory address returned by
+.Xr mmap 2
+go directly to the hardware.
+As such the use of
+.Xr read 2
+and
+.Xr write 2
+can be avoided, reducing the access overhead significantly.
+Alignment and access width constraints put forth by the underlying device
+apply.
+Also, make sure the compiler does not optimize memory accesses away or has
+them coalesced into bigger accesses.
+.Ss DMA pseudo resource
+A device special file named
+.Pa busdma
+is created for the purpose of doing DMA.
+It only supports
+.Xr ioctl 2
+and only for the
+.Dv PROTO_IOC_BUSDMA
+request.
+This device special file does not support
+.Xr read 2
+nor
+.Xr write 2 .
+The
+.Dv PROTO_IOC_BUSDMA
+request has an argument that is both in and out and is defined as
+follows:
+.Bd -literal
+struct proto_ioc_busdma {
+unsigned intrequest;
+unsigned long   key;
+union {
+struct {
+unsigned long   align;
+unsigned long   bndry;
+unsigned long   maxaddr;
+unsigned long   maxsz;
+unsigned long   maxsegsz;
+unsigned intnsegs;
+unsigned intdatarate;
+unsigned intflags;
+} tag;
+struct {
+unsigned long   tag;
+unsigned intflags;
+unsigned long   virt_addr;
+unsigned long   virt_size;
+unsigned intphys_nsegs;
+unsigned long   phys_addr;
+unsigned long   bus_addr;
+unsigned intbus_nsegs;
+} md;
+struct {
+unsigned intop;
+unsigned long   base;
+unsigned long   size;
+} sync;
+} u;
+unsigned long   result;
+};
+.Ed
+The
+.Va request
+field is used to specify which DMA operation is to be performed.
+The
+.Va key
+field is used to specify which object the operation applies to.
+An object is either a tag or a memory descriptor (md).
+The following DMA operations are defined:
+.Bl -tag -width 
+.It PROTO_IOC_BUSDMA_TAG_CREATE
+Create a root tag.
+The
+.Va result
+field is set on output with the key of the DMA tag.
+The tag is created with the constraints given by the
+.Va tag
+sub-structure. These constraints correspond roughly to those that can be
+given to the
+.Xr bus_dma_tag_create 9
+function.
+.It 

svn commit: r286417 - head/usr.bin/mkimg

2015-08-07 Thread Marcel Moolenaar
Author: marcel
Date: Fri Aug  7 17:22:37 2015
New Revision: 286417
URL: https://svnweb.freebsd.org/changeset/base/286417

Log:
  o  Fix a typo.
  o  Describe the file formats mkimg can create.

Modified:
  head/usr.bin/mkimg/mkimg.1

Modified: head/usr.bin/mkimg/mkimg.1
==
--- head/usr.bin/mkimg/mkimg.1  Fri Aug  7 16:23:16 2015(r286416)
+++ head/usr.bin/mkimg/mkimg.1  Fri Aug  7 17:22:37 2015(r286417)
@@ -24,7 +24,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd February 22, 2015
+.Dd August 7, 2015
 .Dt MKIMG 1
 .Os
 .Sh NAME
@@ -141,7 +141,7 @@ utility will create images that are iden
 .Pp
 A set of long options exist to query about the
 .Nm
-utilty itself.
+utility itself.
 Options in this set should be given by themselves because the
 .Nm
 utility exits immediately after providing the requested information.
@@ -165,6 +165,85 @@ run the
 .Nm
 utility without any arguments.
 This will print a usage message with all the necessary details.
+.Sh DISK FORMATS
+The
+.Nm
+utility supports a number of output file formats.
+A short description of these is given below.
+.Ss QCOW and QCOW2
+QCOW stands for QEMU Copy On Write.
+It's a sparse file format akin to VHD and VMDK and QCOW represents the
+first version.
+QCOW2 represents version 2 of the file format.
+Version 2 is not backward compatible with version 1 and adds support for
+snapshots among other things.
+The QCOW file formats are natively supported by QEMU and Xen.
+To write QCOW, specify
+.Fl f Ar qcow
+on the command line.
+To write version 2 QCOW, specify
+.Fl f Ar qcow2
+on the command line.
+The preferred file extension is .qcow iand .qcow2 for QCOW and QCOW2
+(resp.), but .qcow is sometimes used for version 2 files as well.
+.Ss RAW file format
+This file format is a sector by sector representation of an actual disk.
+There is no extra information that describes or relates to the format
+itself. The size of the file is the size of the (virtual) disk.
+This file format is suitable for being copyied onto a disk with utilities
+like
+.Nm dd .
+To write a raw disk file, either omit the
+.Fl f
+option, or specify
+.Fl f Ar raw
+on the command line.
+The preferred file extension is one of .img or .raw, but there's no
+real convention for it.
+.Ss Dynamic VHD and Fixed VHD
+Microsoft's Virtual Hard Disk file formats.
+The dynamic format is a sparse format akin to QCOW and VMDK.
+The fixed format is effectively a raw format with a footer appended to the
+file and as such it's often indistinguishable from the raw format.
+The fixed file format has been added to support Microsoft's Azure platform
+and due to inconsistencies in interpretation of the footer is not compatible
+with utilities like
+.Nm qemu
+when it is specifically instructed to interpreted the file as a VHD file.
+By default
+.Nm qemu
+will treat the file as a raw disk file, which mostly works fine.
+To have
+.Nm
+create a dynamic VHD file, specify
+.Fl f Ar vhd
+on the command line.
+To create a fixed VHD file for use by Azure, specify
+.Fl f Ar vhdf
+on the command line.
+The preferred file extension is .vhd.
+.Ss VMDK
+VMware's Virtual Machine Disk file format.
+It's a sparse file format akin to QCOW and VHD and supported by many
+virtualization solutions.
+To create a VMDK file, specify
+.Fl f Ar vmdk
+on the command line.
+The preferred file extension is .vmdk.
+.Pp
+Not all virtualization solutions support all file formats, but often those
+virtualization environments have utilities to convert from one format to
+another.
+Note however that conversion may require that the virtual disk size is
+changed to match the constraints of the output format and this may invalidate
+the contents of the disk image.
+For example, the GUID Partition Table (GPT) scheme has a header in the last
+sector on the disk.
+When changing the disk size, the GPT must be changed so that the last header
+is moved accordingly.
+This is typically not part of the conversion process.
+If possible, use an output format specifically for the environment in which
+the file is intended to be used.
 .Sh ENVIRONMENT
 .Bl -tag -width TMPDIR -compact
 .It Ev TMPDIR
@@ -235,6 +314,7 @@ utility supports assigning labels to the
 In the following example the file system partition is labeled as 'backup':
 .Dl % mkimg -s gpt -p freebsd-ufs/backup:=file-system.ufs -o gpt.img
 .Sh SEE ALSO
+.Xr dd 1 ,
 .Xr gpart 8 ,
 .Xr makefs 8 ,
 .Xr mdconfig 8 ,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286419 - head/usr.bin/mkimg

2015-08-07 Thread Marcel Moolenaar
Author: marcel
Date: Fri Aug  7 18:40:44 2015
New Revision: 286419
URL: https://svnweb.freebsd.org/changeset/base/286419

Log:
  Fix typo introduced in previous commit.
  
  Pointed out by: Nikolai Lifanov lifanov at mail.lifanov.com

Modified:
  head/usr.bin/mkimg/mkimg.1

Modified: head/usr.bin/mkimg/mkimg.1
==
--- head/usr.bin/mkimg/mkimg.1  Fri Aug  7 18:30:11 2015(r286418)
+++ head/usr.bin/mkimg/mkimg.1  Fri Aug  7 18:40:44 2015(r286419)
@@ -184,7 +184,7 @@ on the command line.
 To write version 2 QCOW, specify
 .Fl f Ar qcow2
 on the command line.
-The preferred file extension is .qcow iand .qcow2 for QCOW and QCOW2
+The preferred file extension is .qcow and .qcow2 for QCOW and QCOW2
 (resp.), but .qcow is sometimes used for version 2 files as well.
 .Ss RAW file format
 This file format is a sector by sector representation of an actual disk.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286395 - head/usr.bin/mkimg

2015-08-06 Thread Marcel Moolenaar
Author: marcel
Date: Fri Aug  7 04:27:51 2015
New Revision: 286395
URL: https://svnweb.freebsd.org/changeset/base/286395

Log:
  Fix the dynamic VHD format to work with qemu. The size of the disk
  is taken to match the geometry and only when the geometry is max'd
  out, is the actual recorded size taken.
  
  Note that qemu has the same logic for the fixed VHD format. However
  that is known to conflict with Microsoft Azure, where the recorded
  size of the image is what counts.
  
  Pointed out by: gjb@

Modified:
  head/usr.bin/mkimg/vhd.c

Modified: head/usr.bin/mkimg/vhd.c
==
--- head/usr.bin/mkimg/vhd.cFri Aug  7 02:37:47 2015(r286394)
+++ head/usr.bin/mkimg/vhd.cFri Aug  7 04:27:51 2015(r286395)
@@ -159,6 +159,34 @@ vhd_geometry(uint64_t image_size, struct
geom-cylinders = cth / geom-heads;
 }
 
+static uint64_t
+vhd_resize(uint64_t origsz)
+{
+   struct vhd_geom geom;
+   uint64_t newsz;
+
+   /*
+* Round the image size to the pre-determined geometry that
+* matches the image size. This circular dependency implies
+* that we need to loop to handle boundary conditions.
+* The first time, newsz equals origsz and the geometry will
+* typically yield a new size that's smaller. We keep adding
+* cylinder's worth of sectors to the new size until its
+* larger or equal or origsz. But during those iterations,
+* the geometry can change, so we need to account for that.
+*/
+   newsz = origsz;
+   while (1) {
+   vhd_geometry(newsz, geom);
+   newsz = (int64_t)geom.cylinders * geom.heads *
+   geom.sectors * VHD_SECTOR_SIZE;
+   if (newsz = origsz)
+   break;
+   newsz += geom.heads * geom.sectors * VHD_SECTOR_SIZE;
+   }
+   return (newsz);
+}
+
 static uint32_t
 vhd_timestamp(void)
 {
@@ -256,8 +284,7 @@ vhd_dyn_resize(lba_t imgsz)
 {
uint64_t imagesz;
 
-   imagesz = imgsz * secsz;
-   imagesz = (imagesz + VHD_BLOCK_SIZE - 1)  ~(VHD_BLOCK_SIZE - 1);
+   imagesz = vhd_resize(imgsz * secsz);
return (image_set_size(imagesz / secsz));
 }
 
@@ -266,7 +293,7 @@ vhd_dyn_write(int fd)
 {
struct vhd_footer footer;
struct vhd_dyn_header header;
-   uint64_t imgsz;
+   uint64_t imgsz, rawsz;
lba_t blk, blkcnt, nblks;
uint32_t *bat;
void *bitmap;
@@ -274,13 +301,14 @@ vhd_dyn_write(int fd)
uint32_t sector;
int bat_entries, error, entry;
 
-   imgsz = image_get_size() * secsz;
-   bat_entries = imgsz / VHD_BLOCK_SIZE;
+   rawsz = image_get_size() * secsz;
+   imgsz = (rawsz + VHD_BLOCK_SIZE - 1)  ~(VHD_BLOCK_SIZE - 1);
 
-   vhd_make_footer(footer, imgsz, VHD_DISK_TYPE_DYNAMIC, sizeof(footer));
+   vhd_make_footer(footer, rawsz, VHD_DISK_TYPE_DYNAMIC, sizeof(footer));
if (sparse_write(fd, footer, sizeof(footer))  0)
return (errno);
 
+   bat_entries = imgsz / VHD_BLOCK_SIZE;
memset(header, 0, sizeof(header));
be64enc(header.cookie, VHD_HEADER_COOKIE);
be64enc(header.data_offset, ~0ULL);
@@ -321,7 +349,7 @@ vhd_dyn_write(int fd)
blk = 0;
blkcnt = VHD_BLOCK_SIZE / secsz;
error = 0;
-   nblks = image_get_size();
+   nblks = rawsz / secsz;
while (blk  nblks) {
if (!image_data(blk, blkcnt)) {
blk += blkcnt;
@@ -331,15 +359,20 @@ vhd_dyn_write(int fd)
error = errno;
break;
}
+   /* Handle partial last block */
+   if (blk + blkcnt  nblks)
+   blkcnt = nblks - blk;
error = image_copyout_region(fd, blk, blkcnt);
if (error)
break;
blk += blkcnt;
}
free(bitmap);
-   if (blk != nblks)
+   if (error)
+   return (error);
+   error = image_copyout_zeroes(fd, imgsz - rawsz);
+   if (error)
return (error);
-
if (sparse_write(fd, footer, sizeof(footer))  0)
return (errno);
 
@@ -362,24 +395,9 @@ FORMAT_DEFINE(vhd_dyn_format);
 static int
 vhd_fix_resize(lba_t imgsz)
 {
-   struct vhd_geom geom;
-   int64_t imagesz;
+   uint64_t imagesz;
 
-   /*
-* Round the image size to the pre-determined geometry that
-* matches the image size. This circular dependency implies
-* that we need to loop to handle boundary conditions.
-*/
-   imgsz *= secsz;
-   imagesz = imgsz;
-   while (1) {
-   vhd_geometry(imagesz, geom);
-   imagesz = (int64_t)geom.cylinders * geom.heads *
-   geom.sectors * VHD_SECTOR_SIZE;
-   if (imagesz = imgsz)
-  

Re: svn commit: r286395 - head/usr.bin/mkimg

2015-08-06 Thread Marcel Moolenaar

 On Aug 6, 2015, at 9:31 PM, Glen Barber g...@freebsd.org wrote:
 
 On Fri, Aug 07, 2015 at 04:27:52AM +, Marcel Moolenaar wrote:
 Author: marcel
 Date: Fri Aug  7 04:27:51 2015
 New Revision: 286395
 URL: https://svnweb.freebsd.org/changeset/base/286395
 
 Log:
  Fix the dynamic VHD format to work with qemu. The size of the disk
  is taken to match the geometry and only when the geometry is max'd
  out, is the actual recorded size taken.
 
  Note that qemu has the same logic for the fixed VHD format. However
  that is known to conflict with Microsoft Azure, where the recorded
  size of the image is what counts.
 
 
 I'll test this out on the next 11-CURRENT builds.  (Based on the content
 of the commit log, it's unclear to me if you received my last reply on
 this topic, so if you didn't let me know.)

I tested this in Azure: the fixed format VHD hasn't been
changed.

--
Marcel Moolenaar
mar...@xcllnt.net




signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r286212 - head/tools/bus_space/examples

2015-08-02 Thread Marcel Moolenaar
Author: marcel
Date: Sun Aug  2 21:24:03 2015
New Revision: 286212
URL: https://svnweb.freebsd.org/changeset/base/286212

Log:
  Add an example program (in Python) for the AMD Am79c900 (ILACC)
  ethernet controller. The ethernet controller is emulated by VMware
  Fusion (for example) and is a good device to demonstrate how to use
  the bus space and busdma functions due to its simple programming.
  
  The program sets up the DMA structures, sends a DHCP discover packet,
  waits 2 seconds, and iterates over the receive ring for an offer.

Added:
  head/tools/bus_space/examples/
  head/tools/bus_space/examples/am79c900_diag.py   (contents, props changed)

Added: head/tools/bus_space/examples/am79c900_diag.py
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/bus_space/examples/am79c900_diag.py  Sun Aug  2 21:24:03 
2015(r286212)
@@ -0,0 +1,344 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2014 Marcel Moolenaar
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#notice, this list of conditions and the following disclaimer in the
+#documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+'''
+Simple diagnostics program fo the AMD Am89c900 series ILACC.
+This ethernet controller is emulated by VMware Fusion among
+possibly other virtualization platforms.
+
+The datasheet can be found here:
+http://support.amd.com/TechDocs/18219.pdf
+
+This example program sends a single DHCP discovery packet,
+waits 2 seconds and then iterates over the receive ring for
+a targeted packet.
+
+For this program to function, connect the network interface
+to a network with a DHCP server. In VMware Fusion this can
+best be done by configuring the interface as a NAT interface
+using the Share with my Mac setting.
+'''
+
+import ctypes
+import logging
+import os
+import sys
+import time
+
+sys.path.append('/usr/lib')
+
+import bus
+import busdma
+
+
+# ILACC initialization block definition
+class initblock(ctypes.LittleEndianStructure):
+_fields_ = [('mode', ctypes.c_uint32),
+('hwaddr', ctypes.c_uint8 * 6),
+('_pad1_', ctypes.c_uint16),
+('filter', ctypes.c_uint16 * 4),
+('rxdesc', ctypes.c_uint32),
+('txdesc', ctypes.c_uint32),
+('_pad2_', ctypes.c_uint32)]
+
+
+# ILACC ring buffer descriptor
+class bufdesc(ctypes.LittleEndianStructure):
+_fields_ = [('buffer', ctypes.c_uint32),
+('flags', ctypes.c_uint32),
+('length', ctypes.c_uint32),
+('_pad_', ctypes.c_uint32)]
+
+
+# The DHCP packet definition (incl. all headers)
+class packet(ctypes.BigEndianStructure):
+_pack_ = 1
+_fields_ = [('eth_dest', ctypes.c_uint8 * 6),
+('eth_src', ctypes.c_uint8 * 6),
+('eth_type', ctypes.c_uint16),
+('ip_vl', ctypes.c_uint8),
+('ip_de', ctypes.c_uint8),
+('ip_len', ctypes.c_uint16),
+('ip_id', ctypes.c_uint16),
+('ip_ff', ctypes.c_uint16),
+('ip_ttl', ctypes.c_uint8),
+('ip_proto', ctypes.c_uint8),
+('ip_cksum', ctypes.c_uint16),
+('ip_src', ctypes.c_uint32),
+('ip_dest', ctypes.c_uint32),
+('udp_src', ctypes.c_uint16),
+('udp_dest', ctypes.c_uint16),
+('udp_len', ctypes.c_uint16),
+('udp_cksum', ctypes.c_uint16),
+('bootp_op', ctypes.c_uint8),
+('bootp_htype', ctypes.c_uint8),
+('bootp_hlen', ctypes.c_uint8),
+('bootp_hops', ctypes.c_uint8),
+('bootp_xid', ctypes.c_uint32),
+('bootp_secs', ctypes.c_uint16

svn commit: r286215 - head/usr.bin/mkimg

2015-08-02 Thread Marcel Moolenaar
Author: marcel
Date: Mon Aug  3 01:24:48 2015
New Revision: 286215
URL: https://svnweb.freebsd.org/changeset/base/286215

Log:
  Make image_copyout_zeroes() an interface function.

Modified:
  head/usr.bin/mkimg/image.c
  head/usr.bin/mkimg/image.h

Modified: head/usr.bin/mkimg/image.c
==
--- head/usr.bin/mkimg/image.c  Mon Aug  3 01:22:49 2015(r286214)
+++ head/usr.bin/mkimg/image.c  Mon Aug  3 01:24:48 2015(r286215)
@@ -517,14 +517,14 @@ image_copyout_memory(int fd, size_t size
return (0);
 }
 
-static int
-image_copyout_zeroes(int fd, size_t size)
+int
+image_copyout_zeroes(int fd, size_t count)
 {
static uint8_t *zeroes = NULL;
size_t sz;
int error;
 
-   if (lseek(fd, (off_t)size, SEEK_CUR) != -1)
+   if (lseek(fd, (off_t)count, SEEK_CUR) != -1)
return (0);
 
/*
@@ -537,12 +537,12 @@ image_copyout_zeroes(int fd, size_t size
return (ENOMEM);
}
 
-   while (size  0) {
-   sz = (size  secsz) ? secsz : size;
+   while (count  0) {
+   sz = (count  secsz) ? secsz : count;
error = image_copyout_memory(fd, sz, zeroes);
if (error)
return (error);
-   size -= sz;
+   count -= sz;
}
return (0);
 }

Modified: head/usr.bin/mkimg/image.h
==
--- head/usr.bin/mkimg/image.h  Mon Aug  3 01:22:49 2015(r286214)
+++ head/usr.bin/mkimg/image.h  Mon Aug  3 01:24:48 2015(r286215)
@@ -35,6 +35,7 @@ int image_copyin(lba_t blk, int fd, uint
 int image_copyout(int fd);
 int image_copyout_done(int fd);
 int image_copyout_region(int fd, lba_t blk, lba_t size);
+int image_copyout_zeroes(int fd, size_t count);
 int image_data(lba_t blk, lba_t size);
 lba_t image_get_size(void);
 int image_init(void);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286176 - in head/tools/bus_space: . C Python

2015-08-01 Thread Marcel Moolenaar
Author: marcel
Date: Sun Aug  2 01:09:30 2015
New Revision: 286176
URL: https://svnweb.freebsd.org/changeset/base/286176

Log:
  Rename busdma_sync() to busdma_sync_range() and rename the
  base and size parameters to ofs and len (resp). Add a new
  busdma_sync() that makes the entire MD coherent.

Modified:
  head/tools/bus_space/C/lang.c
  head/tools/bus_space/C/libbus.h
  head/tools/bus_space/Python/lang.c
  head/tools/bus_space/busdma.c
  head/tools/bus_space/busdma.h

Modified: head/tools/bus_space/C/lang.c
==
--- head/tools/bus_space/C/lang.c   Sun Aug  2 00:56:16 2015
(r286175)
+++ head/tools/bus_space/C/lang.c   Sun Aug  2 01:09:30 2015
(r286176)
@@ -227,8 +227,15 @@ busdma_seg_get_size(busdma_seg_t seg)
 }
 
 int
-busdma_sync(busdma_md_t md, int op, bus_addr_t base, bus_size_t size)
+busdma_sync(busdma_md_t md, int op)
 {
 
-   return (bd_sync(md, op, base, size));
+   return (bd_sync(md, op, 0UL, ~0UL));
+}
+
+int
+busdma_sync_range(busdma_md_t md, int op, bus_size_t ofs, bus_size_t len)
+{
+
+   return (bd_sync(md, op, ofs, len));
 }

Modified: head/tools/bus_space/C/libbus.h
==
--- head/tools/bus_space/C/libbus.h Sun Aug  2 00:56:16 2015
(r286175)
+++ head/tools/bus_space/C/libbus.h Sun Aug  2 01:09:30 2015
(r286176)
@@ -78,6 +78,7 @@ bus_size_tbusdma_seg_get_size(busdma_se
 #defineBUSDMA_SYNC_PREWRITE4
 #defineBUSDMA_SYNC_POSTWRITE   8
 
-intbusdma_sync(busdma_md_t md, int op, bus_addr_t, bus_size_t);
+intbusdma_sync(busdma_md_t md, int op);
+intbusdma_sync_range(busdma_md_t md, int op, bus_size_t, bus_size_t);
 
 #endif /* _LIBBUS_SPACE_H_ */

Modified: head/tools/bus_space/Python/lang.c
==
--- head/tools/bus_space/Python/lang.c  Sun Aug  2 00:56:16 2015
(r286175)
+++ head/tools/bus_space/Python/lang.c  Sun Aug  2 01:09:30 2015
(r286176)
@@ -384,12 +384,27 @@ busdma_seg_get_size(PyObject *self, PyOb
 static PyObject *
 busdma_sync(PyObject *self, PyObject *args)
 {
-   u_long base, size;
int error, mdid, op;
 
-   if (!PyArg_ParseTuple(args, iikk, mdid, op, base, size))
+   if (!PyArg_ParseTuple(args, ii, mdid, op))
return (NULL);
-   error = bd_sync(mdid, op, base, size);
+   error = bd_sync(mdid, op, 0UL, ~0UL);
+   if (error) {
+   PyErr_SetString(PyExc_IOError, strerror(error));
+   return (NULL);
+   }
+   Py_RETURN_NONE;
+}
+
+static PyObject *
+busdma_sync_range(PyObject *self, PyObject *args)
+{
+   u_long ofs, len;
+   int error, mdid, op;
+
+   if (!PyArg_ParseTuple(args, iikk, mdid, op, ofs, len))
+   return (NULL);
+   error = bd_sync(mdid, op, ofs, len);
if (error) {
PyErr_SetString(PyExc_IOError, strerror(error));
return (NULL);
@@ -448,7 +463,9 @@ static PyMethodDef busdma_methods[] = {
Return the size of the segment. },
 
 { sync, busdma_sync, METH_VARARGS,
-   Keep memory/caches coherent WRT to DMA. },
+   Make the entire memory descriptor coherent WRT to DMA. },
+{ sync_range, busdma_sync_range, METH_VARARGS,
+   Make part of the memory descriptor coherent WRT to DMA. },
 
 { NULL, NULL, 0, NULL }
 };

Modified: head/tools/bus_space/busdma.c
==
--- head/tools/bus_space/busdma.c   Sun Aug  2 00:56:16 2015
(r286175)
+++ head/tools/bus_space/busdma.c   Sun Aug  2 01:09:30 2015
(r286176)
@@ -536,7 +536,7 @@ bd_seg_get_size(int sid, u_long *size_p)
 }
 
 int
-bd_sync(int mdid, u_int op, u_long base, u_long size)
+bd_sync(int mdid, u_int op, u_long ofs, u_long len)
 {
struct proto_ioc_busdma ioc;
struct obj *md;
@@ -549,8 +549,8 @@ bd_sync(int mdid, u_int op, u_long base,
ioc.request = PROTO_IOC_BUSDMA_SYNC;
ioc.key = md-key;
ioc.u.sync.op = op;
-   ioc.u.sync.base = base;
-   ioc.u.sync.size = size;
+   ioc.u.sync.base = ofs;
+   ioc.u.sync.size = len;
if (ioctl(md-fd, PROTO_IOC_BUSDMA, ioc) == -1)
return (errno);
 

Modified: head/tools/bus_space/busdma.h
==
--- head/tools/bus_space/busdma.h   Sun Aug  2 00:56:16 2015
(r286175)
+++ head/tools/bus_space/busdma.h   Sun Aug  2 01:09:30 2015
(r286176)
@@ -51,6 +51,6 @@ int   bd_md_next_seg(int mdid, int sid);
 intbd_seg_get_addr(int sid, u_long *);
 intbd_seg_get_size(int sid, u_long *);
 
-intbd_sync(int mdid, u_int op, u_long base, u_long size);
+intbd_sync(int mdid, u_int op, u_long ofs, u_long len);
 
 #endif /* 

svn commit: r285927 - head/sys/dev/proto

2015-07-27 Thread Marcel Moolenaar
Author: marcel
Date: Tue Jul 28 04:54:05 2015
New Revision: 285927
URL: https://svnweb.freebsd.org/changeset/base/285927

Log:
  Check the sync operation.

Modified:
  head/sys/dev/proto/proto_busdma.c

Modified: head/sys/dev/proto/proto_busdma.c
==
--- head/sys/dev/proto/proto_busdma.c   Tue Jul 28 02:32:40 2015
(r285926)
+++ head/sys/dev/proto/proto_busdma.c   Tue Jul 28 04:54:05 2015
(r285927)
@@ -325,7 +325,12 @@ static int
 proto_busdma_sync(struct proto_busdma *busdma, struct proto_md *md,
 struct proto_ioc_busdma *ioc)
 {
- 
+   u_int ops;
+
+   ops = BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE |
+   BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE;
+   if (ioc-u.sync.op  ~ops)
+   return (EINVAL);
if (!md-physaddr)
return (ENXIO);
bus_dmamap_sync(md-bd_tag, md-bd_map, ioc-u.sync.op);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r285903 - in head/tools/bus_space: . C Python

2015-07-26 Thread Marcel Moolenaar
Author: marcel
Date: Sun Jul 26 21:37:31 2015
New Revision: 285903
URL: https://svnweb.freebsd.org/changeset/base/285903

Log:
  Change the dev argument from a full path to just the device
  identification (e.g. isa:0x3f0 or pci0:2:1:0). In libbus,
  the device is turned into a path name. For bus_space_map(),
  the resource is now specified in a second argument.
  Before:
bus.map('/dev/proto/pci0:2:1:0/pcicfg')
busdma.tag_create('/dev/proto/pci0:2:1:0/busdma', ...)
  Now:
bus.map('pci0:2:1:0', 'pcicfg')
busdma.tag_create('pci0:2:1:0', ...)

Modified:
  head/tools/bus_space/C/lang.c
  head/tools/bus_space/C/libbus.h
  head/tools/bus_space/Python/lang.c
  head/tools/bus_space/bus.c
  head/tools/bus_space/bus.h
  head/tools/bus_space/busdma.c

Modified: head/tools/bus_space/C/lang.c
==
--- head/tools/bus_space/C/lang.c   Sun Jul 26 19:47:46 2015
(r285902)
+++ head/tools/bus_space/C/lang.c   Sun Jul 26 21:37:31 2015
(r285903)
@@ -80,10 +80,10 @@ bus_write_4(int rid, long ofs, uint32_t 
 }
 
 int
-bus_map(const char *dev)
+bus_map(const char *dev, const char *resource)
 {
 
-   return (bs_map(dev));
+   return (bs_map(dev, resource));
 }
 
 int

Modified: head/tools/bus_space/C/libbus.h
==
--- head/tools/bus_space/C/libbus.h Sun Jul 26 19:47:46 2015
(r285902)
+++ head/tools/bus_space/C/libbus.h Sun Jul 26 21:37:31 2015
(r285903)
@@ -29,7 +29,7 @@
 #ifndef _LIBBUS_SPACE_H_
 #define_LIBBUS_SPACE_H_
 
-intbus_map(const char *dev);
+intbus_map(const char *dev, const char *resource);
 int16_tbus_read_1(int rid, long ofs);
 int32_tbus_read_2(int rid, long ofs);
 int64_t bus_read_4(int rid, long ofs);

Modified: head/tools/bus_space/Python/lang.c
==
--- head/tools/bus_space/Python/lang.c  Sun Jul 26 19:47:46 2015
(r285902)
+++ head/tools/bus_space/Python/lang.c  Sun Jul 26 21:37:31 2015
(r285903)
@@ -131,12 +131,12 @@ bus_write_4(PyObject *self, PyObject *ar
 static PyObject *
 bus_map(PyObject *self, PyObject *args)
 {
-   char *dev;
+   char *dev, *resource;
int rid;
 
-   if (!PyArg_ParseTuple(args, s, dev))
+   if (!PyArg_ParseTuple(args, ss, dev, resource))
return (NULL);
-   rid = bs_map(dev);
+   rid = bs_map(dev, resource);
if (rid == -1) {
PyErr_SetString(PyExc_IOError, strerror(errno));
return (NULL);

Modified: head/tools/bus_space/bus.c
==
--- head/tools/bus_space/bus.c  Sun Jul 26 19:47:46 2015(r285902)
+++ head/tools/bus_space/bus.c  Sun Jul 26 21:37:31 2015(r285903)
@@ -32,6 +32,7 @@ __FBSDID($FreeBSD$);
 #include errno.h
 #include fcntl.h
 #include limits.h
+#include stdio.h
 #include stdlib.h
 #include unistd.h
 
@@ -92,19 +93,25 @@ rid_lookup(int rid)
 }
 
 int
-bs_map(const char *dev)
+bs_map(const char *dev, const char *res)
 {
+   char path[PATH_MAX];
struct proto_ioc_region region;
struct resource *r;
-   int rid;
+   int len, rid;
 
+   len = snprintf(path, PATH_MAX, /dev/proto/%s/%s, dev, res);
+   if (len = PATH_MAX) {
+   errno = EINVAL;
+   return (-1);
+   }
rid = rid_alloc();
if (rid == -1)
return (-1);
r = rid_lookup(rid);
if (r == NULL)
return (-1);
-   r-fd = open(dev, O_RDWR);
+   r-fd = open(path, O_RDWR);
if (r-fd == -1)
return (-1);
r-rid = -1;

Modified: head/tools/bus_space/bus.h
==
--- head/tools/bus_space/bus.h  Sun Jul 26 19:47:46 2015(r285902)
+++ head/tools/bus_space/bus.h  Sun Jul 26 21:37:31 2015(r285903)
@@ -29,7 +29,7 @@
 #ifndef _TOOLS_BUS_SPACE_H_
 #define_TOOLS_BUS_SPACE_H_
 
-int bs_map(const char *dev);
+int bs_map(const char *dev, const char *res);
 int bs_read(int rid, off_t ofs, void *buf, ssize_t bufsz);
 int bs_subregion(int rid0, long ofs, long sz);
 int bs_unmap(int rid);

Modified: head/tools/bus_space/busdma.c
==
--- head/tools/bus_space/busdma.c   Sun Jul 26 19:47:46 2015
(r285902)
+++ head/tools/bus_space/busdma.c   Sun Jul 26 21:37:31 2015
(r285903)
@@ -33,6 +33,7 @@ __FBSDID($FreeBSD$);
 #include errno.h
 #include fcntl.h
 #include limits.h
+#include stdio.h
 #include stdlib.h
 #include string.h
 #include unistd.h
@@ -183,10 +184,16 @@ int
 bd_tag_create(const char *dev, u_long align, u_long bndry, u_long maxaddr,
 u_long maxsz, u_int nsegs, u_long 

svn commit: r285893 - head/tools/bus_space

2015-07-26 Thread Marcel Moolenaar
Author: marcel
Date: Sun Jul 26 16:40:51 2015
New Revision: 285893
URL: https://svnweb.freebsd.org/changeset/base/285893

Log:
  Remove debugging output. We should have tracing instead.

Modified:
  head/tools/bus_space/busdma.c

Modified: head/tools/bus_space/busdma.c
==
--- head/tools/bus_space/busdma.c   Sun Jul 26 16:39:37 2015
(r285892)
+++ head/tools/bus_space/busdma.c   Sun Jul 26 16:40:51 2015
(r285893)
@@ -33,7 +33,6 @@ __FBSDID($FreeBSD$);
 #include errno.h
 #include fcntl.h
 #include limits.h
-#include stdio.h
 #include stdlib.h
 #include string.h
 #include unistd.h
@@ -348,10 +347,6 @@ bd_md_load(int mdid, void *buf, u_long l
if (ioctl(md-fd, PROTO_IOC_BUSDMA, ioc) == -1)
return (errno);
 
-   printf(XXX: %s: phys(%d, %#lx), bus(%d, %#lx)\n, __func__,
-   ioc.u.md.phys_nsegs, ioc.u.md.phys_addr,
-   ioc.u.md.bus_nsegs, ioc.u.md.bus_addr);
-
error = bd_md_add_seg(md, BUSDMA_MD_VIRT, ioc.u.md.virt_addr, len);
error = bd_md_add_seg(md, BUSDMA_MD_PHYS, ioc.u.md.phys_addr, len);
error = bd_md_add_seg(md, BUSDMA_MD_BUS, ioc.u.md.bus_addr, len);
@@ -412,10 +407,6 @@ bd_mem_alloc(int tid, u_int flags)
tag-refcnt++;
md-key = ioc.result;
 
-   printf(XXX: %s: phys(%d, %#lx), bus(%d, %#lx)\n, __func__,
-   ioc.u.md.phys_nsegs, ioc.u.md.phys_addr,
-   ioc.u.md.bus_nsegs, ioc.u.md.bus_addr);
-
/* XXX we need to support multiple segments */
assert(ioc.u.md.phys_nsegs == 1);
assert(ioc.u.md.bus_nsegs == 1);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r285892 - head/sys/dev/proto

2015-07-26 Thread Marcel Moolenaar
Author: marcel
Date: Sun Jul 26 16:39:37 2015
New Revision: 285892
URL: https://svnweb.freebsd.org/changeset/base/285892

Log:
  o   make sure the boundary is a power of 2, when not zero.
  o   don't convert 0 to ~0 just so that we can use MIN. ~0 is not a
  valid boundary. Introduce BNDRY_MIN that deals with 0 values
  that mean no boundary.

Modified:
  head/sys/dev/proto/proto_busdma.c

Modified: head/sys/dev/proto/proto_busdma.c
==
--- head/sys/dev/proto/proto_busdma.c   Sun Jul 26 14:46:42 2015
(r285891)
+++ head/sys/dev/proto/proto_busdma.c   Sun Jul 26 16:39:37 2015
(r285892)
@@ -51,6 +51,9 @@ __FBSDID($FreeBSD$);
 
 MALLOC_DEFINE(M_PROTO_BUSDMA, proto_busdma, DMA management data);
 
+#defineBNDRY_MIN(a, b) \
+   (((a) == 0) ? (b) : (((b) == 0) ? (a) : MIN((a), (b
+
 struct proto_callback_bundle {
struct proto_busdma *busdma;
struct proto_md *md;
@@ -63,6 +66,11 @@ proto_busdma_tag_create(struct proto_bus
 {
struct proto_tag *tag;
 
+   /* Make sure that when a boundary is specified, it's a power of 2 */
+   if (ioc-u.tag.bndry != 0 
+   (ioc-u.tag.bndry  (ioc-u.tag.bndry - 1)) != 0)
+   return (EINVAL);
+
/*
 * If nsegs is 1, ignore maxsegsz. What this means is that if we have
 * just 1 segment, then maxsz should be equal to maxsegsz. To keep it
@@ -71,16 +79,12 @@ proto_busdma_tag_create(struct proto_bus
if (ioc-u.tag.maxsegsz  ioc-u.tag.maxsz || ioc-u.tag.nsegs == 1)
ioc-u.tag.maxsegsz = ioc-u.tag.maxsz;
 
-   /* A bndry of 0 really means ~0, or no boundary. */
-   if (ioc-u.tag.bndry == 0)
-   ioc-u.tag.bndry = ~0U;
-
tag = malloc(sizeof(*tag), M_PROTO_BUSDMA, M_WAITOK | M_ZERO);
if (parent != NULL) {
tag-parent = parent;
LIST_INSERT_HEAD(parent-children, tag, peers);
tag-align = MAX(ioc-u.tag.align, parent-align);
-   tag-bndry = MIN(ioc-u.tag.bndry, parent-bndry);
+   tag-bndry = BNDRY_MIN(ioc-u.tag.bndry, parent-bndry);
tag-maxaddr = MIN(ioc-u.tag.maxaddr, parent-maxaddr);
tag-maxsz = MIN(ioc-u.tag.maxsz, parent-maxsz);
tag-maxsegsz = MIN(ioc-u.tag.maxsegsz, parent-maxsegsz);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r285707 - in head: share/man/man4 sys/dev/proto

2015-07-19 Thread Marcel Moolenaar
Author: marcel
Date: Sun Jul 19 23:37:45 2015
New Revision: 285707
URL: https://svnweb.freebsd.org/changeset/base/285707

Log:
  Check the hw.proto.attach environment variable for devices that
  proto(4) should attach to instead of the normal driver.
  
  Document the variable.

Modified:
  head/share/man/man4/proto.4
  head/sys/dev/proto/proto.h
  head/sys/dev/proto/proto_bus_isa.c
  head/sys/dev/proto/proto_bus_pci.c
  head/sys/dev/proto/proto_core.c

Modified: head/share/man/man4/proto.4
==
--- head/share/man/man4/proto.4 Sun Jul 19 22:26:02 2015(r285706)
+++ head/share/man/man4/proto.4 Sun Jul 19 23:37:45 2015(r285707)
@@ -25,7 +25,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd July 3, 2015
+.Dd July 19, 2015
 .Dt PROTO 4
 .Os
 .\
@@ -47,6 +47,12 @@ module at boot time, place the following
 .Bd -literal -offset indent
 proto_load=YES
 .Ed
+.Pp
+To have the driver attach to a device instead of its regular driver,
+mention it in the list of devices assigned to the following loader variable:
+.Bd -ragged -offset indent
+hw.proto.attach=desc[,desc]
+.Ed
 .\
 .Sh DESCRIPTION
 The

Modified: head/sys/dev/proto/proto.h
==
--- head/sys/dev/proto/proto.h  Sun Jul 19 22:26:02 2015(r285706)
+++ head/sys/dev/proto/proto.h  Sun Jul 19 23:37:45 2015(r285707)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2014 Marcel Moolenaar
+ * Copyright (c) 2014, 2015 Marcel Moolenaar
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -61,6 +61,7 @@ extern char proto_driver_name[];
 
 int proto_add_resource(struct proto_softc *, int, int, struct resource *);
 
+int proto_probe(device_t dev, const char *prefix, char ***devnamesp);
 int proto_attach(device_t dev);
 int proto_detach(device_t dev);
 

Modified: head/sys/dev/proto/proto_bus_isa.c
==
--- head/sys/dev/proto/proto_bus_isa.c  Sun Jul 19 22:26:02 2015
(r285706)
+++ head/sys/dev/proto/proto_bus_isa.c  Sun Jul 19 23:37:45 2015
(r285707)
@@ -59,6 +59,9 @@ static driver_t proto_isa_driver = {
sizeof(struct proto_softc),
 };
 
+static char proto_isa_prefix[] = isa;
+static char **proto_isa_devnames;
+
 static int
 proto_isa_probe(device_t dev)
 {
@@ -77,12 +80,12 @@ proto_isa_probe(device_t dev)
return (ENODEV);
 
sb = sbuf_new_auto();
-   sbuf_printf(sb, isa:%#lx, rman_get_start(res));
+   sbuf_printf(sb, %s:%#lx, proto_isa_prefix, rman_get_start(res));
sbuf_finish(sb);
device_set_desc_copy(dev, sbuf_data(sb));
sbuf_delete(sb);
bus_release_resource(dev, type, rid, res);
-   return (BUS_PROBE_HOOVER);
+   return (proto_probe(dev, proto_isa_prefix, proto_isa_devnames));
 }
 
 static int

Modified: head/sys/dev/proto/proto_bus_pci.c
==
--- head/sys/dev/proto/proto_bus_pci.c  Sun Jul 19 22:26:02 2015
(r285706)
+++ head/sys/dev/proto/proto_bus_pci.c  Sun Jul 19 23:37:45 2015
(r285707)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2014 Marcel Moolenaar
+ * Copyright (c) 2014, 2015 Marcel Moolenaar
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -59,6 +59,9 @@ static driver_t proto_pci_driver = {
sizeof(struct proto_softc),
 };
 
+static char proto_pci_prefix[] = pci;
+static char **proto_pci_devnames;
+
 static int
 proto_pci_probe(device_t dev)
 {
@@ -68,12 +71,12 @@ proto_pci_probe(device_t dev)
return (ENXIO);
 
sb = sbuf_new_auto();
-   sbuf_printf(sb, pci%d:%d:%d:%d, pci_get_domain(dev),
+   sbuf_printf(sb, %s%d:%d:%d:%d, proto_pci_prefix, pci_get_domain(dev),
pci_get_bus(dev), pci_get_slot(dev), pci_get_function(dev));
sbuf_finish(sb);
device_set_desc_copy(dev, sbuf_data(sb));
sbuf_delete(sb);
-   return (BUS_PROBE_HOOVER);
+   return (proto_probe(dev, proto_pci_prefix, proto_pci_devnames));
 }
 
 static int

Modified: head/sys/dev/proto/proto_core.c
==
--- head/sys/dev/proto/proto_core.c Sun Jul 19 22:26:02 2015
(r285706)
+++ head/sys/dev/proto/proto_core.c Sun Jul 19 23:37:45 2015
(r285707)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2014 Marcel Moolenaar
+ * Copyright (c) 2014, 2015 Marcel Moolenaar
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -120,6 +120,62 @@ proto_intr(void *arg)
 #endif
 
 int
+proto_probe(device_t dev, const char *prefix, char ***devnamesp)
+{
+   char **devnames = *devnamesp;
+   const char *dn, *ep, *ev;
+   size_t pfxlen;
+   int idx, names;
+
+   if (devnames == NULL

svn commit: r285099 - head/share/man/man4

2015-07-03 Thread Marcel Moolenaar
Author: marcel
Date: Fri Jul  3 16:20:14 2015
New Revision: 285099
URL: https://svnweb.freebsd.org/changeset/base/285099

Log:
  Minor update to the proto(4) man page:
  1.  We now support ISA devices
  2.  DMA support has been added

Modified:
  head/share/man/man4/proto.4

Modified: head/share/man/man4/proto.4
==
--- head/share/man/man4/proto.4 Fri Jul  3 16:02:06 2015(r285098)
+++ head/share/man/man4/proto.4 Fri Jul  3 16:20:14 2015(r285099)
@@ -1,5 +1,5 @@
 .\
-.\ Copyright (c) 2014 Marcel Moolenaar
+.\ Copyright (c) 2014, 2015 Marcel Moolenaar
 .\ All rights reserved.
 .\
 .\ Redistribution and use in source and binary forms, with or without
@@ -25,13 +25,13 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd April 29, 2014
+.Dd July 3, 2015
 .Dt PROTO 4
 .Os
 .\
 .Sh NAME
 .Nm proto
-.Nd Driver for prototyping and H/W diagnostics
+.Nd Generic prototyping and diagnostics driver
 .\
 .Sh SYNOPSIS
 To compile this driver into the kernel,
@@ -51,9 +51,9 @@ proto_load=YES
 .Sh DESCRIPTION
 The
 .Nm
-device driver attaches to PCI devices when no other device drivers are
-present and creates device special files for all resources associated
-with the device.
+device driver attaches to PCI or ISA devices when no other device drivers
+are present for those devices and it creates device special files for all
+resources associated with the device.
 The driver itself has no knowledge of the device it attaches to.
 Programs can open these device special files and perform register-level
 reads and writes.
@@ -75,9 +75,9 @@ All device special files corresponding t
 with
 .Pa pcid:b:s:f
 representing the location of the PCI device in the PCI hierarchy.
-A location includes:
+A PCI location includes:
 .Pp
-.Bl -tag -width XX -compact
+.Bl -tag -width XX -compact -offset indent
 .It d
 The PCI domain number
 .It b
@@ -91,6 +91,10 @@ The PCI function number
 Every PCI device has a device special file called
 .Pa pcicfg .
 This device special file gives access to the PCI configuration space.
+A device special file called
+.Pa busdma
+is also created.
+This device special file provides the interfaces needed for doing DMA.
 For each valid base address register (BAR), a device special file is created
 that contains the BAR offset and the resource type.
 A resource type can be either
@@ -98,15 +102,49 @@ A resource type can be either
 or
 .Pa mem
 representing I/O port or memory mapped I/O space (resp.)
+.Pp
+ISA devices do not have a location. Instead, they are identified by the
+first I/O port address or first memory mapped I/O address.
+Consequently, all device special files corresponding to an ISA device are
+located under
+.Pa /dev/proto/isa:addr
+with
+.Pa addr
+the address in hexadecimal notation.
+For each I/O port or memory mapped I/O address, a device special file is
+created that contains the resource identification used by the kernel and
+the resource type.
+The resource type can be either
+.Pa io
+or
+.Pa mem
+representing I/O port or memory mapped I/O space (resp.)
+When the device has a DMA channel assigned to it, a device special file
+with the name
+.Pa busdma
+is created as well.
+This device special file provides the interfaces needed for doing DMA.
+.Pp
+If the ISA device is not a Plug-and-Play device nor present in the ACPI
+device tree, it must have the appropriate hints so that the kernel can
+reserve the resources for it.
 .\
 .Sh EXAMPLES
 A single function PCI device in domain 0, on bus 1, in slot 2 and having a
 single memory mapped I/O region will have the following device special files:
 .Pp
-.Bl -tag -width XX -compact
+.Bl -tag -width XX -compact -offset indent
 .It Pa /dev/proto/pci0:1:2:0/10.mem
 .It Pa /dev/proto/pci0:1:2:0/pcicfg
 .El
+.Pp
+A legacy floppy controller will have the following device files:
+.Pp
+.Bl -tag -width XX -compact -offset indent
+.It Pa /dev/proto/isa:0x3f0/00.io
+.It Pa /dev/proto/isa:0x3f0/01.io
+.It Pa /dev/proto/isa:0x3f0/busdma
+.El
 .\
 .Sh AUTHORS
 The
@@ -123,13 +161,12 @@ It is not advisable to use this driver o
 The
 .Nm
 driver does not yet support interrupts.
-Since interrupts cannot be handled by the driver itself, they must be converted
-into signals and delivered to the program that has registered for interrupts.
-.Pp
-In order to test the transmission or reception of data, some means of doing
-direct memory access (DMA) by the device must be possible.
-This too must be under the control of the program.
-The details of how a program can set up and
-initiate DMA still need to be fleshed out.
-.Pp
-Support for non-PCI devices has not been implemented yet.
+Since interrupts cannot be handled by the driver itself, they must be
+converted into signals and delivered to the program that has registered
+for interrupts.
+A satisfactory mechanism for keeping the interrupt masked during the
+signal handling is still being worked out.
+.Pp
+DMA support for devices other

  1   2   3   4   5   6   7   8   >