This commit is contained in:
Attilio Rao 2011-06-22 19:42:32 +00:00
commit 9b571ec6b3
42 changed files with 588 additions and 564 deletions

View File

@ -33,7 +33,7 @@
.\" From: src/bin/pwd/pwd.1,v 1.11 2000/11/20 11:39:39 ru Exp
.\" $FreeBSD$
.\"
.Dd November 24, 2000
.Dd June 21, 2011
.Dt REALPATH 1
.Os
.Sh NAME
@ -42,8 +42,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl q
.Ar path
.Op Ar ...
.Op Ar path ...
.Sh DESCRIPTION
The
.Nm
@ -57,6 +56,11 @@ and
.Pa /../
in
.Ar path .
If
.Ar path
is absent, the current working directory
.Pq Sq Pa .\&
is assumed.
.Pp
If
.Fl q

View File

@ -44,7 +44,8 @@ main(int argc, char *argv[])
{
char buf[PATH_MAX];
char *p;
int ch, i, qflag, rval;
const char *path;
int ch, qflag, rval;
qflag = 0;
while ((ch = getopt(argc, argv, "q")) != -1) {
@ -59,17 +60,16 @@ main(int argc, char *argv[])
}
argc -= optind;
argv += optind;
if (argc < 1)
usage();
path = *argv != NULL ? *argv++ : ".";
rval = 0;
for (i = 0; i < argc; i++) {
if ((p = realpath(argv[i], buf)) == NULL) {
do {
if ((p = realpath(path, buf)) == NULL) {
if (!qflag)
warn("%s", argv[i]);
warn("%s", path);
rval = 1;
} else
(void)printf("%s\n", p);
}
} while ((path = *argv++) != NULL);
exit(rval);
}
@ -77,6 +77,6 @@ static void
usage(void)
{
(void)fprintf(stderr, "usage: realpath [-q] path [...]\n");
(void)fprintf(stderr, "usage: realpath [-q] [path ...]\n");
exit(1);
}

View File

@ -14,7 +14,8 @@
. /etc/rc.subr
name="netwait"
rc_var=`set_rcvar`
rcvar=`set_rcvar`
start_cmd="${name}_start"
stop_cmd=":"

View File

@ -234,7 +234,7 @@ __FBSDID("$FreeBSD$");
#ifdef __sparc64__
# define LG_QUANTUM 4
# define LG_SIZEOF_PTR 3
# define TLS_MODEL /* default */
# define TLS_MODEL __attribute__((tls_model("initial-exec")))
#endif
#ifdef __amd64__
# define LG_QUANTUM 4

View File

@ -5,7 +5,7 @@ BINOWN= root
BINMODE=4555
NO_MAN=
DPADD= ${LIBULOG} ${LIBMD}
LDADD= -lulog -lmd
DPADD= ${LIBULOG}
LDADD= -lulog
.include <bsd.prog.mk>

View File

@ -36,11 +36,11 @@ __FBSDID("$FreeBSD$");
/*
* This setuid helper utility writes user login records to disk.
* Unprivileged processes are not capable of writing records to utmp,
* wtmp and lastlog, but we do want to allow this for pseudo-terminals.
* Because a file descriptor to a pseudo-terminal master device can only
* be obtained by processes using the pseudo-terminal, we expect such a
* descriptor on stdin.
* Unprivileged processes are not capable of writing records to utmpx,
* but we do want to allow this for pseudo-terminals. Because a file
* descriptor to a pseudo-terminal master device can only be obtained by
* processes using the pseudo-terminal, we expect such a descriptor on
* stdin.
*
* It uses the real user ID of the calling process to determine the
* username. It does allow users to log arbitrary hostnames.
@ -49,26 +49,22 @@ __FBSDID("$FreeBSD$");
int
main(int argc, char *argv[])
{
const char *line;
const char *line, *user, *host;
/* Device line name. */
if ((line = ptsname(STDIN_FILENO)) == NULL)
return (EX_USAGE);
if ((argc == 2 || argc == 3) && strcmp(argv[1], "login") == 0) {
struct passwd *pwd;
const char *host = NULL;
/* Username. */
pwd = getpwuid(getuid());
if (pwd == NULL)
user = user_from_uid(getuid(), 1);
if (user == NULL)
return (EX_OSERR);
/* Hostname. */
if (argc == 3)
host = argv[2];
host = argc == 3 ? argv[2] : NULL;
ulog_login(line, pwd->pw_name, host);
ulog_login(line, user, host);
return (EX_OK);
} else if (argc == 2 && strcmp(argv[1], "logout") == 0) {
ulog_logout(line);

View File

@ -1208,8 +1208,11 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl)
if (idx == 0)
errx(EXIT_FAILURE, "missing -i option");
gpart_write_partcode(gp, idx, partcode, partsize);
} else
} else {
if (partsize != VTOC_BOOTSIZE)
errx(EXIT_FAILURE, "invalid bootcode");
gpart_write_partcode_vtoc8(gp, idx, partcode);
}
} else
if (bootcode == NULL)
errx(EXIT_FAILURE, "no -b nor -p");

View File

@ -37,12 +37,12 @@
.\" $TSHeader: src/sbin/growfs/growfs.8,v 1.3 2000/12/12 19:31:00 tomsoft Exp $
.\" $FreeBSD$
.\"
.Dd May 8, 2011
.Dd June 22, 2011
.Dt GROWFS 8
.Os
.Sh NAME
.Nm growfs
.Nd grow size of an existing UFS file system
.Nd expand an existing UFS filesystem
.Sh SYNOPSIS
.Nm
.Op Fl Ny
@ -58,26 +58,26 @@ Before starting
.Nm
the disk must be labeled to a bigger size using
.Xr bsdlabel 8 .
If you wish to grow a file system beyond the boundary of
the slice it resides in, you must re-size the slice using
.Xr fdisk 8
If you wish to grow a filesystem beyond the boundary of
the slice it resides in, you must resize the slice using
.Xr gpart 8
before running
.Nm .
If you are using volumes you must enlarge them by using
.Xr vinum 8 .
.Xr gvinum 8 .
The
.Nm
utility extends the size of the file system on the specified special file.
utility extends the size of the filesystem on the specified special file.
Currently
.Nm
can only enlarge unmounted file systems.
Do not try enlarging a mounted file system, your system may panic and you will
not be able to use the file system any longer.
can only enlarge unmounted filesystems.
Do not try enlarging a mounted filesystem, your system may panic and you will
not be able to use the filesystem any longer.
Most of the
.Xr newfs 8
options cannot be changed by
.Nm .
In fact, you can only increase the size of the file system.
In fact, you can only increase the size of the filesystem.
Use
.Xr tunefs 8
for other changes.
@ -86,8 +86,8 @@ The following options are available:
.Bl -tag -width indent
.It Fl N
.Dq Test mode .
Causes the new file system parameters to be printed out without actually
enlarging the file system.
Causes the new filesystem parameters to be printed out without actually
enlarging the filesystem.
.It Fl y
.Dq Expert mode .
Usually
@ -102,12 +102,12 @@ So use this option with great care!
.It Fl s Ar size
Determines the
.Ar size
of the file system after enlarging in sectors.
of the filesystem after enlarging in sectors.
This value defaults to the size of the raw partition specified in
.Ar special
(in other words,
.Nm
will enlarge the file system to the size of the entire partition).
will enlarge the filesystem to the size of the entire partition).
.El
.Sh EXAMPLES
.Dl growfs -s 4194304 /dev/vinum/testvol
@ -119,12 +119,12 @@ up to 2GB if there is enough space in
.Sh SEE ALSO
.Xr bsdlabel 8 ,
.Xr dumpfs 8 ,
.Xr fdisk 8 ,
.Xr ffsinfo 8 ,
.Xr fsck 8 ,
.Xr gpart 8 ,
.Xr newfs 8 ,
.Xr tunefs 8 ,
.Xr vinum 8
.Xr gvinum 8
.Sh HISTORY
The
.Nm
@ -144,12 +144,12 @@ There may be cases on
.Fx
3.x only, when
.Nm
does not recognize properly whether or not the file system is mounted and
does not recognize properly whether or not the filesystem is mounted and
exits with an error message.
Then please use
.Nm
.Fl y
if you are sure that the file system is not mounted.
if you are sure that the filesystem is not mounted.
It is also recommended to always use
.Xr fsck 8
after enlarging (just to be on the safe side).
@ -183,8 +183,8 @@ on the first cylinder group to verify that
in the CYLINDER SUMMARY (internal cs) of the CYLINDER GROUP
.Em cgr0
has enough blocks.
As a rule of thumb for default file system parameters one block is needed for
every 2 GB of total file system size.
As a rule of thumb for default filesystem parameters one block is needed for
every 2 GB of total filesystem size.
.Pp
Normally
.Nm

View File

@ -160,7 +160,7 @@ static void get_dev_size(int, int *);
/* ************************************************************ growfs ***** */
/*
* Here we actually start growing the file system. We basically read the
* Here we actually start growing the filesystem. We basically read the
* cylinder summary from the first cylinder group as we want to update
* this on the fly during our various operations. First we handle the
* changes in the former last cylinder group. Afterwards we create all new
@ -231,7 +231,7 @@ growfs(int fsi, int fso, unsigned int Nflag)
updjcg(osblock.fs_ncg-1, modtime, fsi, fso, Nflag);
/*
* Dump out summary information about file system.
* Dump out summary information about filesystem.
*/
# define B2MBFACTOR (1 / (1024.0 * 1024.0))
printf("growfs: %.1fMB (%jd sectors) block size %d, fragment size %d\n",
@ -435,7 +435,7 @@ initcg(int cylno, time_t modtime, int fso, unsigned int Nflag)
if (acg.cg_nextfreeoff > (unsigned)sblock.fs_cgsize) {
/*
* This should never happen as we would have had that panic
* already on file system creation
* already on filesystem creation
*/
errx(37, "panic: cylinder group too big");
}
@ -446,7 +446,7 @@ initcg(int cylno, time_t modtime, int fso, unsigned int Nflag)
acg.cg_cs.cs_nifree--;
}
/*
* For the old file system, we have to initialize all the inodes.
* For the old filesystem, we have to initialize all the inodes.
*/
if (sblock.fs_magic == FS_UFS1_MAGIC) {
bzero(iobuf, sblock.fs_bsize);
@ -670,7 +670,7 @@ cond_bl_upd(ufs2_daddr_t *block, struct gfs_bpp *field, int fsi, int fso,
/* ************************************************************ updjcg ***** */
/*
* Here we do all needed work for the former last cylinder group. It has to be
* changed in any case, even if the file system ended exactly on the end of
* changed in any case, even if the filesystem ended exactly on the end of
* this group, as there is some slightly inconsistent handling of the number
* of cylinders in the cylinder group. We start again by reading the cylinder
* group from disk. If the last block was not fully available, we first handle
@ -780,7 +780,7 @@ updjcg(int cylno, time_t modtime, int fsi, int fso, unsigned int Nflag)
* the rotational layout tables and the cluster summary. This is
* also done per fragment for the first new block if the old file
* system end was not on a block boundary, per fragment for the new
* last block if the new file system end is not on a block boundary,
* last block if the new filesystem end is not on a block boundary,
* and per block for all space in between.
*
* Handle the first new block here if it was partially available
@ -804,7 +804,7 @@ updjcg(int cylno, time_t modtime, int fsi, int fso, unsigned int Nflag)
/*
* Check if the fragment just created could join an
* already existing fragment at the former end of the
* file system.
* filesystem.
*/
if(isblock(&sblock, cg_blksfree(&acg),
((osblock.fs_size - cgbase(&sblock, cylno))/
@ -931,7 +931,7 @@ updjcg(int cylno, time_t modtime, int fsi, int fso, unsigned int Nflag)
* Option (1) is considered to be less intrusive to the structure of the file-
* system. So we try to stick to that whenever possible. If there is not enough
* space in the cylinder group containing the cylinder summary we have to use
* method (2). In case of active snapshots in the file system we probably can
* method (2). In case of active snapshots in the filesystem we probably can
* completely avoid implementing copy on write if we stick to method (2) only.
*/
static void
@ -1287,7 +1287,7 @@ updcsloc(time_t modtime, int fsi, int fso, unsigned int Nflag)
/*
* No cluster handling is needed here, as there was at least
* one fragment in use by the cylinder summary in the old
* file system.
* filesystem.
* No block-free counter handling here as this block was not
* a free block.
*/
@ -1597,7 +1597,7 @@ wtfs(ufs2_daddr_t bno, size_t size, void *bf, int fso, unsigned int Nflag)
/*
* Here we allocate a free block in the current cylinder group. It is assumed,
* that acg contains the current cylinder group. As we may take a block from
* somewhere in the file system we have to handle cluster summary here.
* somewhere in the filesystem we have to handle cluster summary here.
*/
static ufs2_daddr_t
alloc(void)
@ -1939,9 +1939,9 @@ get_dev_size(int fd, int *size)
/* ************************************************************** main ***** */
/*
* growfs(8) is a utility which allows to increase the size of an existing
* ufs file system. Currently this can only be done on unmounted file system.
* ufs filesystem. Currently this can only be done on unmounted filesystem.
* It recognizes some command line options to specify the new desired size,
* and it does some basic checkings. The old file system size is determined
* and it does some basic checkings. The old filesystem size is determined
* and after some more checks like we can really access the new last block
* on the disk etc. we calculate the new parameters for the superblock. After
* having done this we just call growfs() which will do the work. Before
@ -1953,11 +1953,11 @@ get_dev_size(int fd, int *size)
* are lucky, then we only have to handle our blocks to be relocated in that
* way.
* Also we have to consider in what order we actually update the critical
* data structures of the file system to make sure, that in case of a disaster
* data structures of the filesystem to make sure, that in case of a disaster
* fsck(8) is still able to restore any lost data.
* The foreseen last step then will be to provide for growing even mounted
* file systems. There we have to extend the mount() system call to provide
* userland access to the file system locking facility.
* filesystems. There we have to extend the mount() system call to provide
* userland access to the filesystem locking facility.
*/
int
main(int argc, char **argv)
@ -2088,7 +2088,7 @@ main(int argc, char **argv)
}
/*
* Check if that partition is suitable for growing a file system.
* Check if that partition is suitable for growing a filesystem.
*/
if (p_size < 1) {
errx(1, "partition is unavailable");
@ -2146,8 +2146,8 @@ main(int argc, char **argv)
if(ExpertFlag == 0) {
for(j=0; j<FSMAXSNAP; j++) {
if(sblock.fs_snapinum[j]) {
errx(1, "active snapshot found in file system\n"
" please remove all snapshots before "
errx(1, "active snapshot found in filesystem; "
"please remove all snapshots before "
"using growfs");
}
if(!sblock.fs_snapinum[j]) { /* list is dense */
@ -2159,19 +2159,19 @@ main(int argc, char **argv)
if (ExpertFlag == 0 && Nflag == 0) {
printf("We strongly recommend you to make a backup "
"before growing the Filesystem\n\n"
" Did you backup your data (Yes/No) ? ");
"before growing the filesystem.\n"
"Did you backup your data (Yes/No)? ");
fgets(reply, (int)sizeof(reply), stdin);
if (strcmp(reply, "Yes\n")){
printf("\n Nothing done \n");
printf("\nNothing done\n");
exit (0);
}
}
printf("new file systemsize is: %jd frags\n", (intmax_t)sblock.fs_size);
printf("New filesystem size is %jd frags\n", (intmax_t)sblock.fs_size);
/*
* Try to access our new last block in the file system. Even if we
* Try to access our new last block in the filesystem. Even if we
* later on realize we have to abort our operation, on that block
* there should be no data, so we can't destroy something yet.
*/
@ -2180,7 +2180,7 @@ main(int argc, char **argv)
/*
* Now calculate new superblock values and check for reasonable
* bound for new file system size:
* bound for new filesystem size:
* fs_size: is derived from label or user input
* fs_dsize: should get updated in the routines creating or
* updating the cylinder groups on the fly
@ -2189,7 +2189,7 @@ main(int argc, char **argv)
*/
/*
* Update the number of cylinders and cylinder groups in the file system.
* Update the number of cylinders and cylinder groups in the filesystem.
*/
if (sblock.fs_magic == FS_UFS1_MAGIC) {
sblock.fs_old_ncyl =

View File

@ -785,8 +785,9 @@ ipfw_config_nat(int ac, char **av)
len += estimate_redir_port(&ac1, &av1);
av1 += 2; ac1 -= 2;
/* Skip optional remoteIP/port */
if (ac1 != 0 && isdigit(**av1))
if (ac1 != 0 && isdigit(**av1)) {
av1++; ac1--;
}
break;
case TOK_REDIR_PROTO:
if (ac1 < 2)
@ -795,10 +796,12 @@ ipfw_config_nat(int ac, char **av)
len += sizeof(struct cfg_redir);
av1 += 2; ac1 -= 2;
/* Skip optional remoteIP/port */
if (ac1 != 0 && isdigit(**av1))
if (ac1 != 0 && isdigit(**av1)) {
av1++; ac1--;
if (ac1 != 0 && isdigit(**av1))
}
if (ac1 != 0 && isdigit(**av1)) {
av1++; ac1--;
}
break;
default:
errx(EX_DATAERR, "unrecognised option ``%s''", av1[-1]);

View File

@ -28,7 +28,7 @@
.\" @(#)newfs.8 8.6 (Berkeley) 5/3/95
.\" $FreeBSD$
.\"
.Dd May 25, 2011
.Dd June 22, 2011
.Dt NEWFS 8
.Os
.Sh NAME
@ -297,6 +297,7 @@ on file systems that contain many small files.
.Xr dumpfs 8 ,
.Xr fsck 8 ,
.Xr gjournal 8 ,
.Xr growfs 8 ,
.Xr makefs 8 ,
.Xr mount 8 ,
.Xr tunefs 8 ,

View File

@ -28,7 +28,7 @@
.\" @(#)tunefs.8 8.2 (Berkeley) 12/11/93
.\" $FreeBSD$
.\"
.Dd May 8, 2011
.Dd June 22, 2011
.Dt TUNEFS 8
.Os
.Sh NAME
@ -165,6 +165,7 @@ specified mount point.
.Xr fs 5 ,
.Xr dumpfs 8 ,
.Xr gjournal 8 ,
.Xr growfs 8 ,
.Xr newfs 8
.Rs
.%A M. McKusick

View File

@ -37,6 +37,7 @@
#define CONF1_ENABLE_MSK1 0x80000001ul
#define CONF1_ENABLE_RES1 0x80000000ul
u_long hostb_alloc_start(int type, u_long start, u_long end, u_long count);
int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus);
int pci_cfgregopen(void);
u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes);

View File

@ -135,7 +135,7 @@ static void
legacy_pcib_identify(driver_t *driver, device_t parent)
{
int bus, slot, func;
u_int8_t hdrtype;
uint8_t hdrtype;
int found = 0;
int pcifunchigh;
int found824xx = 0;
@ -178,8 +178,8 @@ legacy_pcib_identify(driver_t *driver, device_t parent)
/*
* Read the IDs and class from the device.
*/
u_int32_t id;
u_int8_t class, subclass, busnum;
uint32_t id;
uint8_t class, subclass, busnum;
const char *s;
device_t *devs;
int ndevs, i;
@ -302,35 +302,45 @@ legacy_pcib_write_ivar(device_t dev, device_t child, int which,
return ENOENT;
}
/*
* Helper routine for x86 Host-PCI bridge driver resource allocation.
* This is used to adjust the start address of wildcard allocation
* requests to avoid low addresses that are known to be problematic.
*
* If no memory preference is given, use upper 32MB slot most BIOSes
* use for their memory window. This is typically only used on older
* laptops that don't have PCI busses behind a PCI bridge, so assuming
* > 32MB is likely OK.
*
* However, this can cause problems for other chipsets, so we make
* this tunable by hw.pci.host_mem_start.
*/
SYSCTL_DECL(_hw_pci);
static unsigned long legacy_host_mem_start = 0x80000000;
TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start);
SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN,
&legacy_host_mem_start, 0x80000000,
"Limit the host bridge memory to being above this address. Must be\n\
set at boot via a tunable.");
static unsigned long host_mem_start = 0x80000000;
TUNABLE_ULONG("hw.pci.host_mem_start", &host_mem_start);
SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, &host_mem_start,
0, "Limit the host bridge memory to being above this address.");
u_long
hostb_alloc_start(int type, u_long start, u_long end, u_long count)
{
if (start + count - 1 != end) {
if (type == SYS_RES_MEMORY && start < host_mem_start)
start = host_mem_start;
if (type == SYS_RES_IOPORT && start < 0x1000)
start = 0x1000;
}
return (start);
}
struct resource *
legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
{
/*
* If no memory preference is given, use upper 32MB slot most
* bioses use for their memory window. Typically other bridges
* before us get in the way to assert their preferences on memory.
* Hardcoding like this sucks, so a more MD/MI way needs to be
* found to do it. This is typically only used on older laptops
* that don't have pci busses behind pci bridge, so assuming > 32MB
* is liekly OK.
*
* However, this can cause problems for other chipsets, so we make
* this tunable by hw.pci.host_mem_start.
*/
if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL)
start = legacy_host_mem_start;
if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL)
start = 0x1000;
start = hostb_alloc_start(type, start, end, count);
return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
count, flags));
}

View File

@ -856,6 +856,8 @@ acpi_cpu_cx_list(struct acpi_cpu_softc *sc)
sbuf_printf(&sb, "C%d/%d ", i + 1, sc->cpu_cx_states[i].trans_lat);
if (sc->cpu_cx_states[i].type < ACPI_STATE_C3)
sc->cpu_non_c3 = i;
else
cpu_can_deep_sleep = 1;
}
sbuf_trim(&sb);
sbuf_finish(&sb);

View File

@ -357,32 +357,14 @@ acpi_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr,
return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data));
}
static u_long acpi_host_mem_start = 0x80000000;
TUNABLE_ULONG("hw.acpi.host_mem_start", &acpi_host_mem_start);
struct resource *
acpi_pcib_acpi_alloc_resource(device_t dev, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
{
/*
* If no memory preference is given, use upper 32MB slot most
* bioses use for their memory window. Typically other bridges
* before us get in the way to assert their preferences on memory.
* Hardcoding like this sucks, so a more MD/MI way needs to be
* found to do it. This is typically only used on older laptops
* that don't have pci busses behind pci bridge, so assuming > 32MB
* is likely OK.
*
* PCI-PCI bridges may allocate smaller ranges for their windows,
* but the heuristics here should apply to those, so we allow
* several different end addresses.
*/
if (type == SYS_RES_MEMORY && start == 0UL && (end == ~0UL ||
end == 0xffffffff))
start = acpi_host_mem_start;
if (type == SYS_RES_IOPORT && start == 0UL && (end == ~0UL ||
end == 0xffff || end == 0xffffffff))
start = 0x1000;
#if defined(__i386__) || defined(__amd64__)
start = hostb_alloc_start(type, start, end, count);
#endif
return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
count, flags));
}

View File

@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/module.h>
@ -139,6 +140,249 @@ acpi_config_intr(device_t dev, ACPI_RESOURCE *res)
INTR_POLARITY_HIGH : INTR_POLARITY_LOW);
}
struct acpi_resource_context {
struct acpi_parse_resource_set *set;
device_t dev;
void *context;
};
#ifdef ACPI_DEBUG_OUTPUT
static const char *
acpi_address_range_name(UINT8 ResourceType)
{
static char buf[16];
switch (ResourceType) {
case ACPI_MEMORY_RANGE:
return ("Memory");
case ACPI_IO_RANGE:
return ("IO");
case ACPI_BUS_NUMBER_RANGE:
return ("Bus Number");
default:
snprintf(buf, sizeof(buf), "type %u", ResourceType);
return (buf);
}
}
#endif
static ACPI_STATUS
acpi_parse_resource(ACPI_RESOURCE *res, void *context)
{
struct acpi_parse_resource_set *set;
struct acpi_resource_context *arc;
UINT64 min, max, length, gran;
const char *name;
device_t dev;
arc = context;
dev = arc->dev;
set = arc->set;
switch (res->Type) {
case ACPI_RESOURCE_TYPE_END_TAG:
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "EndTag\n"));
break;
case ACPI_RESOURCE_TYPE_FIXED_IO:
if (res->Data.FixedIo.AddressLength <= 0)
break;
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "FixedIo 0x%x/%d\n",
res->Data.FixedIo.Address, res->Data.FixedIo.AddressLength));
set->set_ioport(dev, arc->context, res->Data.FixedIo.Address,
res->Data.FixedIo.AddressLength);
break;
case ACPI_RESOURCE_TYPE_IO:
if (res->Data.Io.AddressLength <= 0)
break;
if (res->Data.Io.Minimum == res->Data.Io.Maximum) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Io 0x%x/%d\n",
res->Data.Io.Minimum, res->Data.Io.AddressLength));
set->set_ioport(dev, arc->context, res->Data.Io.Minimum,
res->Data.Io.AddressLength);
} else {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Io 0x%x-0x%x/%d\n",
res->Data.Io.Minimum, res->Data.Io.Maximum,
res->Data.Io.AddressLength));
set->set_iorange(dev, arc->context, res->Data.Io.Minimum,
res->Data.Io.Maximum, res->Data.Io.AddressLength,
res->Data.Io.Alignment);
}
break;
case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
if (res->Data.FixedMemory32.AddressLength <= 0)
break;
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "FixedMemory32 0x%x/%d\n",
res->Data.FixedMemory32.Address,
res->Data.FixedMemory32.AddressLength));
set->set_memory(dev, arc->context, res->Data.FixedMemory32.Address,
res->Data.FixedMemory32.AddressLength);
break;
case ACPI_RESOURCE_TYPE_MEMORY32:
if (res->Data.Memory32.AddressLength <= 0)
break;
if (res->Data.Memory32.Minimum == res->Data.Memory32.Maximum) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory32 0x%x/%d\n",
res->Data.Memory32.Minimum, res->Data.Memory32.AddressLength));
set->set_memory(dev, arc->context, res->Data.Memory32.Minimum,
res->Data.Memory32.AddressLength);
} else {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory32 0x%x-0x%x/%d\n",
res->Data.Memory32.Minimum, res->Data.Memory32.Maximum,
res->Data.Memory32.AddressLength));
set->set_memoryrange(dev, arc->context, res->Data.Memory32.Minimum,
res->Data.Memory32.Maximum, res->Data.Memory32.AddressLength,
res->Data.Memory32.Alignment);
}
break;
case ACPI_RESOURCE_TYPE_MEMORY24:
if (res->Data.Memory24.AddressLength <= 0)
break;
if (res->Data.Memory24.Minimum == res->Data.Memory24.Maximum) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory24 0x%x/%d\n",
res->Data.Memory24.Minimum, res->Data.Memory24.AddressLength));
set->set_memory(dev, arc->context, res->Data.Memory24.Minimum,
res->Data.Memory24.AddressLength);
} else {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory24 0x%x-0x%x/%d\n",
res->Data.Memory24.Minimum, res->Data.Memory24.Maximum,
res->Data.Memory24.AddressLength));
set->set_memoryrange(dev, arc->context, res->Data.Memory24.Minimum,
res->Data.Memory24.Maximum, res->Data.Memory24.AddressLength,
res->Data.Memory24.Alignment);
}
break;
case ACPI_RESOURCE_TYPE_IRQ:
/*
* from 1.0b 6.4.2
* "This structure is repeated for each separate interrupt
* required"
*/
set->set_irq(dev, arc->context, res->Data.Irq.Interrupts,
res->Data.Irq.InterruptCount, res->Data.Irq.Triggering,
res->Data.Irq.Polarity);
break;
case ACPI_RESOURCE_TYPE_DMA:
/*
* from 1.0b 6.4.3
* "This structure is repeated for each separate DMA channel
* required"
*/
set->set_drq(dev, arc->context, res->Data.Dma.Channels,
res->Data.Dma.ChannelCount);
break;
case ACPI_RESOURCE_TYPE_START_DEPENDENT:
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "start dependent functions\n"));
set->set_start_dependent(dev, arc->context,
res->Data.StartDpf.CompatibilityPriority);
break;
case ACPI_RESOURCE_TYPE_END_DEPENDENT:
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "end dependent functions\n"));
set->set_end_dependent(dev, arc->context);
break;
case ACPI_RESOURCE_TYPE_ADDRESS16:
case ACPI_RESOURCE_TYPE_ADDRESS32:
case ACPI_RESOURCE_TYPE_ADDRESS64:
case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
switch (res->Type) {
case ACPI_RESOURCE_TYPE_ADDRESS16:
gran = res->Data.Address16.Granularity;
min = res->Data.Address16.Minimum;
max = res->Data.Address16.Maximum;
length = res->Data.Address16.AddressLength;
name = "Address16";
break;
case ACPI_RESOURCE_TYPE_ADDRESS32:
gran = res->Data.Address32.Granularity;
min = res->Data.Address32.Minimum;
max = res->Data.Address32.Maximum;
length = res->Data.Address32.AddressLength;
name = "Address32";
break;
case ACPI_RESOURCE_TYPE_ADDRESS64:
gran = res->Data.Address64.Granularity;
min = res->Data.Address64.Minimum;
max = res->Data.Address64.Maximum;
length = res->Data.Address64.AddressLength;
name = "Address64";
break;
default:
KASSERT(res->Type == ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64,
("should never happen"));
gran = res->Data.ExtAddress64.Granularity;
min = res->Data.ExtAddress64.Minimum;
max = res->Data.ExtAddress64.Maximum;
length = res->Data.ExtAddress64.AddressLength;
name = "ExtAddress64";
break;
}
if (length <= 0)
break;
if (res->Data.Address.ProducerConsumer != ACPI_CONSUMER) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"ignored %s %s producer\n", name,
acpi_address_range_name(res->Data.Address.ResourceType)));
break;
}
if (res->Data.Address.ResourceType != ACPI_MEMORY_RANGE &&
res->Data.Address.ResourceType != ACPI_IO_RANGE) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"ignored %s for non-memory, non-I/O\n", name));
break;
}
#ifdef __i386__
if (min > ULONG_MAX || (res->Data.Address.MaxAddressFixed && max >
ULONG_MAX)) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "ignored %s above 4G\n",
name));
break;
}
if (max > ULONG_MAX)
max = ULONG_MAX;
#endif
if (res->Data.Address.MinAddressFixed == ACPI_ADDRESS_FIXED &&
res->Data.Address.MaxAddressFixed == ACPI_ADDRESS_FIXED) {
if (res->Data.Address.ResourceType == ACPI_MEMORY_RANGE) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "%s/Memory 0x%jx/%ju\n",
name, (uintmax_t)min, (uintmax_t)length));
set->set_memory(dev, arc->context, min, length);
} else {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "%s/IO 0x%jx/%ju\n", name,
(uintmax_t)min, (uintmax_t)length));
set->set_ioport(dev, arc->context, min, length);
}
} else {
if (res->Data.Address32.ResourceType == ACPI_MEMORY_RANGE) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"%s/Memory 0x%jx-0x%jx/%ju\n", name, (uintmax_t)min,
(uintmax_t)max, (uintmax_t)length));
set->set_memoryrange(dev, arc->context, min, max, length, gran);
} else {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "%s/IO 0x%jx-0x%jx/%ju\n",
name, (uintmax_t)min, (uintmax_t)max, (uintmax_t)length));
set->set_iorange(dev, arc->context, min, max, length, gran);
}
}
break;
case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
if (res->Data.ExtendedIrq.ProducerConsumer != ACPI_CONSUMER) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "ignored ExtIRQ producer\n"));
break;
}
set->set_ext_irq(dev, arc->context, res->Data.ExtendedIrq.Interrupts,
res->Data.ExtendedIrq.InterruptCount,
res->Data.ExtendedIrq.Triggering, res->Data.ExtendedIrq.Polarity);
break;
case ACPI_RESOURCE_TYPE_VENDOR:
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"unimplemented VendorSpecific resource\n"));
break;
default:
break;
}
return (AE_OK);
}
/*
* Fetch a device's resources and associate them with the device.
*
@ -153,318 +397,21 @@ ACPI_STATUS
acpi_parse_resources(device_t dev, ACPI_HANDLE handle,
struct acpi_parse_resource_set *set, void *arg)
{
ACPI_BUFFER buf;
ACPI_RESOURCE *res;
char *curr, *last;
struct acpi_resource_context arc;
ACPI_STATUS status;
void *context;
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
/*
* Special-case some devices that abuse _PRS/_CRS to mean
* something other than "I consume this resource".
*
* XXX do we really need this? It's only relevant once
* we start always-allocating these resources, and even
* then, the only special-cased device is likely to be
* the PCI interrupt link.
*/
/* Fetch the device's current resources. */
buf.Length = ACPI_ALLOCATE_BUFFER;
if (ACPI_FAILURE((status = AcpiGetCurrentResources(handle, &buf)))) {
if (status != AE_NOT_FOUND && status != AE_TYPE)
printf("can't fetch resources for %s - %s\n",
acpi_name(handle), AcpiFormatException(status));
set->set_init(dev, arg, &arc.context);
arc.set = set;
arc.dev = dev;
status = AcpiWalkResources(handle, "_CRS", acpi_parse_resource, &arc);
if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
printf("can't fetch resources for %s - %s\n",
acpi_name(handle), AcpiFormatException(status));
return_ACPI_STATUS (status);
}
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "%s - got %ld bytes of resources\n",
acpi_name(handle), (long)buf.Length));
set->set_init(dev, arg, &context);
/* Iterate through the resources */
curr = buf.Pointer;
last = (char *)buf.Pointer + buf.Length;
while (curr < last) {
res = (ACPI_RESOURCE *)curr;
curr += res->Length;
/* Handle the individual resource types */
switch(res->Type) {
case ACPI_RESOURCE_TYPE_END_TAG:
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "EndTag\n"));
curr = last;
break;
case ACPI_RESOURCE_TYPE_FIXED_IO:
if (res->Data.FixedIo.AddressLength <= 0)
break;
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "FixedIo 0x%x/%d\n",
res->Data.FixedIo.Address,
res->Data.FixedIo.AddressLength));
set->set_ioport(dev, context,
res->Data.FixedIo.Address,
res->Data.FixedIo.AddressLength);
break;
case ACPI_RESOURCE_TYPE_IO:
if (res->Data.Io.AddressLength <= 0)
break;
if (res->Data.Io.Minimum == res->Data.Io.Maximum) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Io 0x%x/%d\n",
res->Data.Io.Minimum,
res->Data.Io.AddressLength));
set->set_ioport(dev, context,
res->Data.Io.Minimum,
res->Data.Io.AddressLength);
} else {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Io 0x%x-0x%x/%d\n",
res->Data.Io.Minimum,
res->Data.Io.Maximum,
res->Data.Io.AddressLength));
set->set_iorange(dev, context,
res->Data.Io.Minimum,
res->Data.Io.Maximum,
res->Data.Io.AddressLength,
res->Data.Io.Alignment);
}
break;
case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
if (res->Data.FixedMemory32.AddressLength <= 0)
break;
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "FixedMemory32 0x%x/%d\n",
res->Data.FixedMemory32.Address,
res->Data.FixedMemory32.AddressLength));
set->set_memory(dev, context,
res->Data.FixedMemory32.Address,
res->Data.FixedMemory32.AddressLength);
break;
case ACPI_RESOURCE_TYPE_MEMORY32:
if (res->Data.Memory32.AddressLength <= 0)
break;
if (res->Data.Memory32.Minimum ==
res->Data.Memory32.Maximum) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory32 0x%x/%d\n",
res->Data.Memory32.Minimum,
res->Data.Memory32.AddressLength));
set->set_memory(dev, context,
res->Data.Memory32.Minimum,
res->Data.Memory32.AddressLength);
} else {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory32 0x%x-0x%x/%d\n",
res->Data.Memory32.Minimum,
res->Data.Memory32.Maximum,
res->Data.Memory32.AddressLength));
set->set_memoryrange(dev, context,
res->Data.Memory32.Minimum,
res->Data.Memory32.Maximum,
res->Data.Memory32.AddressLength,
res->Data.Memory32.Alignment);
}
break;
case ACPI_RESOURCE_TYPE_MEMORY24:
if (res->Data.Memory24.AddressLength <= 0)
break;
if (res->Data.Memory24.Minimum ==
res->Data.Memory24.Maximum) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory24 0x%x/%d\n",
res->Data.Memory24.Minimum,
res->Data.Memory24.AddressLength));
set->set_memory(dev, context, res->Data.Memory24.Minimum,
res->Data.Memory24.AddressLength);
} else {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory24 0x%x-0x%x/%d\n",
res->Data.Memory24.Minimum,
res->Data.Memory24.Maximum,
res->Data.Memory24.AddressLength));
set->set_memoryrange(dev, context,
res->Data.Memory24.Minimum,
res->Data.Memory24.Maximum,
res->Data.Memory24.AddressLength,
res->Data.Memory24.Alignment);
}
break;
case ACPI_RESOURCE_TYPE_IRQ:
/*
* from 1.0b 6.4.2
* "This structure is repeated for each separate interrupt
* required"
*/
set->set_irq(dev, context, res->Data.Irq.Interrupts,
res->Data.Irq.InterruptCount, res->Data.Irq.Triggering,
res->Data.Irq.Polarity);
break;
case ACPI_RESOURCE_TYPE_DMA:
/*
* from 1.0b 6.4.3
* "This structure is repeated for each separate dma channel
* required"
*/
set->set_drq(dev, context, res->Data.Dma.Channels,
res->Data.Dma.ChannelCount);
break;
case ACPI_RESOURCE_TYPE_START_DEPENDENT:
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "start dependent functions\n"));
set->set_start_dependent(dev, context,
res->Data.StartDpf.CompatibilityPriority);
break;
case ACPI_RESOURCE_TYPE_END_DEPENDENT:
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "end dependent functions\n"));
set->set_end_dependent(dev, context);
break;
case ACPI_RESOURCE_TYPE_ADDRESS32:
if (res->Data.Address32.AddressLength <= 0)
break;
if (res->Data.Address32.ProducerConsumer != ACPI_CONSUMER) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"ignored Address32 %s producer\n",
res->Data.Address32.ResourceType == ACPI_IO_RANGE ?
"IO" : "Memory"));
break;
}
if (res->Data.Address32.ResourceType != ACPI_MEMORY_RANGE &&
res->Data.Address32.ResourceType != ACPI_IO_RANGE) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"ignored Address32 for non-memory, non-I/O\n"));
break;
}
if (res->Data.Address32.MinAddressFixed == ACPI_ADDRESS_FIXED &&
res->Data.Address32.MaxAddressFixed == ACPI_ADDRESS_FIXED) {
if (res->Data.Address32.ResourceType == ACPI_MEMORY_RANGE) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"Address32/Memory 0x%x/%d\n",
res->Data.Address32.Minimum,
res->Data.Address32.AddressLength));
set->set_memory(dev, context,
res->Data.Address32.Minimum,
res->Data.Address32.AddressLength);
} else {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"Address32/IO 0x%x/%d\n",
res->Data.Address32.Minimum,
res->Data.Address32.AddressLength));
set->set_ioport(dev, context,
res->Data.Address32.Minimum,
res->Data.Address32.AddressLength);
}
} else {
if (res->Data.Address32.ResourceType == ACPI_MEMORY_RANGE) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"Address32/Memory 0x%x-0x%x/%d\n",
res->Data.Address32.Minimum,
res->Data.Address32.Maximum,
res->Data.Address32.AddressLength));
set->set_memoryrange(dev, context,
res->Data.Address32.Minimum,
res->Data.Address32.Maximum,
res->Data.Address32.AddressLength,
res->Data.Address32.Granularity);
} else {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"Address32/IO 0x%x-0x%x/%d\n",
res->Data.Address32.Minimum,
res->Data.Address32.Maximum,
res->Data.Address32.AddressLength));
set->set_iorange(dev, context,
res->Data.Address32.Minimum,
res->Data.Address32.Maximum,
res->Data.Address32.AddressLength,
res->Data.Address32.Granularity);
}
}
break;
case ACPI_RESOURCE_TYPE_ADDRESS16:
if (res->Data.Address16.AddressLength <= 0)
break;
if (res->Data.Address16.ProducerConsumer != ACPI_CONSUMER) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"ignored Address16 %s producer\n",
res->Data.Address16.ResourceType == ACPI_IO_RANGE ?
"IO" : "Memory"));
break;
}
if (res->Data.Address16.ResourceType != ACPI_MEMORY_RANGE &&
res->Data.Address16.ResourceType != ACPI_IO_RANGE) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"ignored Address16 for non-memory, non-I/O\n"));
break;
}
if (res->Data.Address16.MinAddressFixed == ACPI_ADDRESS_FIXED &&
res->Data.Address16.MaxAddressFixed == ACPI_ADDRESS_FIXED) {
if (res->Data.Address16.ResourceType == ACPI_MEMORY_RANGE) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"Address16/Memory 0x%x/%d\n",
res->Data.Address16.Minimum,
res->Data.Address16.AddressLength));
set->set_memory(dev, context,
res->Data.Address16.Minimum,
res->Data.Address16.AddressLength);
} else {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"Address16/IO 0x%x/%d\n",
res->Data.Address16.Minimum,
res->Data.Address16.AddressLength));
set->set_ioport(dev, context,
res->Data.Address16.Minimum,
res->Data.Address16.AddressLength);
}
} else {
if (res->Data.Address16.ResourceType == ACPI_MEMORY_RANGE) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"Address16/Memory 0x%x-0x%x/%d\n",
res->Data.Address16.Minimum,
res->Data.Address16.Maximum,
res->Data.Address16.AddressLength));
set->set_memoryrange(dev, context,
res->Data.Address16.Minimum,
res->Data.Address16.Maximum,
res->Data.Address16.AddressLength,
res->Data.Address16.Granularity);
} else {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"Address16/IO 0x%x-0x%x/%d\n",
res->Data.Address16.Minimum,
res->Data.Address16.Maximum,
res->Data.Address16.AddressLength));
set->set_iorange(dev, context,
res->Data.Address16.Minimum,
res->Data.Address16.Maximum,
res->Data.Address16.AddressLength,
res->Data.Address16.Granularity);
}
}
break;
case ACPI_RESOURCE_TYPE_ADDRESS64:
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"unimplemented Address64 resource\n"));
break;
case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
if (res->Data.ExtendedIrq.ProducerConsumer != ACPI_CONSUMER) {
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"ignored ExtIRQ producer\n"));
break;
}
set->set_ext_irq(dev, context, res->Data.ExtendedIrq.Interrupts,
res->Data.ExtendedIrq.InterruptCount,
res->Data.ExtendedIrq.Triggering,
res->Data.ExtendedIrq.Polarity);
break;
case ACPI_RESOURCE_TYPE_VENDOR:
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
"unimplemented VendorSpecific resource\n"));
break;
default:
break;
}
}
AcpiOsFree(buf.Pointer);
set->set_done(dev, context);
set->set_done(dev, arc.context);
return_ACPI_STATUS (AE_OK);
}
@ -475,20 +422,20 @@ acpi_parse_resources(device_t dev, ACPI_HANDLE handle,
static void acpi_res_set_init(device_t dev, void *arg, void **context);
static void acpi_res_set_done(device_t dev, void *context);
static void acpi_res_set_ioport(device_t dev, void *context,
u_int32_t base, u_int32_t length);
uint64_t base, uint64_t length);
static void acpi_res_set_iorange(device_t dev, void *context,
u_int32_t low, u_int32_t high,
u_int32_t length, u_int32_t align);
uint64_t low, uint64_t high,
uint64_t length, uint64_t align);
static void acpi_res_set_memory(device_t dev, void *context,
u_int32_t base, u_int32_t length);
uint64_t base, uint64_t length);
static void acpi_res_set_memoryrange(device_t dev, void *context,
u_int32_t low, u_int32_t high,
u_int32_t length, u_int32_t align);
static void acpi_res_set_irq(device_t dev, void *context, u_int8_t *irq,
uint64_t low, uint64_t high,
uint64_t length, uint64_t align);
static void acpi_res_set_irq(device_t dev, void *context, uint8_t *irq,
int count, int trig, int pol);
static void acpi_res_set_ext_irq(device_t dev, void *context,
u_int32_t *irq, int count, int trig, int pol);
static void acpi_res_set_drq(device_t dev, void *context, u_int8_t *drq,
uint32_t *irq, int count, int trig, int pol);
static void acpi_res_set_drq(device_t dev, void *context, uint8_t *drq,
int count);
static void acpi_res_set_start_dependent(device_t dev, void *context,
int preference);
@ -539,8 +486,8 @@ acpi_res_set_done(device_t dev, void *context)
}
static void
acpi_res_set_ioport(device_t dev, void *context, u_int32_t base,
u_int32_t length)
acpi_res_set_ioport(device_t dev, void *context, uint64_t base,
uint64_t length)
{
struct acpi_res_context *cp = (struct acpi_res_context *)context;
@ -550,8 +497,8 @@ acpi_res_set_ioport(device_t dev, void *context, u_int32_t base,
}
static void
acpi_res_set_iorange(device_t dev, void *context, u_int32_t low,
u_int32_t high, u_int32_t length, u_int32_t align)
acpi_res_set_iorange(device_t dev, void *context, uint64_t low,
uint64_t high, uint64_t length, uint64_t align)
{
struct acpi_res_context *cp = (struct acpi_res_context *)context;
@ -561,8 +508,8 @@ acpi_res_set_iorange(device_t dev, void *context, u_int32_t low,
}
static void
acpi_res_set_memory(device_t dev, void *context, u_int32_t base,
u_int32_t length)
acpi_res_set_memory(device_t dev, void *context, uint64_t base,
uint64_t length)
{
struct acpi_res_context *cp = (struct acpi_res_context *)context;
@ -573,8 +520,8 @@ acpi_res_set_memory(device_t dev, void *context, u_int32_t base,
}
static void
acpi_res_set_memoryrange(device_t dev, void *context, u_int32_t low,
u_int32_t high, u_int32_t length, u_int32_t align)
acpi_res_set_memoryrange(device_t dev, void *context, uint64_t low,
uint64_t high, uint64_t length, uint64_t align)
{
struct acpi_res_context *cp = (struct acpi_res_context *)context;
@ -584,7 +531,7 @@ acpi_res_set_memoryrange(device_t dev, void *context, u_int32_t low,
}
static void
acpi_res_set_irq(device_t dev, void *context, u_int8_t *irq, int count,
acpi_res_set_irq(device_t dev, void *context, uint8_t *irq, int count,
int trig, int pol)
{
struct acpi_res_context *cp = (struct acpi_res_context *)context;
@ -600,7 +547,7 @@ acpi_res_set_irq(device_t dev, void *context, u_int8_t *irq, int count,
}
static void
acpi_res_set_ext_irq(device_t dev, void *context, u_int32_t *irq, int count,
acpi_res_set_ext_irq(device_t dev, void *context, uint32_t *irq, int count,
int trig, int pol)
{
struct acpi_res_context *cp = (struct acpi_res_context *)context;
@ -616,7 +563,7 @@ acpi_res_set_ext_irq(device_t dev, void *context, u_int32_t *irq, int count,
}
static void
acpi_res_set_drq(device_t dev, void *context, u_int8_t *drq, int count)
acpi_res_set_drq(device_t dev, void *context, uint8_t *drq, int count)
{
struct acpi_res_context *cp = (struct acpi_res_context *)context;

View File

@ -355,19 +355,19 @@ BOOLEAN acpi_MatchHid(ACPI_HANDLE h, const char *hid);
struct acpi_parse_resource_set {
void (*set_init)(device_t dev, void *arg, void **context);
void (*set_done)(device_t dev, void *context);
void (*set_ioport)(device_t dev, void *context, uint32_t base,
uint32_t length);
void (*set_iorange)(device_t dev, void *context, uint32_t low,
uint32_t high, uint32_t length, uint32_t align);
void (*set_memory)(device_t dev, void *context, uint32_t base,
uint32_t length);
void (*set_memoryrange)(device_t dev, void *context, uint32_t low,
uint32_t high, uint32_t length, uint32_t align);
void (*set_irq)(device_t dev, void *context, u_int8_t *irq,
void (*set_ioport)(device_t dev, void *context, uint64_t base,
uint64_t length);
void (*set_iorange)(device_t dev, void *context, uint64_t low,
uint64_t high, uint64_t length, uint64_t align);
void (*set_memory)(device_t dev, void *context, uint64_t base,
uint64_t length);
void (*set_memoryrange)(device_t dev, void *context, uint64_t low,
uint64_t high, uint64_t length, uint64_t align);
void (*set_irq)(device_t dev, void *context, uint8_t *irq,
int count, int trig, int pol);
void (*set_ext_irq)(device_t dev, void *context, u_int32_t *irq,
void (*set_ext_irq)(device_t dev, void *context, uint32_t *irq,
int count, int trig, int pol);
void (*set_drq)(device_t dev, void *context, u_int8_t *drq,
void (*set_drq)(device_t dev, void *context, uint8_t *drq,
int count);
void (*set_start_dependent)(device_t dev, void *context,
int preference);

View File

@ -369,6 +369,14 @@ decode_tuple_end(device_t cbdev, device_t child, int id,
* Functions to read the a tuple from the card
*/
/*
* Read CIS bytes out of the config space. We have to read it 4 bytes at a
* time and do the usual mask and shift to return the bytes. The standard
* defines the byte order to be little endian. pci_read_config converts it to
* host byte order. This is why we have no endian conversion functions: the
* shifts wind up being endian neutral. This is also why we avoid the obvious
* memcpy optimization.
*/
static int
cardbus_read_tuple_conf(device_t cbdev, device_t child, uint32_t start,
uint32_t *off, int *tupleid, int *len, uint8_t *tupledata)
@ -379,12 +387,11 @@ cardbus_read_tuple_conf(device_t cbdev, device_t child, uint32_t start,
loc = start + *off;
e = pci_read_config(child, loc - loc % 4, 4);
for (j = loc % 4; j > 0; j--)
e >>= 8;
e = pci_read_config(child, loc & ~0x3, 4);
e >>= 8 * (loc & 0x3);
*len = 0;
for (i = loc, j = -2; j < *len; j++, i++) {
if (i % 4 == 0)
if ((i & 0x3) == 0)
e = pci_read_config(child, i, 4);
if (j == -2)
*tupleid = 0xff & e;
@ -398,6 +405,10 @@ cardbus_read_tuple_conf(device_t cbdev, device_t child, uint32_t start,
return (0);
}
/*
* Read the CIS data out of memroy. We indirect through the bus space
* routines to ensure proper byte ordering conversions when necessary.
*/
static int
cardbus_read_tuple_mem(device_t cbdev, struct resource *res, uint32_t start,
uint32_t *off, int *tupleid, int *len, uint8_t *tupledata)
@ -580,7 +591,7 @@ cardbus_parse_cis(device_t cbdev, device_t child,
expect_linktarget = TRUE;
if ((start = pci_read_config(child, PCIR_CIS, 4)) == 0) {
DEVPRINTF((cbdev, "Warning: CIS pointer is 0: (no CIS)\n"));
return (ENXIO);
return (0);
}
DEVPRINTF((cbdev, "CIS pointer is %#x\n", start));
off = 0;

View File

@ -1385,7 +1385,7 @@ dc_netcfg_wait(struct dc_softc *sc)
break;
DELAY(10);
}
if (i == DC_TIMEOUT) {
if (i == DC_TIMEOUT && bus_child_present(sc->dc_dev)) {
if (!(isr & DC_ISR_TX_IDLE) && !DC_IS_ASIX(sc))
device_printf(sc->dc_dev,
"%s: failed to force tx to idle state\n", __func__);

View File

@ -297,7 +297,7 @@ static int pci_usb_takeover = 1;
static int pci_usb_takeover = 0;
#endif
TUNABLE_INT("hw.pci.usb_early_takeover", &pci_usb_takeover);
SYSCTL_INT(_hw_pci, OID_AUTO, usb_early_takeover, CTLFLAG_RD | CTLFLAG_TUN,
SYSCTL_INT(_hw_pci, OID_AUTO, usb_early_takeover, CTLFLAG_RDTUN,
&pci_usb_takeover, 1, "Enable early takeover of USB controllers.\n\
Disable this if you depend on BIOS emulation of USB devices, that is\n\
you use USB devices (like keyboard or mouse) but do not load USB drivers");
@ -2482,7 +2482,8 @@ pci_write_bar(device_t dev, struct pci_map *pm, pci_addr_t base)
pci_write_config(dev, pm->pm_reg + 4, base >> 32, 4);
pm->pm_value = pci_read_config(dev, pm->pm_reg, 4);
if (ln2range == 64)
pm->pm_value |= (pci_addr_t)pci_read_config(dev, pm->pm_reg + 4, 4) << 32;
pm->pm_value |= (pci_addr_t)pci_read_config(dev,
pm->pm_reg + 4, 4) << 32;
}
struct pci_map *
@ -2680,7 +2681,7 @@ pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl,
count = (pci_addr_t)1 << mapsize;
if (basezero || base == pci_mapbase(testval)) {
start = 0; /* Let the parent decide. */
end = ~0ULL;
end = ~0ul;
} else {
start = base;
end = base + count - 1;

View File

@ -185,7 +185,6 @@ static int vr_miibus_readreg(device_t, int, int);
static int vr_miibus_writereg(device_t, int, int, int);
static void vr_miibus_statchg(device_t);
static void vr_link_task(void *, int);
static void vr_cam_mask(struct vr_softc *, uint32_t, int);
static int vr_cam_data(struct vr_softc *, int, int, uint8_t *);
static void vr_set_filter(struct vr_softc *);
@ -226,7 +225,6 @@ static device_method_t vr_methods[] = {
DEVMETHOD(miibus_readreg, vr_miibus_readreg),
DEVMETHOD(miibus_writereg, vr_miibus_writereg),
DEVMETHOD(miibus_statchg, vr_miibus_statchg),
DEVMETHOD(miibus_linkchg, vr_miibus_statchg),
{ NULL, NULL }
};
@ -290,22 +288,13 @@ vr_miibus_writereg(device_t dev, int phy, int reg, int data)
return (0);
}
static void
vr_miibus_statchg(device_t dev)
{
struct vr_softc *sc;
sc = device_get_softc(dev);
taskqueue_enqueue(taskqueue_swi, &sc->vr_link_task);
}
/*
* In order to fiddle with the
* 'full-duplex' and '100Mbps' bits in the netconfig register, we
* first have to put the transmit and/or receive logic in the idle state.
*/
static void
vr_link_task(void *arg, int pending)
vr_miibus_statchg(device_t dev)
{
struct vr_softc *sc;
struct mii_data *mii;
@ -313,22 +302,25 @@ vr_link_task(void *arg, int pending)
int lfdx, mfdx;
uint8_t cr0, cr1, fc;
sc = (struct vr_softc *)arg;
VR_LOCK(sc);
sc = device_get_softc(dev);
mii = device_get_softc(sc->vr_miibus);
ifp = sc->vr_ifp;
if (mii == NULL || ifp == NULL ||
(ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
VR_UNLOCK(sc);
(ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
return;
}
if (mii->mii_media_status & IFM_ACTIVE) {
if (IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE)
sc->vr_link = 0;
if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
(IFM_ACTIVE | IFM_AVALID)) {
switch (IFM_SUBTYPE(mii->mii_media_active)) {
case IFM_10_T:
case IFM_100_TX:
sc->vr_link = 1;
} else
sc->vr_link = 0;
break;
default:
break;
}
}
if (sc->vr_link != 0) {
cr0 = CSR_READ_1(sc, VR_CR0);
@ -384,11 +376,8 @@ vr_link_task(void *arg, int pending)
"%s: Tx/Rx shutdown error -- resetting\n",
__func__);
sc->vr_flags |= VR_F_RESTART;
VR_UNLOCK(sc);
return;
}
}
VR_UNLOCK(sc);
}
@ -621,7 +610,6 @@ vr_attach(device_t dev)
mtx_init(&sc->vr_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
MTX_DEF);
callout_init_mtx(&sc->vr_stat_callout, &sc->vr_mtx, 0);
TASK_INIT(&sc->vr_link_task, 0, vr_link_task, sc);
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
OID_AUTO, "stats", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
@ -841,7 +829,6 @@ vr_detach(device_t dev)
vr_stop(sc);
VR_UNLOCK(sc);
callout_drain(&sc->vr_stat_callout);
taskqueue_drain(taskqueue_swi, &sc->vr_link_task);
ether_ifdetach(ifp);
}
if (sc->vr_miibus)
@ -1559,6 +1546,8 @@ vr_tick(void *xsc)
mii = device_get_softc(sc->vr_miibus);
mii_tick(mii);
if (sc->vr_link == 0)
vr_miibus_statchg(sc->vr_dev);
vr_watchdog(sc);
callout_reset(&sc->vr_stat_callout, hz, vr_tick, sc);
}
@ -2161,6 +2150,10 @@ vr_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
sc = ifp->if_softc;
mii = device_get_softc(sc->vr_miibus);
VR_LOCK(sc);
if ((ifp->if_flags & IFF_UP) == 0) {
VR_UNLOCK(sc);
return;
}
mii_pollstat(mii);
VR_UNLOCK(sc);
ifmr->ifm_active = mii->mii_media_active;

View File

@ -723,7 +723,6 @@ struct vr_softc {
uint8_t vr_flags; /* See VR_F_* below */
#define VR_F_RESTART 0x01 /* Restart unit on next tick */
int vr_if_flags;
struct task vr_link_task;
struct vr_chain_data vr_cdata;
struct vr_ring_data vr_rdata;
struct vr_statistics vr_stat;

View File

@ -334,7 +334,7 @@ xl_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error)
* only a finite amount of time to avoid getting caught in an
* infinite loop. Normally this delay routine would be a macro,
* but it isn't called during normal operation so we can afford
* to make it a function.
* to make it a function. Suppress warning when card gone.
*/
static void
xl_wait(struct xl_softc *sc)
@ -346,7 +346,7 @@ xl_wait(struct xl_softc *sc)
break;
}
if (i == XL_TIMEOUT)
if (i == XL_TIMEOUT && bus_child_present(sc->xl_dev))
device_printf(sc->xl_dev, "command never completed!\n");
}

View File

@ -172,11 +172,12 @@ nfsrvd_getattr(struct nfsrv_descript *nd, int isdgram,
fhandle_t fh;
int at_root = 0, error = 0, supports_nfsv4acls;
struct nfsreferral *refp;
nfsattrbit_t attrbits;
nfsattrbit_t attrbits, tmpbits;
struct mount *mp;
struct vnode *tvp = NULL;
struct vattr va;
uint64_t mounted_on_fileno = 0;
accmode_t accmode;
if (nd->nd_repstat)
return (0);
@ -197,11 +198,20 @@ nfsrvd_getattr(struct nfsrv_descript *nd, int isdgram,
vput(vp);
return (0);
}
if (!nd->nd_repstat)
nd->nd_repstat = nfsvno_accchk(vp,
VREAD_ATTRIBUTES,
nd->nd_cred, exp, p, NFSACCCHK_NOOVERRIDE,
NFSACCCHK_VPISLOCKED, NULL);
if (nd->nd_repstat == 0) {
accmode = 0;
NFSSET_ATTRBIT(&tmpbits, &attrbits);
if (NFSISSET_ATTRBIT(&tmpbits, NFSATTRBIT_ACL)) {
NFSCLRBIT_ATTRBIT(&tmpbits, NFSATTRBIT_ACL);
accmode |= VREAD_ACL;
}
if (NFSNONZERO_ATTRBIT(&tmpbits))
accmode |= VREAD_ATTRIBUTES;
if (accmode != 0)
nd->nd_repstat = nfsvno_accchk(vp, accmode,
nd->nd_cred, exp, p, NFSACCCHK_NOOVERRIDE,
NFSACCCHK_VPISLOCKED, NULL);
}
}
if (!nd->nd_repstat)
nd->nd_repstat = nfsvno_getattr(vp, &nva, nd->nd_cred, p, 1);

View File

@ -43,6 +43,7 @@
#define CONF2_ENABLE_CHK 0x0e
#define CONF2_ENABLE_RES 0x0e
u_long hostb_alloc_start(int type, u_long start, u_long end, u_long count);
int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus);
int pci_cfgregopen(void);
u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes);

View File

@ -62,7 +62,7 @@ legacy_pcib_maxslots(device_t dev)
/* read configuration space register */
u_int32_t
uint32_t
legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func,
u_int reg, int bytes)
{
@ -73,7 +73,7 @@ legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func,
void
legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func,
u_int reg, u_int32_t data, int bytes)
u_int reg, uint32_t data, int bytes)
{
pci_cfgregwrite(bus, slot, func, reg, data, bytes);
}
@ -342,7 +342,7 @@ static void
legacy_pcib_identify(driver_t *driver, device_t parent)
{
int bus, slot, func;
u_int8_t hdrtype;
uint8_t hdrtype;
int found = 0;
int pcifunchigh;
int found824xx = 0;
@ -385,8 +385,8 @@ legacy_pcib_identify(driver_t *driver, device_t parent)
/*
* Read the IDs and class from the device.
*/
u_int32_t id;
u_int8_t class, subclass, busnum;
uint32_t id;
uint8_t class, subclass, busnum;
const char *s;
device_t *devs;
int ndevs, i;
@ -519,35 +519,45 @@ legacy_pcib_write_ivar(device_t dev, device_t child, int which,
return ENOENT;
}
/*
* Helper routine for x86 Host-PCI bridge driver resource allocation.
* This is used to adjust the start address of wildcard allocation
* requests to avoid low addresses that are known to be problematic.
*
* If no memory preference is given, use upper 32MB slot most BIOSes
* use for their memory window. This is typically only used on older
* laptops that don't have PCI busses behind a PCI bridge, so assuming
* > 32MB is likely OK.
*
* However, this can cause problems for other chipsets, so we make
* this tunable by hw.pci.host_mem_start.
*/
SYSCTL_DECL(_hw_pci);
static unsigned long legacy_host_mem_start = 0x80000000;
TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start);
SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN,
&legacy_host_mem_start, 0x80000000,
"Limit the host bridge memory to being above this address. Must be\n\
set at boot via a tunable.");
static unsigned long host_mem_start = 0x80000000;
TUNABLE_ULONG("hw.pci.host_mem_start", &host_mem_start);
SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, &host_mem_start,
0, "Limit the host bridge memory to being above this address.");
u_long
hostb_alloc_start(int type, u_long start, u_long end, u_long count)
{
if (start + count - 1 != end) {
if (type == SYS_RES_MEMORY && start < host_mem_start)
start = host_mem_start;
if (type == SYS_RES_IOPORT && start < 0x1000)
start = 0x1000;
}
return (start);
}
struct resource *
legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
{
/*
* If no memory preference is given, use upper 32MB slot most
* bioses use for their memory window. Typically other bridges
* before us get in the way to assert their preferences on memory.
* Hardcoding like this sucks, so a more MD/MI way needs to be
* found to do it. This is typically only used on older laptops
* that don't have pci busses behind pci bridge, so assuming > 32MB
* is liekly OK.
*
* However, this can cause problems for other chipsets, so we make
* this tunable by hw.pci.host_mem_start.
*/
if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL)
start = legacy_host_mem_start;
if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL)
start = 0x1000;
start = hostb_alloc_start(type, start, end, count);
return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
count, flags));
}

View File

@ -25,7 +25,7 @@ options LOG2_ID_PAGE_SIZE=27 # 128M
# option: LOG2_PAGE_SIZE
# Specify the log2 size of the page to be used for virtual memory management.
# The page size being equal to 1<<LOG2_PAGE_SIZE.
options LOG2_PAGE_SIZE=15 # 32K
options LOG2_PAGE_SIZE=14 # 16K
# option: SKI
# Build support for running under the ski simulator.

View File

@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
cyclic_clock_func_t cyclic_clock_func = NULL;
#endif
int cpu_can_deep_sleep = 0; /* C3 state is available. */
int cpu_disable_deep_sleep = 0; /* Timer dies in C3. */
static void setuptimer(void);

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd October 1, 2006
.Dd June 22, 2011
.Dt LIBALIAS 3
.Os
.Sh NAME
@ -257,6 +257,16 @@ Normal packet aliasing is not performed.
See
.Fn LibAliasProxyRule
below for details.
.It Dv PKT_ALIAS_SKIP_GLOBAL
This option is used by
.Pa ipfw_nat
only. Specifying it as a flag to
.Fn LibAliasSetMode
has no effect. See section
.Sx NETWORK ADDRESS TRANSLATION
in
.Xr ipfw 8
for more details.
.El
.Ed
.Pp

View File

@ -672,7 +672,15 @@ ps3bus_get_dma_tag(device_t dev, device_t child)
NULL, NULL, BUS_SPACE_MAXSIZE, 0, BUS_SPACE_MAXSIZE,
0, NULL, NULL, &dinfo->dma_tag);
bus_dma_tag_set_iommu(dinfo->dma_tag, dev, dinfo);
/*
* Note: storage devices have IOMMU mappings set up by the hypervisor,
* but use physical, non-translated addresses. The above IOMMU
* initialization is necessary for the hypervisor to be able to set up
* the mappings, but actual DMA mappings should not use the IOMMU
* routines.
*/
if (dinfo->bustype != PS3_BUSTYPE_STORAGE)
bus_dma_tag_set_iommu(dinfo->dma_tag, dev, dinfo);
fail:
mtx_unlock(&dinfo->iommu_mtx);

View File

@ -50,7 +50,6 @@ extern struct tte *tsb_kernel;
extern vm_size_t tsb_kernel_mask;
extern vm_size_t tsb_kernel_size;
extern vm_paddr_t tsb_kernel_phys;
extern u_int tsb_kernel_ldd_phys;
static __inline struct tte *
tsb_vpntobucket(pmap_t pm, vm_offset_t vpn)

View File

@ -70,7 +70,7 @@
* The number of PHYSSEG entries must be one greater than the number
* of phys_avail entries because the phys_avail entry that spans the
* largest physical address that is accessible by ISA DMA is split
* into two PHYSSEG entries.
* into two PHYSSEG entries.
*/
#define VM_PHYSSEG_MAX 64
@ -136,13 +136,13 @@
* 43 bits of user address space is considered to be "enough", so we ignore it.
*
* Upper region: 0xffffffffffffffff
* 0xfffff80000000000
*
* 0xfffff80000000000
*
* Hole: 0xfffff7ffffffffff
* 0x0000080000000000
* 0x0000080000000000
*
* Lower region: 0x000007ffffffffff
* 0x0000000000000000
* 0x0000000000000000
*
* In general we ignore the upper region, and use the lower region as mappable
* space.
@ -218,7 +218,7 @@
* is the total KVA space allocated for kmem_map.
*/
#ifndef VM_KMEM_SIZE_SCALE
#define VM_KMEM_SIZE_SCALE (3)
#define VM_KMEM_SIZE_SCALE (tsb_kernel_ldd_phys == 0 ? 3 : 1)
#endif
/*
@ -238,6 +238,7 @@
#define UMA_MD_SMALL_ALLOC
extern u_int tsb_kernel_ldd_phys;
extern vm_offset_t vm_max_kernel_address;
/*

View File

@ -384,11 +384,12 @@ pmap_bootstrap(u_int cpu_impl)
* public documentation is available for these, the latter just might
* not support it, yet.
*/
virtsz = roundup(physsz, PAGE_SIZE_4M << (PAGE_SHIFT - TTE_SHIFT));
if (cpu_impl == CPU_IMPL_SPARC64V ||
cpu_impl >= CPU_IMPL_ULTRASPARCIIIp)
cpu_impl >= CPU_IMPL_ULTRASPARCIIIp) {
tsb_kernel_ldd_phys = 1;
else {
virtsz = roundup(5 / 3 * physsz, PAGE_SIZE_4M <<
(PAGE_SHIFT - TTE_SHIFT));
} else {
dtlb_slots_avail = 0;
for (i = 0; i < dtlb_slots; i++) {
data = dtlb_get_data(i);
@ -401,6 +402,8 @@ pmap_bootstrap(u_int cpu_impl)
if (cpu_impl >= CPU_IMPL_ULTRASPARCI &&
cpu_impl < CPU_IMPL_ULTRASPARCIII)
dtlb_slots_avail /= 2;
virtsz = roundup(physsz, PAGE_SIZE_4M <<
(PAGE_SHIFT - TTE_SHIFT));
virtsz = MIN(virtsz, (dtlb_slots_avail * PAGE_SIZE_4M) <<
(PAGE_SHIFT - TTE_SHIFT));
}

View File

@ -253,6 +253,7 @@ void cpu_startprofclock(void);
void cpu_stopprofclock(void);
void cpu_idleclock(void);
void cpu_activeclock(void);
extern int cpu_can_deep_sleep;
extern int cpu_disable_deep_sleep;
int cr_cansee(struct ucred *u1, struct ucred *u2);

View File

@ -444,6 +444,19 @@ init_TSC_tc(void)
goto init;
}
/*
* We cannot use the TSC if it stops incrementing in deep sleep.
* Currently only Intel CPUs are known for this problem unless
* the invariant TSC bit is set.
*/
if (cpu_can_deep_sleep && cpu_vendor_id == CPU_VENDOR_INTEL &&
(amd_pminfo & AMDPM_TSC_INVARIANT) == 0) {
tsc_timecounter.tc_quality = -1000;
if (bootverbose)
printf("TSC timecounter disabled: C3 enabled.\n");
goto init;
}
#ifdef SMP
/*
* We can not use the TSC in SMP mode unless the TSCs on all CPUs are

View File

@ -41,12 +41,10 @@ __FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <err.h>
#include <errno.h>
#include <limits.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "extern.h"

View File

@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "extern.h"

View File

@ -226,7 +226,7 @@ trying(const struct addrinfo *ai)
printf("Trying %s...\n", buf);
}
void
static void
cleanup(int sig __unused)
{
#define ERRSTR "Timed out.\n"

View File

@ -48,8 +48,6 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>

View File

@ -33,13 +33,9 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/acct.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int readrec_forward(FILE *f, struct acctv2 *av2);

View File

@ -76,6 +76,8 @@ static bool_t xdr_retval(XDR *, caddr_t);
#define MAXNAME 1024
#define MAXNFSUSERD 20
#define DEFNFSUSERD 4
#define MAXUSERMAX 100000
#define MINUSERMAX 10
#define DEFUSERMAX 200
#define DEFUSERTIMEOUT (1 * 60)
struct info {
@ -96,8 +98,8 @@ pid_t slaves[MAXNFSUSERD];
int
main(int argc, char *argv[])
{
int i;
int error, len, mustfreeai = 0;
int i, j;
int error, fnd_dup, len, mustfreeai = 0, start_uidpos;
struct nfsd_idargs nid;
struct passwd *pwd;
struct group *grp;
@ -107,6 +109,7 @@ main(int argc, char *argv[])
sigset_t signew;
char hostname[MAXHOSTNAMELEN + 1], *cp;
struct addrinfo *aip, hints;
static uid_t check_dups[MAXUSERMAX];
if (modfind("nfscommon") < 0) {
/* Not present in kernel, try loading it */
@ -163,9 +166,10 @@ main(int argc, char *argv[])
argc--;
argv++;
i = atoi(*argv);
if (i < 10 || i > 100000) {
if (i < MINUSERMAX || i > MAXUSERMAX) {
fprintf(stderr,
"usermax %d out of range 10<->100000\n", i);
"usermax %d out of range %d<->%d\n", i,
MINUSERMAX, MAXUSERMAX);
usage();
}
nid.nid_usermax = i;
@ -326,8 +330,25 @@ main(int argc, char *argv[])
/*
* Loop around adding all users.
*/
start_uidpos = i;
setpwent();
while (i < nid.nid_usermax && (pwd = getpwent())) {
fnd_dup = 0;
/*
* Yes, this is inefficient, but it is only done once when
* the daemon is started and will run in a fraction of a second
* for nid_usermax at 10000. If nid_usermax is cranked up to
* 100000, it will take several seconds, depending on the CPU.
*/
for (j = 0; j < (i - start_uidpos); j++)
if (check_dups[j] == pwd->pw_uid) {
/* Found another entry for uid, so skip it */
fnd_dup = 1;
break;
}
if (fnd_dup != 0)
continue;
check_dups[i - start_uidpos] = pwd->pw_uid;
nid.nid_uid = pwd->pw_uid;
nid.nid_name = pwd->pw_name;
nid.nid_namelen = strlen(pwd->pw_name);