summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2019-03-13 12:53:46 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2019-03-13 12:53:46 +0000
commitc767c5a53dc0ab8ce9e92ab7599f7f3740819bfc (patch)
treed3d03d6f2f52aa3b546f7e2808d07921d09afe9e /usr/src
parent8585938b68c417dc081eba6fd4434484bb46dfe4 (diff)
parent36f5a109a7ea7c74a4d90af4f589df489e7537c0 (diff)
downloadillumos-joyent-c767c5a53dc0ab8ce9e92ab7599f7f3740819bfc.tar.gz
[illumos-gate merge]release-20190314
commit 0b427924a934b5ebe2ecd53ed66d8e65892da75e 10145 smbios_info_boot() gets NULL check wrong commit 464615a7e8b4d2de999abe2a1bd78b4be78efc0a 10497 loader: bootstrap.h cstyle cleanup commit cb0ea096588eb33ca26ea8853cda93b3372af2c7 10482 loader: console.c cstyle cleanup commit 6e4a33937f4aeff3a5b207e49607138445d66674 10498 loader: comconsole cstyle cleanup Conflicts: usr/src/uts/i86pc/os/cpuid.c
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/boot/sys/boot/common/bootstrap.h268
-rw-r--r--usr/src/boot/sys/boot/common/console.c357
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/comconsole.c216
-rw-r--r--usr/src/common/smbios/smb_info.c4
-rw-r--r--usr/src/uts/i86pc/os/cpuid.c22
5 files changed, 454 insertions, 413 deletions
diff --git a/usr/src/boot/sys/boot/common/bootstrap.h b/usr/src/boot/sys/boot/common/bootstrap.h
index 0ffe65f725..b691df0ac3 100644
--- a/usr/src/boot/sys/boot/common/bootstrap.h
+++ b/usr/src/boot/sys/boot/common/bootstrap.h
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* All rights reserved.
*
@@ -37,11 +37,11 @@ typedef int (bootblk_cmd_t)(int argc, char *argv[]);
#define COMMAND_ERRBUFSZ (256)
extern const char *command_errmsg;
extern char command_errbuf[COMMAND_ERRBUFSZ];
-#define CMD_OK 0
-#define CMD_WARN 1
-#define CMD_ERROR 2
-#define CMD_CRIT 3
-#define CMD_FATAL 4
+#define CMD_OK 0
+#define CMD_WARN 1
+#define CMD_ERROR 2
+#define CMD_CRIT 3
+#define CMD_FATAL 4
/* interp.c */
void interact(const char *rc);
@@ -84,10 +84,10 @@ int bcache_strategy(void *devdata, int rw, daddr_t blk,
*/
struct bcache_devdata
{
- int (*dv_strategy)(void *devdata, int rw, daddr_t blk,
- size_t size, char *buf, size_t *rsize);
- void *dv_devdata;
- void *dv_cache;
+ int (*dv_strategy)(void *devdata, int rw, daddr_t blk,
+ size_t size, char *buf, size_t *rsize);
+ void *dv_devdata;
+ void *dv_cache;
};
/*
@@ -95,64 +95,78 @@ struct bcache_devdata
*/
struct console
{
- const char *c_name;
- const char *c_desc;
- int c_flags;
-#define C_PRESENTIN (1<<0) /* console can provide input */
-#define C_PRESENTOUT (1<<1) /* console can provide output */
-#define C_ACTIVEIN (1<<2) /* user wants input from console */
-#define C_ACTIVEOUT (1<<3) /* user wants output to console */
-#define C_WIDEOUT (1<<4) /* c_out routine groks wide chars */
-#define C_MODERAW (1<<5) /* raw mode */
- void (*c_probe)(struct console *); /* set c_flags to match hardware */
- int (*c_init)(struct console *, int); /* reinit XXX may need more args */
- void (*c_out)(struct console *, int); /* emit c */
- int (*c_in)(struct console *); /* wait for and return input */
- int (*c_ready)(struct console *); /* return nonzer if input waiting */
- int (*c_ioctl)(struct console *, int, void *);
- void *c_private; /* private data */
+ const char *c_name;
+ const char *c_desc;
+ int c_flags;
+#define C_PRESENTIN (1<<0) /* console can provide input */
+#define C_PRESENTOUT (1<<1) /* console can provide output */
+#define C_ACTIVEIN (1<<2) /* user wants input from console */
+#define C_ACTIVEOUT (1<<3) /* user wants output to console */
+#define C_WIDEOUT (1<<4) /* c_out routine groks wide chars */
+#define C_MODERAW (1<<5) /* raw mode */
+
+ /* set c_flags to match hardware */
+ void (*c_probe)(struct console *);
+ /* reinit XXX may need more args */
+ int (*c_init)(struct console *, int);
+ /* emit c */
+ void (*c_out)(struct console *, int);
+ /* wait for and return input */
+ int (*c_in)(struct console *);
+ /* return nonzero if input is waiting */
+ int (*c_ready)(struct console *);
+ int (*c_ioctl)(struct console *, int, void *);
+ void *c_private; /* private data */
};
extern struct console *consoles[];
-void cons_probe(void);
-void cons_mode(int);
-void autoload_font(void);
+void cons_probe(void);
+void cons_mode(int);
+void autoload_font(void);
/*
* Plug-and-play enumerator/configurator interface.
*/
struct pnphandler
{
- const char *pp_name; /* handler/bus name */
- void (* pp_enumerate)(void); /* enumerate PnP devices, add to chain */
+ const char *pp_name; /* handler/bus name */
+ /* enumerate PnP devices, add to chain */
+ void (*pp_enumerate)(void);
};
struct pnpident
{
- char *id_ident; /* ASCII identifier, actual format varies with bus/handler */
- STAILQ_ENTRY(pnpident) id_link;
+ /* ASCII identifier, actual format varies with bus/handler */
+ char *id_ident;
+ STAILQ_ENTRY(pnpident) id_link;
};
struct pnpinfo
{
- char *pi_desc; /* ASCII description, optional */
- int pi_revision; /* optional revision (or -1) if not supported */
- char *pi_module; /* module/args nominated to handle device */
- int pi_argc; /* module arguments */
- char **pi_argv;
- struct pnphandler *pi_handler; /* handler which detected this device */
- STAILQ_HEAD(,pnpident) pi_ident; /* list of identifiers */
- STAILQ_ENTRY(pnpinfo) pi_link;
+ /* ASCII description, optional */
+ char *pi_desc;
+ /* optional revision (or -1) if not supported */
+ int pi_revision;
+ /* module/args nominated to handle device */
+ char *pi_module;
+ /* module arguments */
+ int pi_argc;
+ char **pi_argv;
+ /* handler which detected this device */
+ struct pnphandler *pi_handler;
+ /* list of identifiers */
+ STAILQ_HEAD(, pnpident) pi_ident;
+ STAILQ_ENTRY(pnpinfo) pi_link;
};
STAILQ_HEAD(pnpinfo_stql, pnpinfo);
-extern struct pnphandler *pnphandlers[]; /* provided by MD code */
+extern struct pnphandler *pnphandlers[]; /* provided by MD code */
void pnp_addident(struct pnpinfo *pi, char *ident);
struct pnpinfo *pnp_allocinfo(void);
void pnp_freeinfo(struct pnpinfo *pi);
void pnp_addinfo(struct pnpinfo *pi);
-char *pnp_eisaformat(u_int8_t *data);
+char *pnp_eisaformat(uint8_t *data);
/*
* < 0 - No ISA in system
@@ -174,10 +188,11 @@ extern char bootprog_info[];
*/
struct file_metadata
{
- size_t md_size;
- u_int16_t md_type;
- struct file_metadata *md_next;
- char md_data[1]; /* data are immediately appended */
+ size_t md_size;
+ uint16_t md_type;
+ struct file_metadata *md_next;
+ /* data are immediately appended */
+ char md_data[1];
};
struct preloaded_file;
@@ -185,11 +200,11 @@ struct mod_depend;
struct kernel_module
{
- char *m_name; /* module name */
- int m_version; /* module version */
- char *m_args; /* arguments for the module */
- struct preloaded_file *m_fp;
- struct kernel_module *m_next;
+ char *m_name; /* module name */
+ int m_version; /* module version */
+ char *m_args; /* arguments for the module */
+ struct preloaded_file *m_fp;
+ struct kernel_module *m_next;
};
/*
@@ -203,31 +218,40 @@ struct kernel_module
*/
struct preloaded_file
{
- char *f_name; /* file name */
- char *f_type; /* verbose file type, eg 'ELF kernel', 'pnptable', etc. */
- char *f_args; /* arguments for the file */
- struct file_metadata *f_metadata; /* metadata that will be placed in the module directory */
- int f_loader; /* index of the loader that read the file */
- vm_offset_t f_addr; /* load address */
- size_t f_size; /* file size */
- struct kernel_module *f_modules; /* list of modules if any */
- struct preloaded_file *f_next; /* next file */
+ char *f_name; /* file name */
+ /* verbose file type, eg 'ELF kernel', 'pnptable', etc. */
+ char *f_type;
+ char *f_args; /* arguments for the file */
+ /* metadata that will be placed in the module directory */
+ struct file_metadata *f_metadata;
+ /* index of the loader that read the file */
+ int f_loader;
+ vm_offset_t f_addr; /* load address */
+ size_t f_size; /* file size */
+ struct kernel_module *f_modules; /* list of modules if any */
+ struct preloaded_file *f_next; /* next file */
};
struct file_format
{
- /* Load function must return EFTYPE if it can't handle the module supplied */
- int (* l_load)(char *filename, u_int64_t dest, struct preloaded_file **result);
- /* Only a loader that will load a kernel (first module) should have an exec handler */
- int (* l_exec)(struct preloaded_file *mp);
+ /*
+ * Load function must return EFTYPE if it can't handle the module
+ * supplied.
+ */
+ int (*l_load)(char *, uint64_t, struct preloaded_file **);
+ /*
+ * Only a loader that will load a kernel (first module)
+ * should have an exec handler.
+ */
+ int (*l_exec)(struct preloaded_file *);
};
-extern struct file_format *file_formats[]; /* supplied by consumer */
-extern struct preloaded_file *preloaded_files;
+extern struct file_format *file_formats[]; /* supplied by consumer */
+extern struct preloaded_file *preloaded_files;
-int mod_load(char *name, struct mod_depend *verinfo, int argc, char *argv[]);
-int mod_loadkld(const char *name, int argc, char *argv[]);
-void unload(void);
+int mod_load(char *name, struct mod_depend *verinfo, int argc, char *argv[]);
+int mod_loadkld(const char *name, int argc, char *argv[]);
+void unload(void);
struct preloaded_file *file_alloc(void);
struct preloaded_file *file_findfile(const char *name, const char *type);
@@ -235,9 +259,9 @@ struct file_metadata *file_findmetadata(struct preloaded_file *fp, int type);
struct preloaded_file *file_loadraw(const char *name, char *type, int argc,
char **argv, int insert);
void file_discard(struct preloaded_file *fp);
-void file_addmetadata(struct preloaded_file *fp, int type, size_t size, void *p);
-int file_addmodule(struct preloaded_file *fp, char *modname, int version,
- struct kernel_module **newmp);
+void file_addmetadata(struct preloaded_file *, int, size_t, void *);
+int file_addmodule(struct preloaded_file *, char *, int,
+ struct kernel_module **);
void build_environment_module(void);
void build_font_module(void);
vm_offset_t bi_copyenv(vm_offset_t);
@@ -246,14 +270,14 @@ bool sha1(void *, size_t, uint8_t *);
/* MI module loaders */
#ifdef __elfN
/* Relocation types. */
-#define ELF_RELOC_REL 1
-#define ELF_RELOC_RELA 2
+#define ELF_RELOC_REL 1
+#define ELF_RELOC_RELA 2
/* Relocation offset for some architectures */
-extern u_int64_t __elfN(relocation_offset);
+extern uint64_t __elfN(relocation_offset);
struct elf_file;
-typedef Elf_Addr (symaddr_fn)(struct elf_file *ef, Elf_Size symidx);
+typedef Elf_Addr (symaddr_fn)(struct elf_file *, Elf_Size);
int elf64_loadfile(char *, uint64_t, struct preloaded_file **);
int elf32_loadfile(char *, uint64_t, struct preloaded_file **);
@@ -273,12 +297,12 @@ int elf32_load_modmetadata(struct preloaded_file *, uint64_t);
*/
struct bootblk_command
{
- const char *c_name;
- const char *c_desc;
- bootblk_cmd_t *c_fn;
+ const char *c_name;
+ const char *c_desc;
+ bootblk_cmd_t *c_fn;
};
-#define COMMAND_SET(tag, key, desc, func) \
+#define COMMAND_SET(tag, key, desc, func) \
static bootblk_cmd_t func; \
static struct bootblk_command _cmd_ ## tag = { key, desc, func }; \
DATA_SET(Xcommand_set, _cmd_ ## tag)
@@ -293,49 +317,55 @@ SET_DECLARE(Xcommand_set, struct bootblk_command);
*/
struct arch_switch
{
- /* Automatically load modules as required by detected hardware */
- int (*arch_autoload)(void);
- /* Locate the device for (name), return pointer to tail in (*path) */
- int (*arch_getdev)(void **dev, const char *name, const char **path);
- /* Copy from local address space to module address space, similar to bcopy() */
- ssize_t (*arch_copyin)(const void *src, vm_offset_t dest,
- const size_t len);
- /* Copy to local address space from module address space, similar to bcopy() */
- ssize_t (*arch_copyout)(const vm_offset_t src, void *dest,
+ /* Automatically load modules as required by detected hardware */
+ int (*arch_autoload)(void);
+ /* Locate the device for (name), return pointer to tail in (*path) */
+ int (*arch_getdev)(void **dev, const char *name, const char **path);
+ /*
+ * Copy from local address space to module address space,
+ * similar to bcopy()
+ */
+ ssize_t (*arch_copyin)(const void *src, vm_offset_t dest,
+ const size_t len);
+ /*
+ * Copy to local address space from module address space,
+ * similar to bcopy()
+ */
+ ssize_t (*arch_copyout)(const vm_offset_t src, void *dest,
const size_t len);
- /* Read from file to module address space, same semantics as read() */
- ssize_t (*arch_readin)(const int fd, vm_offset_t dest,
- const size_t len);
- /* Perform ISA byte port I/O (only for systems with ISA) */
- int (*arch_isainb)(int port);
- void (*arch_isaoutb)(int port, int value);
-
- /*
- * Interface to adjust the load address according to the "object"
- * being loaded.
- */
- vm_offset_t (*arch_loadaddr)(u_int type, void *data, vm_offset_t addr);
+ /* Read from file to module address space, same semantics as read() */
+ ssize_t (*arch_readin)(const int fd, vm_offset_t dest,
+ const size_t len);
+ /* Perform ISA byte port I/O (only for systems with ISA) */
+ int (*arch_isainb)(int port);
+ void (*arch_isaoutb)(int port, int value);
+
+ /*
+ * Interface to adjust the load address according to the "object"
+ * being loaded.
+ */
+ vm_offset_t (*arch_loadaddr)(uint_t type, void *data, vm_offset_t addr);
#define LOAD_ELF 1 /* data points to the ELF header. */
#define LOAD_RAW 2 /* data points to the module file name. */
#define LOAD_KERN 3 /* data points to the kernel file name. */
#define LOAD_MEM 4 /* data points to int for buffer size. */
- /*
- * Interface to release the load address.
- */
- void (*arch_free_loadaddr)(vm_offset_t addr, size_t pages);
-
- /*
- * Interface to inform MD code about a loaded (ELF) segment. This
- * can be used to flush caches and/or set up translations.
- */
+ /*
+ * Interface to release the load address.
+ */
+ void (*arch_free_loadaddr)(vm_offset_t addr, size_t pages);
+
+ /*
+ * Interface to inform MD code about a loaded (ELF) segment. This
+ * can be used to flush caches and/or set up translations.
+ */
#ifdef __elfN
- void (*arch_loadseg)(Elf_Ehdr *eh, Elf_Phdr *ph, uint64_t delta);
+ void (*arch_loadseg)(Elf_Ehdr *eh, Elf_Phdr *ph, uint64_t delta);
#else
- void (*arch_loadseg)(void *eh, void *ph, uint64_t delta);
+ void (*arch_loadseg)(void *eh, void *ph, uint64_t delta);
#endif
- /* Probe ZFS pool(s), if needed. */
- void (*arch_zfs_probe)(void);
+ /* Probe ZFS pool(s), if needed. */
+ void (*arch_zfs_probe)(void);
};
extern struct arch_switch archsw;
@@ -344,10 +374,10 @@ void delay(int delay);
void dev_cleanup(void);
-#ifndef CTASSERT /* Allow lint to override */
-#define CTASSERT(x) _CTASSERT(x, __LINE__)
-#define _CTASSERT(x, y) __CTASSERT(x, y)
-#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1]
+#ifndef CTASSERT /* Allow lint to override */
+#define CTASSERT(x) _CTASSERT(x, __LINE__)
+#define _CTASSERT(x, y) __CTASSERT(x, y)
+#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1]
#endif
#endif /* !_BOOTSTRAP_H_ */
diff --git a/usr/src/boot/sys/boot/common/console.c b/usr/src/boot/sys/boot/common/console.c
index 34488a886f..a3bc90cb3b 100644
--- a/usr/src/boot/sys/boot/common/console.c
+++ b/usr/src/boot/sys/boot/common/console.c
@@ -48,67 +48,68 @@ static int twiddle_set(struct env_var *ev, int flags, const void *value);
void
cons_probe(void)
{
- int cons;
- int active;
- char *prefconsole;
-
- /* We want a callback to install the new value when this var changes. */
- env_setenv("twiddle_divisor", EV_VOLATILE, "1", twiddle_set, env_nounset);
-
- /* Do all console probes */
- for (cons = 0; consoles[cons] != NULL; cons++) {
- consoles[cons]->c_flags = 0;
- consoles[cons]->c_probe(consoles[cons]);
- }
- /* Now find the first working one */
- active = -1;
- for (cons = 0; consoles[cons] != NULL && active == -1; cons++) {
- consoles[cons]->c_flags = 0;
- consoles[cons]->c_probe(consoles[cons]);
- if (consoles[cons]->c_flags == (C_PRESENTIN | C_PRESENTOUT))
- active = cons;
- }
- /* Force a console even if all probes failed */
- if (active == -1)
- active = 0;
+ int cons;
+ int active;
+ char *prefconsole;
- /* Check to see if a console preference has already been registered */
- prefconsole = getenv("console");
- if (prefconsole != NULL)
- prefconsole = strdup(prefconsole);
- if (prefconsole != NULL) {
- unsetenv("console"); /* we want to replace this */
- cons_change(prefconsole);
- } else {
- consoles[active]->c_flags |= C_ACTIVEIN | C_ACTIVEOUT;
- consoles[active]->c_init(consoles[active], 0);
- prefconsole = strdup(consoles[active]->c_name);
- }
-
- printf("Consoles: ");
- for (cons = 0; consoles[cons] != NULL; cons++)
- if (consoles[cons]->c_flags & (C_ACTIVEIN | C_ACTIVEOUT))
- printf("%s ", consoles[cons]->c_desc);
- printf("\n");
-
- if (prefconsole != NULL) {
- env_setenv("console", EV_VOLATILE, prefconsole, cons_set,
+ /* We want a callback to install the new value when this var changes. */
+ env_setenv("twiddle_divisor", EV_VOLATILE, "1", twiddle_set,
env_nounset);
- free(prefconsole);
- }
+
+ /* Do all console probes */
+ for (cons = 0; consoles[cons] != NULL; cons++) {
+ consoles[cons]->c_flags = 0;
+ consoles[cons]->c_probe(consoles[cons]);
+ }
+ /* Now find the first working one */
+ active = -1;
+ for (cons = 0; consoles[cons] != NULL && active == -1; cons++) {
+ consoles[cons]->c_flags = 0;
+ consoles[cons]->c_probe(consoles[cons]);
+ if (consoles[cons]->c_flags == (C_PRESENTIN | C_PRESENTOUT))
+ active = cons;
+ }
+ /* Force a console even if all probes failed */
+ if (active == -1)
+ active = 0;
+
+ /* Check to see if a console preference has already been registered */
+ prefconsole = getenv("console");
+ if (prefconsole != NULL)
+ prefconsole = strdup(prefconsole);
+ if (prefconsole != NULL) {
+ unsetenv("console"); /* we want to replace this */
+ cons_change(prefconsole);
+ } else {
+ consoles[active]->c_flags |= C_ACTIVEIN | C_ACTIVEOUT;
+ consoles[active]->c_init(consoles[active], 0);
+ prefconsole = strdup(consoles[active]->c_name);
+ }
+
+ printf("Consoles: ");
+ for (cons = 0; consoles[cons] != NULL; cons++)
+ if (consoles[cons]->c_flags & (C_ACTIVEIN | C_ACTIVEOUT))
+ printf("%s ", consoles[cons]->c_desc);
+ printf("\n");
+
+ if (prefconsole != NULL) {
+ env_setenv("console", EV_VOLATILE, prefconsole, cons_set,
+ env_nounset);
+ free(prefconsole);
+ }
}
void
cons_mode(int raw)
{
- int cons;
-
- for (cons = 0; consoles[cons] != NULL; cons++) {
- if (raw == 0)
- consoles[cons]->c_flags &= ~C_MODERAW;
- else
- consoles[cons]->c_flags |= C_MODERAW;
- }
+ int cons;
+
+ for (cons = 0; consoles[cons] != NULL; cons++) {
+ if (raw == 0)
+ consoles[cons]->c_flags &= ~C_MODERAW;
+ else
+ consoles[cons]->c_flags |= C_MODERAW;
+ }
}
int
@@ -123,11 +124,11 @@ getchar(void)
* this code expects all ->c_in() implementations to effectively do an
* ischar() check first, returning -1 if there's not a char ready.
*/
- for(;;) {
+ for (;;) {
for (cons = 0; consoles[cons] != NULL; cons++) {
if ((consoles[cons]->c_flags & flags) == flags &&
((rv = consoles[cons]->c_in(consoles[cons])) != -1))
- return(rv);
+ return (rv);
}
delay(30 * 1000); /* delay 30ms */
}
@@ -136,29 +137,30 @@ getchar(void)
int
ischar(void)
{
- int cons;
-
- for (cons = 0; consoles[cons] != NULL; cons++)
- if ((consoles[cons]->c_flags & (C_PRESENTIN | C_ACTIVEIN)) ==
- (C_PRESENTIN | C_ACTIVEIN) &&
- (consoles[cons]->c_ready(consoles[cons]) != 0))
- return(1);
- return(0);
+ int cons;
+
+ for (cons = 0; consoles[cons] != NULL; cons++)
+ if ((consoles[cons]->c_flags & (C_PRESENTIN | C_ACTIVEIN)) ==
+ (C_PRESENTIN | C_ACTIVEIN) &&
+ (consoles[cons]->c_ready(consoles[cons]) != 0))
+ return (1);
+ return (0);
}
void
putchar(int c)
{
- int cons;
-
- /* Expand newlines if not in raw mode */
- for (cons = 0; consoles[cons] != NULL; cons++)
- if ((consoles[cons]->c_flags & (C_PRESENTOUT | C_ACTIVEOUT)) ==
- (C_PRESENTOUT | C_ACTIVEOUT)) {
- if (c == '\n' && (consoles[cons]->c_flags & C_MODERAW) == 0)
- consoles[cons]->c_out(consoles[cons], '\r');
- consoles[cons]->c_out(consoles[cons], c);
- }
+ int cons;
+
+ /* Expand newlines if not in raw mode */
+ for (cons = 0; consoles[cons] != NULL; cons++)
+ if ((consoles[cons]->c_flags & (C_PRESENTOUT | C_ACTIVEOUT)) ==
+ (C_PRESENTOUT | C_ACTIVEOUT)) {
+ if (c == '\n' &&
+ (consoles[cons]->c_flags & C_MODERAW) == 0)
+ consoles[cons]->c_out(consoles[cons], '\r');
+ consoles[cons]->c_out(consoles[cons], c);
+ }
}
/*
@@ -167,12 +169,12 @@ putchar(int c)
static int
cons_find(const char *name)
{
- int cons;
+ int cons;
- for (cons = 0; consoles[cons] != NULL; cons++)
- if (!strcmp(consoles[cons]->c_name, name))
- return (cons);
- return (-1);
+ for (cons = 0; consoles[cons] != NULL; cons++)
+ if (strcmp(consoles[cons]->c_name, name) == 0)
+ return (cons);
+ return (-1);
}
/*
@@ -181,22 +183,23 @@ cons_find(const char *name)
static int
cons_set(struct env_var *ev, int flags, const void *value)
{
- int ret;
-
- if ((value == NULL) || (cons_check(value) == 0)) {
- /*
- * Return CMD_OK instead of CMD_ERROR to prevent forth syntax error,
- * which would prevent it processing any further loader.conf entries.
- */
- return (CMD_OK);
- }
+ int ret;
+
+ if ((value == NULL) || (cons_check(value) == 0)) {
+ /*
+ * Return CMD_OK instead of CMD_ERROR to prevent forth syntax
+ * error, which would prevent it processing any further
+ * loader.conf entries.
+ */
+ return (CMD_OK);
+ }
- ret = cons_change(value);
- if (ret != CMD_OK)
- return (ret);
+ ret = cons_change(value);
+ if (ret != CMD_OK)
+ return (ret);
- env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
- return (CMD_OK);
+ env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
+ return (CMD_OK);
}
/*
@@ -205,36 +208,36 @@ cons_set(struct env_var *ev, int flags, const void *value)
static int
cons_check(const char *string)
{
- int cons, found, failed;
- char *curpos, *dup, *next;
-
- dup = next = strdup(string);
- found = failed = 0;
- while (next != NULL) {
- curpos = strsep(&next, " ,");
- if (*curpos != '\0') {
- cons = cons_find(curpos);
- if (cons == -1) {
- printf("console %s is invalid!\n", curpos);
- failed++;
- } else {
- found++;
- }
+ int cons, found, failed;
+ char *curpos, *dup, *next;
+
+ dup = next = strdup(string);
+ found = failed = 0;
+ while (next != NULL) {
+ curpos = strsep(&next, " ,");
+ if (*curpos != '\0') {
+ cons = cons_find(curpos);
+ if (cons == -1) {
+ printf("console %s is invalid!\n", curpos);
+ failed++;
+ } else {
+ found++;
+ }
+ }
}
- }
- free(dup);
+ free(dup);
- if (found == 0)
- printf("no valid consoles!\n");
+ if (found == 0)
+ printf("no valid consoles!\n");
- if (found == 0 || failed != 0) {
- printf("Available consoles:\n");
- for (cons = 0; consoles[cons] != NULL; cons++)
- printf(" %s\n", consoles[cons]->c_name);
- }
+ if (found == 0 || failed != 0) {
+ printf("Available consoles:\n");
+ for (cons = 0; consoles[cons] != NULL; cons++)
+ printf(" %s\n", consoles[cons]->c_name);
+ }
- return (found);
+ return (found);
}
/*
@@ -243,57 +246,63 @@ cons_check(const char *string)
static int
cons_change(const char *string)
{
- int cons, active;
- char *curpos, *dup, *next;
-
- /* Disable all consoles */
- for (cons = 0; consoles[cons] != NULL; cons++) {
- consoles[cons]->c_flags &= ~(C_ACTIVEIN | C_ACTIVEOUT);
- }
-
- /* Enable selected consoles */
- dup = next = strdup(string);
- active = 0;
- while (next != NULL) {
- curpos = strsep(&next, " ,");
- if (*curpos == '\0')
- continue;
- cons = cons_find(curpos);
- if (cons >= 0) {
- consoles[cons]->c_flags |= C_ACTIVEIN | C_ACTIVEOUT;
- consoles[cons]->c_init(consoles[cons], 0);
- if ((consoles[cons]->c_flags & (C_PRESENTIN | C_PRESENTOUT)) ==
- (C_PRESENTIN | C_PRESENTOUT)) {
- active++;
- continue;
- }
-
- if (active != 0) {
- /* If no consoles have initialised we wouldn't see this. */
- printf("console %s failed to initialize\n",
- consoles[cons]->c_name);
- }
+ int cons, active;
+ char *curpos, *dup, *next;
+
+ /* Disable all consoles */
+ for (cons = 0; consoles[cons] != NULL; cons++) {
+ consoles[cons]->c_flags &= ~(C_ACTIVEIN | C_ACTIVEOUT);
}
- }
- free(dup);
+ /* Enable selected consoles */
+ dup = next = strdup(string);
+ active = 0;
+ while (next != NULL) {
+ curpos = strsep(&next, " ,");
+ if (*curpos == '\0')
+ continue;
+ cons = cons_find(curpos);
+ if (cons >= 0) {
+ consoles[cons]->c_flags |= C_ACTIVEIN | C_ACTIVEOUT;
+ consoles[cons]->c_init(consoles[cons], 0);
+ if ((consoles[cons]->c_flags &
+ (C_PRESENTIN | C_PRESENTOUT)) ==
+ (C_PRESENTIN | C_PRESENTOUT)) {
+ active++;
+ continue;
+ }
+
+ if (active != 0) {
+ /*
+ * If no consoles have initialised we wouldn't
+ * see this.
+ */
+ printf("console %s failed to initialize\n",
+ consoles[cons]->c_name);
+ }
+ }
+ }
- if (active == 0) {
- /* All requested consoles failed to initialise, try to recover. */
- for (cons = 0; consoles[cons] != NULL; cons++) {
- consoles[cons]->c_flags |= C_ACTIVEIN | C_ACTIVEOUT;
- consoles[cons]->c_init(consoles[cons], 0);
- if ((consoles[cons]->c_flags &
- (C_PRESENTIN | C_PRESENTOUT)) ==
- (C_PRESENTIN | C_PRESENTOUT))
- active++;
+ free(dup);
+
+ if (active == 0) {
+ /*
+ * All requested consoles failed to initialise, try to recover.
+ */
+ for (cons = 0; consoles[cons] != NULL; cons++) {
+ consoles[cons]->c_flags |= C_ACTIVEIN | C_ACTIVEOUT;
+ consoles[cons]->c_init(consoles[cons], 0);
+ if ((consoles[cons]->c_flags &
+ (C_PRESENTIN | C_PRESENTOUT)) ==
+ (C_PRESENTIN | C_PRESENTOUT))
+ active++;
}
if (active == 0)
- return (CMD_ERROR); /* Recovery failed. */
- }
+ return (CMD_ERROR); /* Recovery failed. */
+ }
- return (CMD_OK);
+ return (CMD_OK);
}
/*
@@ -307,16 +316,16 @@ cons_change(const char *string)
static int
twiddle_set(struct env_var *ev, int flags, const void *value)
{
- u_long tdiv;
- char * eptr;
-
- tdiv = strtoul(value, &eptr, 0);
- if (*(const char *)value == 0 || *eptr != 0) {
- printf("invalid twiddle_divisor '%s'\n", (const char *)value);
- return (CMD_ERROR);
- }
- twiddle_divisor((u_int)tdiv);
- env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
-
- return(CMD_OK);
+ ulong_t tdiv;
+ char *eptr;
+
+ tdiv = strtoul(value, &eptr, 0);
+ if (*(const char *)value == 0 || *eptr != 0) {
+ printf("invalid twiddle_divisor '%s'\n", (const char *)value);
+ return (CMD_ERROR);
+ }
+ twiddle_divisor((uint_t)tdiv);
+ env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
+
+ return (CMD_OK);
}
diff --git a/usr/src/boot/sys/boot/i386/libi386/comconsole.c b/usr/src/boot/sys/boot/i386/libi386/comconsole.c
index f4cd9b32fb..ab309c1aca 100644
--- a/usr/src/boot/sys/boot/i386/libi386/comconsole.c
+++ b/usr/src/boot/sys/boot/i386/libi386/comconsole.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1998 Michael Smith (msmith@freebsd.org)
*
* Redistribution and use in source and binary forms, with or without
@@ -32,12 +32,12 @@
#include <dev/pci/pcireg.h>
#include "libi386.h"
-#define COMC_TXWAIT 0x40000 /* transmit timeout */
-#define COMC_BPS(x) (115200 / (x)) /* speed to DLAB divisor */
-#define COMC_DIV2BPS(x) (115200 / (x)) /* DLAB divisor to speed */
+#define COMC_TXWAIT 0x40000 /* transmit timeout */
+#define COMC_BPS(x) (115200 / (x)) /* speed to DLAB divisor */
+#define COMC_DIV2BPS(x) (115200 / (x)) /* DLAB divisor to speed */
#ifndef COMSPEED
-#define COMSPEED 9600
+#define COMSPEED 9600
#endif
#define COM1_IOADDR 0x3f8
@@ -147,18 +147,18 @@ comc_probe(struct console *cp)
if (cp->c_private != NULL)
return;
- cp->c_private = malloc(sizeof(struct serial));
+ cp->c_private = malloc(sizeof (struct serial));
port = cp->c_private;
port->speed = COMSPEED;
if (strcmp(cp->c_name, "ttya") == 0)
- port->ioaddr = COM1_IOADDR;
+ port->ioaddr = COM1_IOADDR;
else if (strcmp(cp->c_name, "ttyb") == 0)
- port->ioaddr = COM2_IOADDR;
+ port->ioaddr = COM2_IOADDR;
else if (strcmp(cp->c_name, "ttyc") == 0)
- port->ioaddr = COM3_IOADDR;
+ port->ioaddr = COM3_IOADDR;
else if (strcmp(cp->c_name, "ttyd") == 0)
- port->ioaddr = COM4_IOADDR;
+ port->ioaddr = COM4_IOADDR;
port->lcr = BITS8; /* 8,n,1 */
port->ignore_cd = 1; /* ignore cd */
@@ -219,9 +219,9 @@ comc_probe(struct console *cp)
snprintf(name, sizeof (name), "%s-pcidev", cp->c_name);
env = getenv(name);
if (env != NULL) {
- port->locator = comc_parse_pcidev(env);
- if (port->locator != 0)
- comc_pcidev_handle(cp, port->locator);
+ port->locator = comc_parse_pcidev(env);
+ if (port->locator != 0)
+ comc_pcidev_handle(cp, port->locator);
}
unsetenv(name);
@@ -233,39 +233,39 @@ static int
comc_init(struct console *cp, int arg __attribute((unused)))
{
- comc_setup(cp);
+ comc_setup(cp);
- if ((cp->c_flags & (C_PRESENTIN | C_PRESENTOUT)) ==
- (C_PRESENTIN | C_PRESENTOUT))
- return (CMD_OK);
- return (CMD_ERROR);
+ if ((cp->c_flags & (C_PRESENTIN | C_PRESENTOUT)) ==
+ (C_PRESENTIN | C_PRESENTOUT))
+ return (CMD_OK);
+ return (CMD_ERROR);
}
static void
comc_putchar(struct console *cp, int c)
{
- int wait;
- struct serial *sp = cp->c_private;
+ int wait;
+ struct serial *sp = cp->c_private;
- for (wait = COMC_TXWAIT; wait > 0; wait--)
- if (inb(sp->ioaddr + com_lsr) & LSR_TXRDY) {
- outb(sp->ioaddr + com_data, (u_char)c);
- break;
- }
+ for (wait = COMC_TXWAIT; wait > 0; wait--)
+ if (inb(sp->ioaddr + com_lsr) & LSR_TXRDY) {
+ outb(sp->ioaddr + com_data, (uchar_t)c);
+ break;
+ }
}
static int
comc_getchar(struct console *cp)
{
- struct serial *sp = cp->c_private;
- return (comc_ischar(cp) ? inb(sp->ioaddr + com_data) : -1);
+ struct serial *sp = cp->c_private;
+ return (comc_ischar(cp) ? inb(sp->ioaddr + com_data) : -1);
}
static int
comc_ischar(struct console *cp)
{
- struct serial *sp = cp->c_private;
- return (inb(sp->ioaddr + com_lsr) & LSR_RXRDY);
+ struct serial *sp = cp->c_private;
+ return (inb(sp->ioaddr + com_lsr) & LSR_RXRDY);
}
static int
@@ -381,7 +381,7 @@ get_console(char *name)
{
struct console *cp = NULL;
- switch(name[3]) {
+ switch (name[3]) {
case 'a': cp = &ttya;
break;
case 'b': cp = &ttyb;
@@ -397,76 +397,76 @@ get_console(char *name)
static int
comc_mode_set(struct env_var *ev, int flags, const void *value)
{
- struct console *cp;
+ struct console *cp;
- if (value == NULL)
- return (CMD_ERROR);
+ if (value == NULL)
+ return (CMD_ERROR);
- if ((cp = get_console(ev->ev_name)) == NULL)
- return (CMD_ERROR);
+ if ((cp = get_console(ev->ev_name)) == NULL)
+ return (CMD_ERROR);
- if (comc_parse_mode(cp->c_private, value) == CMD_ERROR)
- return (CMD_ERROR);
+ if (comc_parse_mode(cp->c_private, value) == CMD_ERROR)
+ return (CMD_ERROR);
- comc_setup(cp);
+ comc_setup(cp);
- env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
+ env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
- return (CMD_OK);
+ return (CMD_OK);
}
static int
comc_cd_set(struct env_var *ev, int flags, const void *value)
{
- struct console *cp;
- struct serial *sp;
+ struct console *cp;
+ struct serial *sp;
- if (value == NULL)
- return (CMD_ERROR);
+ if (value == NULL)
+ return (CMD_ERROR);
- if ((cp = get_console(ev->ev_name)) == NULL)
- return (CMD_ERROR);
+ if ((cp = get_console(ev->ev_name)) == NULL)
+ return (CMD_ERROR);
- sp = cp->c_private;
- if (strcmp(value, "true") == 0)
- sp->ignore_cd = 1;
- else if (strcmp(value, "false") == 0)
- sp->ignore_cd = 0;
- else
- return (CMD_ERROR);
+ sp = cp->c_private;
+ if (strcmp(value, "true") == 0)
+ sp->ignore_cd = 1;
+ else if (strcmp(value, "false") == 0)
+ sp->ignore_cd = 0;
+ else
+ return (CMD_ERROR);
- comc_setup(cp);
+ comc_setup(cp);
- env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
+ env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
- return (CMD_OK);
+ return (CMD_OK);
}
static int
comc_rtsdtr_set(struct env_var *ev, int flags, const void *value)
{
- struct console *cp;
- struct serial *sp;
+ struct console *cp;
+ struct serial *sp;
- if (value == NULL)
- return (CMD_ERROR);
+ if (value == NULL)
+ return (CMD_ERROR);
- if ((cp = get_console(ev->ev_name)) == NULL)
- return (CMD_ERROR);
+ if ((cp = get_console(ev->ev_name)) == NULL)
+ return (CMD_ERROR);
- sp = cp->c_private;
- if (strcmp(value, "true") == 0)
- sp->rtsdtr_off = 1;
- else if (strcmp(value, "false") == 0)
- sp->rtsdtr_off = 0;
- else
- return (CMD_ERROR);
+ sp = cp->c_private;
+ if (strcmp(value, "true") == 0)
+ sp->rtsdtr_off = 1;
+ else if (strcmp(value, "false") == 0)
+ sp->rtsdtr_off = 0;
+ else
+ return (CMD_ERROR);
- comc_setup(cp);
+ comc_setup(cp);
- env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
+ env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
- return (CMD_OK);
+ return (CMD_OK);
}
/*
@@ -477,7 +477,7 @@ static uint32_t
comc_parse_pcidev(const char *string)
{
#ifdef NO_PCI
- (void)string;
+ (void) string;
return (0);
#else
char *p, *p1;
@@ -487,26 +487,26 @@ comc_parse_pcidev(const char *string)
errno = 0;
pres = strtoul(string, &p, 10);
- if (errno != 0 || p == string || *p != ':' || pres < 0 )
+ if (errno != 0 || p == string || *p != ':' || pres < 0)
return (0);
bus = pres;
p1 = ++p;
pres = strtoul(p1, &p, 10);
- if (errno != 0 || p == string || *p != ':' || pres < 0 )
+ if (errno != 0 || p == string || *p != ':' || pres < 0)
return (0);
dev = pres;
p1 = ++p;
pres = strtoul(p1, &p, 10);
- if (errno != 0 || p == string || (*p != ':' && *p != '\0') || pres < 0 )
+ if (errno != 0 || p == string || (*p != ':' && *p != '\0') || pres < 0)
return (0);
func = pres;
if (*p == ':') {
p1 = ++p;
pres = strtoul(p1, &p, 10);
- if (errno != 0 || p == string || *p != '\0' || pres <= 0 )
+ if (errno != 0 || p == string || *p != '\0' || pres <= 0)
return (0);
bar = pres;
} else
@@ -521,15 +521,15 @@ static int
comc_pcidev_handle(struct console *cp, uint32_t locator)
{
#ifdef NO_PCI
- (void)cp;
- (void)locator;
+ (void) cp;
+ (void) locator;
return (CMD_ERROR);
#else
struct serial *sp = cp->c_private;
uint32_t port;
if (biospci_read_config(locator & 0xffff,
- (locator & 0xff0000) >> 16, 2, &port) == -1) {
+ (locator & 0xff0000) >> 16, 2, &port) == -1) {
printf("Cannot read bar at 0x%x\n", locator);
return (CMD_ERROR);
}
@@ -537,7 +537,7 @@ comc_pcidev_handle(struct console *cp, uint32_t locator)
printf("Memory bar at 0x%x\n", locator);
return (CMD_ERROR);
}
- port &= PCIM_BAR_IO_BASE;
+ port &= PCIM_BAR_IO_BASE;
comc_setup(cp);
sp->locator = locator;
@@ -575,38 +575,38 @@ comc_pcidev_set(struct env_var *ev, int flags, const void *value)
static void
comc_setup(struct console *cp)
{
- struct serial *sp = cp->c_private;
- static int TRY_COUNT = 1000000;
- int tries;
-
- if ((cp->c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) == 0)
- return;
-
- outb(sp->ioaddr + com_cfcr, CFCR_DLAB | sp->lcr);
- outb(sp->ioaddr + com_dlbl, COMC_BPS(sp->speed) & 0xff);
- outb(sp->ioaddr + com_dlbh, COMC_BPS(sp->speed) >> 8);
- outb(sp->ioaddr + com_cfcr, sp->lcr);
- outb(sp->ioaddr + com_mcr,
- sp->rtsdtr_off? ~(MCR_RTS | MCR_DTR):MCR_RTS | MCR_DTR);
-
- tries = 0;
- do
- inb(sp->ioaddr + com_data);
- while (inb(sp->ioaddr + com_lsr) & LSR_RXRDY && ++tries < TRY_COUNT);
-
- if (tries < TRY_COUNT) {
- cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT);
- } else
- cp->c_flags &= ~(C_PRESENTIN | C_PRESENTOUT);
+ struct serial *sp = cp->c_private;
+ static int TRY_COUNT = 1000000;
+ int tries;
+
+ if ((cp->c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) == 0)
+ return;
+
+ outb(sp->ioaddr + com_cfcr, CFCR_DLAB | sp->lcr);
+ outb(sp->ioaddr + com_dlbl, COMC_BPS(sp->speed) & 0xff);
+ outb(sp->ioaddr + com_dlbh, COMC_BPS(sp->speed) >> 8);
+ outb(sp->ioaddr + com_cfcr, sp->lcr);
+ outb(sp->ioaddr + com_mcr,
+ sp->rtsdtr_off? ~(MCR_RTS | MCR_DTR) : MCR_RTS | MCR_DTR);
+
+ tries = 0;
+ do {
+ inb(sp->ioaddr + com_data);
+ } while (inb(sp->ioaddr + com_lsr) & LSR_RXRDY && ++tries < TRY_COUNT);
+
+ if (tries < TRY_COUNT)
+ cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT);
+ else
+ cp->c_flags &= ~(C_PRESENTIN | C_PRESENTOUT);
}
static int
comc_getspeed(struct serial *sp)
{
- u_int divisor;
- u_char dlbh;
- u_char dlbl;
- u_char cfcr;
+ uint_t divisor;
+ uchar_t dlbh;
+ uchar_t dlbl;
+ uchar_t cfcr;
cfcr = inb(sp->ioaddr + com_cfcr);
outb(sp->ioaddr + com_cfcr, CFCR_DLAB | cfcr);
diff --git a/usr/src/common/smbios/smb_info.c b/usr/src/common/smbios/smb_info.c
index 71d5dd897d..2c67f2964a 100644
--- a/usr/src/common/smbios/smb_info.c
+++ b/usr/src/common/smbios/smb_info.c
@@ -1072,13 +1072,15 @@ id_t
smbios_info_boot(smbios_hdl_t *shp, smbios_boot_t *bp)
{
const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BOOT);
- const smb_boot_t *b = (smb_boot_t *)(uintptr_t)stp->smbst_hdr;
+ const smb_boot_t *b;
if (stp == NULL)
return (-1); /* errno is set for us */
bzero(bp, sizeof (smbios_boot_t));
+ b = (smb_boot_t *)(uintptr_t)stp->smbst_hdr;
+
bp->smbt_status = b->smbbo_status[0];
bp->smbt_size = stp->smbst_hdr->smbh_len - sizeof (smb_boot_t);
bp->smbt_data = bp->smbt_size ? &b->smbbo_status[1] : NULL;
diff --git a/usr/src/uts/i86pc/os/cpuid.c b/usr/src/uts/i86pc/os/cpuid.c
index 96d00a5f8a..cf4ee31df7 100644
--- a/usr/src/uts/i86pc/os/cpuid.c
+++ b/usr/src/uts/i86pc/os/cpuid.c
@@ -821,20 +821,20 @@
*
* cpi_ncore_bits
*
- * This indicates the number of bits that are required to represent all of
- * the cores in the system. As cores are derived based on their APIC IDs,
- * we aren't guaranteed a run of APIC IDs starting from zero. It's OK for
- * this value to be larger than the actual number of IDs that are present
- * in the system. This is used to size tables by the CMI framework. It is
- * only filled in for Intel and AMD CPUs.
+ * This indicates the number of bits that are required to represent all of
+ * the cores in the system. As cores are derived based on their APIC IDs,
+ * we aren't guaranteed a run of APIC IDs starting from zero. It's OK for
+ * this value to be larger than the actual number of IDs that are present
+ * in the system. This is used to size tables by the CMI framework. It is
+ * only filled in for Intel and AMD CPUs.
*
* cpi_nthread_bits
*
- * This indicates the number of bits required to represent all of the IDs
- * that cover the logical CPUs that exist on a given core. It's OK for this
- * value to be larger than the actual number of IDs that are present in the
- * system. This is used to size tables by the CMI framework. It is
- * only filled in for Intel and AMD CPUs.
+ * This indicates the number of bits required to represent all of the IDs
+ * that cover the logical CPUs that exist on a given core. It's OK for this
+ * value to be larger than the actual number of IDs that are present in the
+ * system. This is used to size tables by the CMI framework. It is
+ * only filled in for Intel and AMD CPUs.
*
* -----------
* Hypervisors