Fix divisor calculation for SDHC 3.0.
1/1   -> 0
1/2   -> 1
1/4   -> 2
...
1/2*N -> N
Be a bit more verbose about errors, also pass through error code
from lower layer like other drivers.
Fix tools build on !NetBSD.
devmajor_t not int
include <sys/endian.h> for both the non-tools build,
and the tools build on a host where the file exists.

Fixes a build problem on FreeBSD, reported by Herbert J. Skuhra, where
tools/compat's configure detected that be32dec() and friends were
available in the host's <sys/endian.h>, so tools/compat did not provide
its own versions.
Call prop_dictionary_get_uint32 with uint32_t
Imported and adapted from FreeBSD svn r272166 and r272207; this fixes
false positives for products of primes larger than 2^16. For example,
before this commit:

  $ /usr/games/primes 4295360521 4295360522
  4295360521
but
  $ /usr/games/factor 4295360521
  4295360521: 65539 65539

or
  $ /usr/games/primes 3825123056546413049 3825123056546413050
  3825123056546413049
yet
  $ /usr/games/factor 3825123056546413049
  3825123056546413049: 165479 23115459100831

or
  $ /usr/games/primes 18446744073709551577
  18446744073709551577
although
  $ /usr/games/factor 18446744073709551577
  18446744073709551577: 139646831 132095686967

Incidentally, the above examples show the smallest and largest cases that
were erroneously stated as prime in the range 2^32 .. 3825123056546413049
.. 2^64; the primes(6) program now stops at 3825123056546413050 as
primality tests on larger integers would be by brute force factorization.

In addition, special to the NetBSD version:
. for -d option, skip first difference when start is >65537 as it is incorrect
. corrected usage to mention both the existing -d as well as the new -h option

For original FreeBSD commit message by Colin Percival, see:
http://svnweb.freebsd.org/base?view=revision&revision=272166
debug ld_sdmmc with LD_SDMMC_DEBUG instead of SDMMC_DEBUG
dm_target_t reference count is modified with atomic_{inc,dec}_32 so should
be uint_32_t not int
Use devmajor_t not int
Work around pedantic compiler
Use uint32_t for blocksize as per other uses and to fix warnings
"0" is not guaranteed to be unique
Remove unneeded #include
Convert to USB_HIST.

From Takahiro HAYASHI with tweaks from me.
add some more bit definitions
Use SDn_CLK_REG instead of MMC_CLKCR to setup bus clock; gives a nearly 2x boost in performance in HS mode. Also, make sure to setup PLL6 before probing clocks.
Introduce RPI_HWCURSOR and default to off. The existing code causes
problems with vchiq at the moment.
Add space before "]" in "if [ ... ]" to fix usage error
and test for existence of the correct file.
When creating a vnode with vcache_get() mark the vnode VI_CHANGING until
it is fully initialised.  It may be on the specnode list before it is
fully initialised and revoking it then would panic.

Should prevent the panic from PR kern/49171 (panic when closing a pty).