Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/uart/uart_subr.c
Show First 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | uart_parse_tag(const char **p) | ||||
if ((*p)[0] == 'x' && (*p)[1] == 'o') { | if ((*p)[0] == 'x' && (*p)[1] == 'o') { | ||||
tag = UART_TAG_XO; | tag = UART_TAG_XO; | ||||
goto out; | goto out; | ||||
} | } | ||||
return (-1); | return (-1); | ||||
out: | out: | ||||
*p += 2; | *p += 2; | ||||
if ((*p)[0] != ':') | if ((*p)[0] != ':' && (*p)[0] != '=') | ||||
return (-1); | return (-1); | ||||
(*p)++; | (*p)++; | ||||
return (tag); | return (tag); | ||||
} | } | ||||
/* | /* | ||||
* Parse a device specification. The specification is a list of attributes | * Parse a device specification. The specification is a list of attributes | ||||
* separated by commas. Each attribute is a tag-value pair with the tag and | * separated by commas. Each attribute is a tag-value pair with the tag and | ||||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | case UART_TAG_RS: | ||||
break; | break; | ||||
case UART_TAG_SB: | case UART_TAG_SB: | ||||
di->stopbits = uart_parse_long(&spec); | di->stopbits = uart_parse_long(&spec); | ||||
break; | break; | ||||
case UART_TAG_XO: | case UART_TAG_XO: | ||||
di->bas.rclk = uart_parse_long(&spec); | di->bas.rclk = uart_parse_long(&spec); | ||||
break; | break; | ||||
default: | default: | ||||
freeenv(cp); | goto inval; | ||||
return (EINVAL); | |||||
} | } | ||||
if (*spec == '\0') | if (*spec == '\0') | ||||
break; | break; | ||||
if (*spec != ',') { | if (*spec != ',') | ||||
freeenv(cp); | goto inval; | ||||
return (EINVAL); | |||||
} | |||||
spec++; | spec++; | ||||
} | } | ||||
freeenv(cp); | |||||
/* | /* | ||||
* If we still have an invalid address, the specification must be | * If we still have an invalid address, the specification must be | ||||
* missing an I/O port or memory address. We don't like that. | * missing an I/O port or memory address. We don't like that. | ||||
*/ | */ | ||||
if (addr == ~0U) | if (addr == ~0U) | ||||
return (EINVAL); | goto inval; | ||||
freeenv(cp); | |||||
/* | /* | ||||
* Accept only the well-known baudrates. Any invalid baudrate | * Accept only the well-known baudrates. Any invalid baudrate | ||||
* is silently replaced with a 0-valued baudrate. The 0 baudrate | * is silently replaced with a 0-valued baudrate. The 0 baudrate | ||||
* has special meaning. It means that we're not supposed to | * has special meaning. It means that we're not supposed to | ||||
* program the baudrate and simply communicate with whatever | * program the baudrate and simply communicate with whatever | ||||
* speed the hardware is currently programmed for. | * speed the hardware is currently programmed for. | ||||
*/ | */ | ||||
Show All 9 Lines | uart_getenv(int devtype, struct uart_devinfo *di, struct uart_class *class) | ||||
} else | } else | ||||
di->baudrate = 0; | di->baudrate = 0; | ||||
/* Set the ops and create a bus space handle. */ | /* Set the ops and create a bus space handle. */ | ||||
di->ops = uart_getops(class); | di->ops = uart_getops(class); | ||||
error = bus_space_map(di->bas.bst, addr, uart_getrange(class), 0, | error = bus_space_map(di->bas.bst, addr, uart_getrange(class), 0, | ||||
&di->bas.bsh); | &di->bas.bsh); | ||||
return (error); | return (error); | ||||
inval: | |||||
printf("warning: bad uart specification: %s\n", cp); | |||||
freeenv(cp); | |||||
return (EINVAL); | |||||
} | } |