kernel: exclude serial ports from pts numbering; start numbering at 1
This commit is contained in:
parent
1e7ffb7b1b
commit
43b6bd32e3
@ -43,4 +43,4 @@ typedef struct pty {
|
|||||||
void tty_output_process_slave(pty_t * pty, uint8_t c);
|
void tty_output_process_slave(pty_t * pty, uint8_t c);
|
||||||
void tty_output_process(pty_t * pty, uint8_t c);
|
void tty_output_process(pty_t * pty, uint8_t c);
|
||||||
void tty_input_process(pty_t * pty, uint8_t c);
|
void tty_input_process(pty_t * pty, uint8_t c);
|
||||||
pty_t * pty_new(struct winsize * size);
|
pty_t * pty_new(struct winsize * size, int index);
|
||||||
|
@ -140,7 +140,7 @@ static void serial_fill_name(pty_t * pty, char * name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static fs_node_t * serial_device_create(int port) {
|
static fs_node_t * serial_device_create(int port) {
|
||||||
pty_t * pty = pty_new(NULL);
|
pty_t * pty = pty_new(NULL, 0);
|
||||||
*pty_for_port(port) = pty;
|
*pty_for_port(port) = pty;
|
||||||
pty->write_out = serial_write_out;
|
pty->write_out = serial_write_out;
|
||||||
pty->fill_name = serial_fill_name;
|
pty->fill_name = serial_fill_name;
|
||||||
|
@ -381,7 +381,9 @@ void open_pty_slave(fs_node_t * node, unsigned int flags) {
|
|||||||
void close_pty_slave(fs_node_t * node) {
|
void close_pty_slave(fs_node_t * node) {
|
||||||
pty_t * pty = (pty_t *)node->device;
|
pty_t * pty = (pty_t *)node->device;
|
||||||
|
|
||||||
hashmap_remove(_pty_index, (void*)pty->name);
|
if (pty->name) {
|
||||||
|
hashmap_remove(_pty_index, (void*)pty->name);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -646,7 +648,7 @@ void pty_install(void) {
|
|||||||
vfs_mount("/dev/tty", _dev_tty);
|
vfs_mount("/dev/tty", _dev_tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
pty_t * pty_new(struct winsize * size) {
|
pty_t * pty_new(struct winsize * size, int index) {
|
||||||
|
|
||||||
if (!_pty_index) {
|
if (!_pty_index) {
|
||||||
pty_install();
|
pty_install();
|
||||||
@ -667,13 +669,15 @@ pty_t * pty_new(struct winsize * size) {
|
|||||||
pty->slave = pty_slave_create(pty);
|
pty->slave = pty_slave_create(pty);
|
||||||
|
|
||||||
/* tty name */
|
/* tty name */
|
||||||
pty->name = _pty_counter++;
|
pty->name = index;
|
||||||
pty->fill_name = tty_fill_name;
|
pty->fill_name = tty_fill_name;
|
||||||
|
|
||||||
pty->write_in = pty_write_in;
|
pty->write_in = pty_write_in;
|
||||||
pty->write_out = pty_write_out;
|
pty->write_out = pty_write_out;
|
||||||
|
|
||||||
hashmap_set(_pty_index, (void*)pty->name, pty);
|
if (index) {
|
||||||
|
hashmap_set(_pty_index, (void*)pty->name, pty);
|
||||||
|
}
|
||||||
|
|
||||||
if (size) {
|
if (size) {
|
||||||
memcpy(&pty->size, size, sizeof(struct winsize));
|
memcpy(&pty->size, size, sizeof(struct winsize));
|
||||||
@ -713,7 +717,7 @@ pty_t * pty_new(struct winsize * size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int pty_create(void *size, fs_node_t ** fs_master, fs_node_t ** fs_slave) {
|
int pty_create(void *size, fs_node_t ** fs_master, fs_node_t ** fs_slave) {
|
||||||
pty_t * pty = pty_new(size);
|
pty_t * pty = pty_new(size, ++_pty_counter);
|
||||||
|
|
||||||
*fs_master = pty->master;
|
*fs_master = pty->master;
|
||||||
*fs_slave = pty->slave;
|
*fs_slave = pty->slave;
|
||||||
|
Loading…
Reference in New Issue
Block a user