add a new physical console to back the virtual console */
| 203 | |
| 204 | /* add a new physical console to back the virtual console */ |
| 205 | int |
| 206 | cnadd(struct consdev *cn) |
| 207 | { |
| 208 | struct cn_device *cnd; |
| 209 | int i; |
| 210 | |
| 211 | STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) |
| 212 | if (cnd->cnd_cn == cn) |
| 213 | return (0); |
| 214 | for (i = 0; i < CNDEVTAB_SIZE; i++) { |
| 215 | cnd = &cn_devtab[i]; |
| 216 | if (cnd->cnd_cn == NULL) |
| 217 | break; |
| 218 | } |
| 219 | if (cnd->cnd_cn != NULL) |
| 220 | return (ENOMEM); |
| 221 | cnd->cnd_cn = cn; |
| 222 | if (cn->cn_name[0] == '\0') { |
| 223 | /* XXX: it is unclear if/where this print might output */ |
| 224 | printf("WARNING: console at %p has no name\n", cn); |
| 225 | } |
| 226 | STAILQ_INSERT_TAIL(&cn_devlist, cnd, cnd_next); |
| 227 | if (STAILQ_FIRST(&cn_devlist) == cnd) |
| 228 | ttyconsdev_select(cnd->cnd_cn->cn_name); |
| 229 | |
| 230 | /* Add device to the active mask. */ |
| 231 | cnavailable(cn, (cn->cn_flags & CN_FLAG_NOAVAIL) == 0); |
| 232 | |
| 233 | return (0); |
| 234 | } |
| 235 | |
| 236 | void |
| 237 | cnremove(struct consdev *cn) |
no test coverage detected