cmd_hppa.c (1.1) | cmd_hppa.c (1.2) |
---|---|
1/* $OpenBSD: cmd_hppa.c,v 1.1 2002/03/02 09:36:43 miod Exp $ */ | 1/* $OpenBSD: cmd_hppa.c,v 1.2 2002/03/06 23:09:44 miod Exp $ */ |
2 3/* 4 * Copyright (c) 2002 Miodrag Vallat 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: --- 47 unchanged lines hidden (view full) --- 57 sizeof(struct device_path)) 58 59/* 60 * Table for the possible console devices found during the device walk. 61 */ 62struct consoledev { 63 struct device_path dp; 64 int type; | 2 3/* 4 * Copyright (c) 2002 Miodrag Vallat 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: --- 47 unchanged lines hidden (view full) --- 57 sizeof(struct device_path)) 58 59/* 60 * Table for the possible console devices found during the device walk. 61 */ 62struct consoledev { 63 struct device_path dp; 64 int type; |
65 int iodc_type; 66 int iodc_model; |
|
65}; 66 67#define PS2 1 68#define HIL 2 69#define SERIAL 3 70#define GRAPHICS 4 71 | 67}; 68 69#define PS2 1 70#define HIL 2 71#define SERIAL 3 72#define GRAPHICS 4 73 |
72/* max. 2 serial ports (PDC compatibility) */ 73#define MAX_SERIALS 2 | 74/* max. serial ports */ 75#define MAX_SERIALS 4 |
74/* max. HIL and PS2 */ 75#define MAX_KEYBOARDS 2 | 76/* max. HIL and PS2 */ 77#define MAX_KEYBOARDS 2 |
76/* max. 3 heads (PDC compatibility) */ 77#define MAX_GRAPHICS 3 | 78/* max. heads */ 79#define MAX_GRAPHICS 4 |
78 79struct consoledev serials[MAX_SERIALS]; 80struct consoledev keyboards[MAX_KEYBOARDS]; 81struct consoledev graphics[MAX_GRAPHICS]; 82 83/* Relaxed device comparison */ 84#define MATCH(dev1, dev2) \ 85 (dev1).dp_mod == (dev2).dp_mod && \ 86 (dev1).dp_bc[4] == (dev2).dp_bc[4] && \ 87 (dev1).dp_bc[5] == (dev2).dp_bc[5] 88 89int walked; 90 91void bus_walk __P((int)); 92void register_device __P((struct consoledev *, int, | 80 81struct consoledev serials[MAX_SERIALS]; 82struct consoledev keyboards[MAX_KEYBOARDS]; 83struct consoledev graphics[MAX_GRAPHICS]; 84 85/* Relaxed device comparison */ 86#define MATCH(dev1, dev2) \ 87 (dev1).dp_mod == (dev2).dp_mod && \ 88 (dev1).dp_bc[4] == (dev2).dp_bc[4] && \ 89 (dev1).dp_bc[5] == (dev2).dp_bc[5] 90 91int walked; 92 93void bus_walk __P((int)); 94void register_device __P((struct consoledev *, int, |
93 struct device_path *, int, int)); | 95 struct device_path *, struct iodc_data *, int, int)); |
94 95int Xconsole __P((void)); 96void print_console __P((void)); 97int set_graphics __P((struct device_path *, int, char *)); 98int set_serial __P((struct device_path *, int, char *)); 99int set_console __P((struct device_path *)); 100 101int Xkeyboard __P((void)); --- 14 unchanged lines hidden (view full) --- 116 150, 117 300, 118 600, 119 1200, 120 2400, 121 4800, 122 7200, 123 9600, | 96 97int Xconsole __P((void)); 98void print_console __P((void)); 99int set_graphics __P((struct device_path *, int, char *)); 100int set_serial __P((struct device_path *, int, char *)); 101int set_console __P((struct device_path *)); 102 103int Xkeyboard __P((void)); --- 14 unchanged lines hidden (view full) --- 118 150, 119 300, 120 600, 121 1200, 122 2400, 123 4800, 124 7200, 125 9600, |
126 19200, 127 38400, 128 57600, 129 115200, 130 230400, |
|
124}; 125 126char* c_speeds[] = { 127 "50", 128 "75", 129 "110", 130 "150", 131 "300", 132 "600", 133 "1200", 134 "2400", 135 "4800", 136 "7200", 137 "9600", | 131}; 132 133char* c_speeds[] = { 134 "50", 135 "75", 136 "110", 137 "150", 138 "300", 139 "600", 140 "1200", 141 "2400", 142 "4800", 143 "7200", 144 "9600", |
145 "19200", 146 "38400", 147 "57600", 148 "115200", 149 "230400", |
|
138}; 139 140/* values to console parity table */ 141char *parities[] = { 142 "none", 143 "odd", 144 "<unknown parity>", 145 "even", --- 62 unchanged lines hidden (view full) --- 208 mode = sstor.ss_console.dp_layers[0]; 209 if (mode != 0) 210 printf(".%d", mode); 211 } else { 212 /* 213 * Serial console 214 */ 215 | 150}; 151 152/* values to console parity table */ 153char *parities[] = { 154 "none", 155 "odd", 156 "<unknown parity>", 157 "even", --- 62 unchanged lines hidden (view full) --- 220 mode = sstor.ss_console.dp_layers[0]; 221 if (mode != 0) 222 printf(".%d", mode); 223 } else { 224 /* 225 * Serial console 226 */ 227 |
216 printf("rs232%s", 217 port == 2 ? "_2" : ""); | 228 if (port == 1) 229 printf("rs232"); 230 else 231 printf("rs232_%d", port); |
218 219 speed = PZL_SPEED(sstor.ss_console.dp_layers[0]); | 232 233 speed = PZL_SPEED(sstor.ss_console.dp_layers[0]); |
220 if (speed < NENTS(i_speeds)) { 221 speed = i_speeds[speed]; 222 printf(".%d", speed); 223 } else 224 printf(".<unknown speed>"); | 234 printf(".%d", i_speeds[speed]); |
225 226 bits = PZL_BITS(sstor.ss_console.dp_layers[0]); 227 printf(".%d", bits); 228 229 parity = PZL_PARITY(sstor.ss_console.dp_layers[0]); 230 printf(".%s", parities[parity]); 231 } 232 --- 152 unchanged lines hidden (view full) --- 385 return 1; 386} 387 388int 389set_console(console) 390 struct device_path *console; 391{ 392 char *arg = cmd.argv[1], *dot; | 235 236 bits = PZL_BITS(sstor.ss_console.dp_layers[0]); 237 printf(".%d", bits); 238 239 parity = PZL_PARITY(sstor.ss_console.dp_layers[0]); 240 printf(".%s", parities[parity]); 241 } 242 --- 152 unchanged lines hidden (view full) --- 395 return 1; 396} 397 398int 399set_console(console) 400 struct device_path *console; 401{ 402 char *arg = cmd.argv[1], *dot; |
403 int port; |
|
393 394 /* extract first word */ 395 dot = strchr(arg, '.'); 396 if (dot != NULL) 397 *dot++ = '\0'; 398 399 /* 400 * Graphics console 401 */ 402 if (strcmp(arg, "graphics") == 0) 403 return set_graphics(console, 0, dot); | 404 405 /* extract first word */ 406 dot = strchr(arg, '.'); 407 if (dot != NULL) 408 *dot++ = '\0'; 409 410 /* 411 * Graphics console 412 */ 413 if (strcmp(arg, "graphics") == 0) 414 return set_graphics(console, 0, dot); |
415 if (strncmp(arg, "graphics_", 9) == 0) { 416 port = arg[9] - '0'; 417 if (port > 0 && port < MAX_GRAPHICS) 418 return set_graphics(console, port, dot); 419 } |
|
404 | 420 |
405 if (strcmp(arg, "graphics_1") == 0) 406 return set_graphics(console, 1, dot); 407 if (strcmp(arg, "graphics_2") == 0) 408 return set_graphics(console, 2, dot); 409 | |
410 /* 411 * Serial console 412 */ 413 if (strcmp(arg, "rs232") == 0) 414 return set_serial(console, 1, dot); | 421 /* 422 * Serial console 423 */ 424 if (strcmp(arg, "rs232") == 0) 425 return set_serial(console, 1, dot); |
426 if (strncmp(arg, "rs232_", 6) == 0) { 427 port = arg[6] - '0'; 428 if (port > 0 && port <= MAX_SERIALS) 429 return set_serial(console, port, dot); 430 } |
|
415 | 431 |
416 if (strcmp(arg, "rs232_2") == 0) 417 return set_serial(console, 2, dot); 418 | |
419 printf("invalid device specification, %s\n", arg); 420 return 0; 421} 422 423int 424Xconsole() 425{ 426 struct device_path console; --- 218 unchanged lines hidden (view full) --- 645 dp.dp_flags, dp.dp_mod, 646 mptr.iodc_type, mptr.iodc_sv_model); 647#endif 648 649 /* 650 * If the device can be considered as a valid rs232, 651 * graphics console or keyboard, register it. 652 * | 432 printf("invalid device specification, %s\n", arg); 433 return 0; 434} 435 436int 437Xconsole() 438{ 439 struct device_path console; --- 218 unchanged lines hidden (view full) --- 658 dp.dp_flags, dp.dp_mod, 659 mptr.iodc_type, mptr.iodc_sv_model); 660#endif 661 662 /* 663 * If the device can be considered as a valid rs232, 664 * graphics console or keyboard, register it. 665 * |
653 * GIO devices are registered as ``main'' devices, since 654 * in the PDC's view of the world, they are, yet other 655 * devices can be found before them... | 666 * Unfortunately, devices which should be considered as 667 * ``main'' aren't necessarily seen first. 668 * The rules we try to enforce here are as follows: 669 * - GIO PS/2 ports wins over any other PS/2 port. 670 * - the first GIO serial found wins over any other 671 * serial port. 672 * The second rule is a bit tricky to achieve, since on 673 * some machines (for example, 715/100XC), the two serial 674 * ports are not seen as attached to the same busses... |
656 */ 657 switch (mptr.iodc_type) { 658 case HPPA_TYPE_ADIRECT: 659 switch (mptr.iodc_sv_model) { 660 case HPPA_ADIRECT_RS232: 661 register_device(serials, MAX_SERIALS, | 675 */ 676 switch (mptr.iodc_type) { 677 case HPPA_TYPE_ADIRECT: 678 switch (mptr.iodc_sv_model) { 679 case HPPA_ADIRECT_RS232: 680 register_device(serials, MAX_SERIALS, |
662 &dp, SERIAL, 0); | 681 &dp, &mptr, SERIAL, 0); |
663 break; 664 case HPPA_ADIRECT_HIL: 665 register_device(keyboards, MAX_KEYBOARDS, | 682 break; 683 case HPPA_ADIRECT_HIL: 684 register_device(keyboards, MAX_KEYBOARDS, |
666 &dp, HIL, 0); | 685 &dp, &mptr, HIL, 0); |
667 break; 668 case HPPA_ADIRECT_PEACOCK: 669 case HPPA_ADIRECT_LEONARDO: 670 register_device(graphics, MAX_GRAPHICS, | 686 break; 687 case HPPA_ADIRECT_PEACOCK: 688 case HPPA_ADIRECT_LEONARDO: 689 register_device(graphics, MAX_GRAPHICS, |
671 &dp, GRAPHICS, 0); | 690 &dp, &mptr, GRAPHICS, 0); |
672 break; 673 } 674 break; 675 case HPPA_TYPE_FIO: 676 switch (mptr.iodc_sv_model) { 677 case HPPA_FIO_HIL: 678 register_device(keyboards, MAX_KEYBOARDS, | 691 break; 692 } 693 break; 694 case HPPA_TYPE_FIO: 695 switch (mptr.iodc_sv_model) { 696 case HPPA_FIO_HIL: 697 register_device(keyboards, MAX_KEYBOARDS, |
679 &dp, HIL, 0); | 698 &dp, &mptr, HIL, 0); |
680 break; 681 case HPPA_FIO_RS232: 682 register_device(serials, MAX_SERIALS, | 699 break; 700 case HPPA_FIO_RS232: 701 register_device(serials, MAX_SERIALS, |
683 &dp, SERIAL, 0); | 702 &dp, &mptr, SERIAL, 0); |
684 break; 685 case HPPA_FIO_DINOPCK: 686 register_device(keyboards, MAX_KEYBOARDS, | 703 break; 704 case HPPA_FIO_DINOPCK: 705 register_device(keyboards, MAX_KEYBOARDS, |
687 &dp, PS2, 0); | 706 &dp, &mptr, PS2, 0); |
688 break; 689 case HPPA_FIO_GPCIO: 690 /* 691 * KLUGE! At this point, there is no way to 692 * know if this port is the keyboard port or 693 * the mouse port. 694 * Let's assume the first port found is the 695 * keyboard, and ignore the others. 696 */ 697 if (kluge_ps2 != 0) 698 break; 699 register_device(keyboards, MAX_KEYBOARDS, | 707 break; 708 case HPPA_FIO_GPCIO: 709 /* 710 * KLUGE! At this point, there is no way to 711 * know if this port is the keyboard port or 712 * the mouse port. 713 * Let's assume the first port found is the 714 * keyboard, and ignore the others. 715 */ 716 if (kluge_ps2 != 0) 717 break; 718 register_device(keyboards, MAX_KEYBOARDS, |
700 &dp, PS2, 1); | 719 &dp, &mptr, PS2, 1); |
701 kluge_ps2++; 702 break; 703 case HPPA_FIO_GRS232: | 720 kluge_ps2++; 721 break; 722 case HPPA_FIO_GRS232: |
723 { 724 int j, first; 725 726 /* 727 * If a GIO serial port is already registered, 728 * registered as extra port... 729 */ 730 first = 1; 731 for (j = 0; j < MAX_SERIALS; j++) 732 if (serials[j].type == SERIAL && 733 serials[j].iodc_type == 734 HPPA_TYPE_FIO && 735 serials[j].iodc_model == 736 HPPA_FIO_GRS232) { 737 first = 0; 738 break; 739 } 740 |
|
704 register_device(serials, MAX_SERIALS, | 741 register_device(serials, MAX_SERIALS, |
705 &dp, SERIAL, 1); | 742 &dp, &mptr, SERIAL, first); 743 } |
706 break; 707 case HPPA_FIO_SGC: 708 register_device(graphics, MAX_GRAPHICS, | 744 break; 745 case HPPA_FIO_SGC: 746 register_device(graphics, MAX_GRAPHICS, |
709 &dp, GRAPHICS, 0); | 747 &dp, &mptr, GRAPHICS, 0); |
710 break; 711 case HPPA_FIO_GSGC: 712 register_device(graphics, MAX_GRAPHICS, | 748 break; 749 case HPPA_FIO_GSGC: 750 register_device(graphics, MAX_GRAPHICS, |
713 &dp, GRAPHICS, 1); | 751 &dp, &mptr, GRAPHICS, 1); |
714 break; 715 } 716 break; 717 } 718 } 719 720 /* 721 * Do a second pass to scan all child busses --- 20 unchanged lines hidden (view full) --- 742 case HPPA_TYPE_BRIDGE: 743 bus_walk(dp.dp_mod); 744 break; 745 } 746 } 747} 748 749void | 752 break; 753 } 754 break; 755 } 756 } 757 758 /* 759 * Do a second pass to scan all child busses --- 20 unchanged lines hidden (view full) --- 780 case HPPA_TYPE_BRIDGE: 781 bus_walk(dp.dp_mod); 782 break; 783 } 784 } 785} 786 787void |
750register_device(devlist, cnt, dp, type, first) | 788register_device(devlist, cnt, dp, mptr, type, first) |
751 struct consoledev *devlist; 752 int cnt; 753 struct device_path *dp; | 789 struct consoledev *devlist; 790 int cnt; 791 struct device_path *dp; |
792 struct iodc_data *mptr; |
|
754 int type; 755 int first; 756{ 757 int i; 758 struct consoledev *dev; 759 760 for (i = 0, dev = devlist; i < cnt; i++, dev++) 761 if (dev->type == 0) --- 12 unchanged lines hidden (view full) --- 774 if (first != 0) { 775 memcpy(devlist + 1, devlist, 776 (cnt - 1) * sizeof(struct consoledev)); 777 dev = devlist; 778 } 779 780 dev->dp = *dp; 781 dev->type = type; | 793 int type; 794 int first; 795{ 796 int i; 797 struct consoledev *dev; 798 799 for (i = 0, dev = devlist; i < cnt; i++, dev++) 800 if (dev->type == 0) --- 12 unchanged lines hidden (view full) --- 813 if (first != 0) { 814 memcpy(devlist + 1, devlist, 815 (cnt - 1) * sizeof(struct consoledev)); 816 dev = devlist; 817 } 818 819 dev->dp = *dp; 820 dev->type = type; |
821 dev->iodc_type = mptr->iodc_type; 822 dev->iodc_model = mptr->iodc_sv_model; |
|
782 783#ifdef DEBUG 784 printf("(registered as type %d)\n", type); 785#endif 786} | 823 824#ifdef DEBUG 825 printf("(registered as type %d)\n", type); 826#endif 827} |