Skip to content

Commit

Permalink
[console+kbd+build] Add /dev/tty4
Browse files Browse the repository at this point in the history
Since we can now have 4 consoles up at a time (1 on MDA + 3 on CGA),
bump up the amount of ttys available.
I think CGA could do 4 pages on its own too, but we have to draw the
limit somewhere. 3+1 feels nice and even :]
  • Loading branch information
vkoskiv committed Sep 2, 2024
1 parent 98f74b7 commit dc9821b
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion elks/arch/i86/drivers/char/console-direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static struct hw_params params[N_DEVICETYPES] = {
0x1F, 0x06, 0x19, 0x1C,
0x02, 0x07, 0x06, 0x07,
0x00, 0x00, 0x00, 0x00,
}, 16, 2, 2000
}, 16, 3, 2000
}, /* CGA */
// TODO
//{ 0 }, /* EGA */
Expand Down
4 changes: 2 additions & 2 deletions elks/arch/i86/drivers/char/kbd-poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ static void kbd_timer(int data)
else {
dav = (dav >> 8) & 0xFF;
#ifndef CONFIG_CONSOLE_HEADLESS
if (dav >= 0x3B && dav <= 0x3D) { /* temp console switch on F1-F3*/
if (dav >= 0x3B && dav <= 0x3E) { /* temp console switch on F1-F4*/
Console_set_vc(dav - 0x3B);
dav = 0;
}
else if ((dav >= 0x68) && (dav < 0x6B)) { /* Change VC */
else if ((dav >= 0x68) && (dav < 0x6C)) { /* Change VC */
Console_set_vc(dav - 0x68);
dav = 0;
}
Expand Down
8 changes: 4 additions & 4 deletions elks/arch/i86/drivers/char/kbd-scancode.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ static void keyboard_irq(int irq, struct pt_regs *regs)
/* F11 and F12 function keys need 89 byte table like keys-de.h */
/* function keys are not posix standard here */

/* AltF1-F3 are console switch*/
if ((ModeState & ALT) && code <= SCAN_F1+2) {
/* AltF1-F4 are console switch*/
if ((ModeState & ALT) && code <= SCAN_F1+3) {
Console_set_vc(code - SCAN_F1);
return;
}
Expand Down Expand Up @@ -354,8 +354,8 @@ static void keyboard_irq(int irq, struct pt_regs *regs)

/* Step 6: Modify keyboard character based on some special states*/
if ((ModeState & (CTRL|ALT)) == ALT) {
/* Alt-1 - Alt-3 are also console switch (for systems w/no fnkeys)*/
if (key >= '1' && key <= '3') {
/* Alt-1 - Alt-4 are also console switch (for systems w/no fnkeys)*/
if (key >= '1' && key <= '4') {
Console_set_vc(key - '1');
return;
}
Expand Down
1 change: 1 addition & 0 deletions elks/fs/msdos/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct msdos_devdir_entry devnods[DEVDIR_SIZE] = {
{ "tty1", S_IFCHR | 0644, MKDEV(TTY_MAJOR, 0) },
{ "tty2", S_IFCHR | 0644, MKDEV(TTY_MAJOR, 1) },
{ "tty3", S_IFCHR | 0644, MKDEV(TTY_MAJOR, 2) },
{ "tty4", S_IFCHR | 0644, MKDEV(TTY_MAJOR, 3) },
{ "ttyS0", S_IFCHR | 0644, MKDEV(TTY_MAJOR, 64) },
{ "ttyS1", S_IFCHR | 0644, MKDEV(TTY_MAJOR, 65) },
{ "console",S_IFCHR | 0600, MKDEV(TTY_MAJOR, 254) },
Expand Down
1 change: 1 addition & 0 deletions elks/include/linuxmt/devnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define DEV_TTY1 MKDEV(TTY_MAJOR, 0)
#define DEV_TTY2 MKDEV(TTY_MAJOR, 1)
#define DEV_TTY3 MKDEV(TTY_MAJOR, 2)
#define DEV_TTY4 MKDEV(TTY_MAJOR, 3)
#define DEV_TTYS0 MKDEV(TTY_MAJOR, 64)
#define DEV_TTYS1 MKDEV(TTY_MAJOR, 65)

Expand Down
2 changes: 1 addition & 1 deletion elks/include/linuxmt/msdos_fs_sb.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct msdos_sb_info { /* space in struct super_block is 28 bytes */
#endif

#ifdef CONFIG_FS_DEV
#define DEVDIR_SIZE 44 /* # entries in FAT device table */
#define DEVDIR_SIZE 45 /* # entries in FAT device table */
#define DEVINO_BASE (MSDOS_DPB*2) /* (DEVDIR_SIZE+MSDOS_DBP-1) & ~(MSDOS_DBP-1) */

struct msdos_devdir_entry {
Expand Down
2 changes: 1 addition & 1 deletion elks/include/linuxmt/ntty.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/* Predefined maximum number of tty character devices */

#define MAX_CONSOLES 3
#define MAX_CONSOLES 4
#define MAX_PTYS 4

#define TTY_MINOR_OFFSET 0
Expand Down
1 change: 1 addition & 0 deletions elks/init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ static struct dev_name_struct {
{ "tty1", DEV_TTY1 },
{ "tty2", DEV_TTY2 },
{ "tty3", DEV_TTY3 },
{ "tty4", DEV_TTY4 },
{ NULL, 0 }
};

Expand Down
1 change: 1 addition & 0 deletions elkscmd/rootfs_template/bin/sys
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ create_dev_dir()
mknod $MNT/dev/rd1 b 1 1
mknod $MNT/dev/tty2 c 4 1
mknod $MNT/dev/tty3 c 4 2
mknod $MNT/dev/tty4 c 4 3
mknod $MNT/dev/ttyS2 c 4 66
mknod $MNT/dev/ttyS3 c 4 67
mknod $MNT/dev/ttyp1 c 4 9
Expand Down
3 changes: 2 additions & 1 deletion elkscmd/rootfs_template/etc/inittab
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ si::sysinit:/etc/rc.sys
# 2 single user ttyS0 only
# 3 multiuser tty1 and ttyS0
# 4 multiuser serial only (ttyS0,ttyS1)
# 5 multiuser console only (tty1,tty2,tty3)
# 5 multiuser console only (tty1,tty2,tty3,tty4)
# 6 multiuser console and serial
t1:1356:respawn:/bin/getty /dev/tty1
t2:56:respawn:/bin/getty /dev/tty2
t3:56:respawn:/bin/getty /dev/tty3
t4:56:respawn:/bin/getty /dev/tty4
s0:2346:respawn:/bin/getty /dev/ttyS0
s1:46:respawn:/bin/getty /dev/ttyS1 9600
1 change: 1 addition & 0 deletions image/Make.devices
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ devices:
$(MKDEV) /dev/tty1 c 4 0
$(MKDEV) /dev/tty2 c 4 1
$(MKDEV) /dev/tty3 c 4 2
$(MKDEV) /dev/tty4 c 4 3

# Pseudo-TTY slave devices.

Expand Down
1 change: 1 addition & 0 deletions libc/misc/devname.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static struct dev_name_struct {
{ "tty1", S_IFCHR, DEV_TTY1 },
{ "tty2", S_IFCHR, DEV_TTY2 },
{ "tty3", S_IFCHR, DEV_TTY3 },
{ "tty4", S_IFCHR, DEV_TTY4 },
};

static char *__fast_devname(dev_t dev, mode_t type)
Expand Down

0 comments on commit dc9821b

Please sign in to comment.