aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@FreeBSD.org>2019-11-02 10:53:23 +0000
committerToomas Soome <tsoome@FreeBSD.org>2019-11-02 10:53:23 +0000
commit0060947db1d813b177fa5349a3b952b5790a99f5 (patch)
tree84613177d2b9e5adae20db2d4f2e6bc77ee9554b
parent183b6fead897604405090119b88d5e68f996fff8 (diff)
downloadsrc-0060947db1d813b177fa5349a3b952b5790a99f5.tar.gz
src-0060947db1d813b177fa5349a3b952b5790a99f5.zip
loader: libi386/comconsole.c cstyle cleanup
Only cstyle, no functional changes.
Notes
Notes: svn path=/head/; revision=354252
-rw-r--r--stand/i386/libi386/comconsole.c246
1 files changed, 123 insertions, 123 deletions
diff --git a/stand/i386/libi386/comconsole.c b/stand/i386/libi386/comconsole.c
index 4eaad2d1a194..20b3076ecae7 100644
--- a/stand/i386/libi386/comconsole.c
+++ b/stand/i386/libi386/comconsole.c
@@ -67,144 +67,144 @@ static int comc_port = COMPORT;
static uint32_t comc_locator;
struct console comconsole = {
- "comconsole",
- "serial port",
- 0,
- comc_probe,
- comc_init,
- comc_putchar,
- comc_getchar,
- comc_ischar
+ .c_name = "comconsole",
+ .c_desc = "serial port",
+ .c_flags = 0,
+ .c_probe = comc_probe,
+ .c_init = comc_init,
+ .c_out = comc_putchar,
+ .c_in = comc_getchar,
+ .c_ready = comc_ischar
};
static void
comc_probe(struct console *cp)
{
- char intbuf[16];
- char *cons, *env;
- int speed, port;
- uint32_t locator;
-
- if (comc_curspeed == 0) {
- comc_curspeed = COMSPEED;
- /*
- * Assume that the speed was set by an earlier boot loader if
- * comconsole is already the preferred console.
- */
- cons = getenv("console");
- if ((cons != NULL && strcmp(cons, comconsole.c_name) == 0) ||
- getenv("boot_multicons") != NULL) {
- comc_curspeed = comc_getspeed();
- }
-
- env = getenv("comconsole_speed");
- if (env != NULL) {
- speed = comc_parseint(env);
- if (speed > 0)
- comc_curspeed = speed;
- }
-
- sprintf(intbuf, "%d", comc_curspeed);
- unsetenv("comconsole_speed");
- env_setenv("comconsole_speed", EV_VOLATILE, intbuf, comc_speed_set,
- env_nounset);
-
- env = getenv("comconsole_port");
- if (env != NULL) {
- port = comc_parseint(env);
- if (port > 0)
- comc_port = port;
- }
+ char intbuf[16];
+ char *cons, *env;
+ int speed, port;
+ uint32_t locator;
- sprintf(intbuf, "%d", comc_port);
- unsetenv("comconsole_port");
- env_setenv("comconsole_port", EV_VOLATILE, intbuf, comc_port_set,
- env_nounset);
-
- env = getenv("comconsole_pcidev");
- if (env != NULL) {
- locator = comc_parse_pcidev(env);
- if (locator != 0)
- comc_pcidev_handle(locator);
+ if (comc_curspeed == 0) {
+ comc_curspeed = COMSPEED;
+ /*
+ * Assume that the speed was set by an earlier boot loader if
+ * comconsole is already the preferred console.
+ */
+ cons = getenv("console");
+ if ((cons != NULL && strcmp(cons, comconsole.c_name) == 0) ||
+ getenv("boot_multicons") != NULL) {
+ comc_curspeed = comc_getspeed();
+ }
+
+ env = getenv("comconsole_speed");
+ if (env != NULL) {
+ speed = comc_parseint(env);
+ if (speed > 0)
+ comc_curspeed = speed;
+ }
+
+ sprintf(intbuf, "%d", comc_curspeed);
+ unsetenv("comconsole_speed");
+ env_setenv("comconsole_speed", EV_VOLATILE, intbuf,
+ comc_speed_set, env_nounset);
+
+ env = getenv("comconsole_port");
+ if (env != NULL) {
+ port = comc_parseint(env);
+ if (port > 0)
+ comc_port = port;
+ }
+
+ sprintf(intbuf, "%d", comc_port);
+ unsetenv("comconsole_port");
+ env_setenv("comconsole_port", EV_VOLATILE, intbuf,
+ comc_port_set, env_nounset);
+
+ env = getenv("comconsole_pcidev");
+ if (env != NULL) {
+ locator = comc_parse_pcidev(env);
+ if (locator != 0)
+ comc_pcidev_handle(locator);
+ }
+
+ unsetenv("comconsole_pcidev");
+ env_setenv("comconsole_pcidev", EV_VOLATILE, env,
+ comc_pcidev_set, env_nounset);
}
-
- unsetenv("comconsole_pcidev");
- env_setenv("comconsole_pcidev", EV_VOLATILE, env, comc_pcidev_set,
- env_nounset);
- }
- comc_setup(comc_curspeed, comc_port);
+ comc_setup(comc_curspeed, comc_port);
}
static int
comc_init(int arg)
{
- comc_setup(comc_curspeed, comc_port);
+ comc_setup(comc_curspeed, comc_port);
- if ((comconsole.c_flags & (C_PRESENTIN | C_PRESENTOUT)) ==
- (C_PRESENTIN | C_PRESENTOUT))
- return (CMD_OK);
- return (CMD_ERROR);
+ if ((comconsole.c_flags & (C_PRESENTIN | C_PRESENTOUT)) ==
+ (C_PRESENTIN | C_PRESENTOUT))
+ return (CMD_OK);
+ return (CMD_ERROR);
}
static void
comc_putchar(int c)
{
- int wait;
+ int wait;
- for (wait = COMC_TXWAIT; wait > 0; wait--)
- if (inb(comc_port + com_lsr) & LSR_TXRDY) {
- outb(comc_port + com_data, (u_char)c);
- break;
- }
+ for (wait = COMC_TXWAIT; wait > 0; wait--)
+ if (inb(comc_port + com_lsr) & LSR_TXRDY) {
+ outb(comc_port + com_data, (u_char)c);
+ break;
+ }
}
static int
comc_getchar(void)
{
- return (comc_ischar() ? inb(comc_port + com_data) : -1);
+ return (comc_ischar() ? inb(comc_port + com_data) : -1);
}
static int
comc_ischar(void)
{
- return (inb(comc_port + com_lsr) & LSR_RXRDY);
+ return (inb(comc_port + com_lsr) & LSR_RXRDY);
}
static int
comc_speed_set(struct env_var *ev, int flags, const void *value)
{
- int speed;
+ int speed;
- if (value == NULL || (speed = comc_parseint(value)) <= 0) {
- printf("Invalid speed\n");
- return (CMD_ERROR);
- }
+ if (value == NULL || (speed = comc_parseint(value)) <= 0) {
+ printf("Invalid speed\n");
+ return (CMD_ERROR);
+ }
- if (comc_curspeed != speed)
- comc_setup(speed, comc_port);
+ if (comc_curspeed != speed)
+ comc_setup(speed, comc_port);
- 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_port_set(struct env_var *ev, int flags, const void *value)
{
- int port;
+ int port;
- if (value == NULL || (port = comc_parseint(value)) <= 0) {
- printf("Invalid port\n");
- return (CMD_ERROR);
- }
+ if (value == NULL || (port = comc_parseint(value)) <= 0) {
+ printf("Invalid port\n");
+ return (CMD_ERROR);
+ }
- if (comc_port != port)
- comc_setup(comc_curspeed, port);
+ if (comc_port != port)
+ comc_setup(comc_curspeed, port);
- 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);
}
/*
@@ -320,46 +320,46 @@ comc_pcidev_set(struct env_var *ev, int flags, const void *value)
static void
comc_setup(int speed, int port)
{
- static int TRY_COUNT = 1000000;
- char intbuf[64];
- int tries;
-
- unsetenv("hw.uart.console");
- comc_curspeed = speed;
- comc_port = port;
- if ((comconsole.c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) == 0)
- return;
-
- outb(comc_port + com_cfcr, CFCR_DLAB | COMC_FMT);
- outb(comc_port + com_dlbl, COMC_BPS(speed) & 0xff);
- outb(comc_port + com_dlbh, COMC_BPS(speed) >> 8);
- outb(comc_port + com_cfcr, COMC_FMT);
- outb(comc_port + com_mcr, MCR_RTS | MCR_DTR);
-
- tries = 0;
- do
- inb(comc_port + com_data);
- while (inb(comc_port + com_lsr) & LSR_RXRDY && ++tries < TRY_COUNT);
-
- if (tries < TRY_COUNT) {
- comconsole.c_flags |= (C_PRESENTIN | C_PRESENTOUT);
- sprintf(intbuf, "io:%d,br:%d", comc_port, comc_curspeed);
- env_setenv("hw.uart.console", EV_VOLATILE, intbuf, NULL, NULL);
- } else
- comconsole.c_flags &= ~(C_PRESENTIN | C_PRESENTOUT);
+ static int TRY_COUNT = 1000000;
+ char intbuf[64];
+ int tries;
+
+ unsetenv("hw.uart.console");
+ comc_curspeed = speed;
+ comc_port = port;
+ if ((comconsole.c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) == 0)
+ return;
+
+ outb(comc_port + com_cfcr, CFCR_DLAB | COMC_FMT);
+ outb(comc_port + com_dlbl, COMC_BPS(speed) & 0xff);
+ outb(comc_port + com_dlbh, COMC_BPS(speed) >> 8);
+ outb(comc_port + com_cfcr, COMC_FMT);
+ outb(comc_port + com_mcr, MCR_RTS | MCR_DTR);
+
+ tries = 0;
+ do
+ inb(comc_port + com_data);
+ while (inb(comc_port + com_lsr) & LSR_RXRDY && ++tries < TRY_COUNT);
+
+ if (tries < TRY_COUNT) {
+ comconsole.c_flags |= (C_PRESENTIN | C_PRESENTOUT);
+ sprintf(intbuf, "io:%d,br:%d", comc_port, comc_curspeed);
+ env_setenv("hw.uart.console", EV_VOLATILE, intbuf, NULL, NULL);
+ } else
+ comconsole.c_flags &= ~(C_PRESENTIN | C_PRESENTOUT);
}
static int
comc_parseint(const char *speedstr)
{
- char *p;
- int speed;
+ char *p;
+ int speed;
- speed = strtol(speedstr, &p, 0);
- if (p == speedstr || *p != '\0' || speed <= 0)
- return (-1);
+ speed = strtol(speedstr, &p, 0);
+ if (p == speedstr || *p != '\0' || speed <= 0)
+ return (-1);
- return (speed);
+ return (speed);
}
static int