File indexing completed on 2025-05-11 08:23:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #include <unistd.h> /* write */
0037
0038 #include <bsp.h>
0039 #include <libchip/serial.h>
0040 #include <libchip/ns16550.h>
0041 #include <rtems/pci.h>
0042 #include <bsp/irq.h>
0043
0044 #if 1
0045 #define COM_CONSOLE_FUNCTIONS &ns16550_fns_polled
0046 #else
0047 #define COM_CONSOLE_FUNCTIONS &ns16550_fns
0048 #endif
0049
0050
0051
0052
0053 #define COM1_BASE_IO 0x3F8
0054 #define COM2_BASE_IO 0x3E8
0055
0056
0057 #define CLOCK_RATE (115200 * 16)
0058
0059 #define COM_IO_BASE_ADDRESS (0xa0000000UL | 0x18000000UL)
0060
0061 static uint8_t com_get_register(uintptr_t addr, uint8_t i);
0062 static void com_set_register(uintptr_t addr, uint8_t i, uint8_t val);
0063 static uint8_t tty2_get_register(uintptr_t addr, uint8_t i);
0064 static void tty2_set_register(uintptr_t addr, uint8_t i, uint8_t val);
0065
0066
0067 uint8_t com_get_register(uintptr_t addr, uint8_t i)
0068 {
0069 uint8_t val;
0070 volatile uint8_t *ptr;
0071 ptr = (volatile uint8_t *) COM_IO_BASE_ADDRESS;
0072 ptr += addr;
0073 ptr += i;
0074 val = *ptr;
0075
0076 return val;
0077 }
0078
0079 void com_set_register(uintptr_t addr, uint8_t i, uint8_t val)
0080 {
0081 volatile uint8_t *ptr;
0082
0083 ptr = (volatile uint8_t *) COM_IO_BASE_ADDRESS;
0084 ptr += addr;
0085 ptr += i;
0086 *ptr = val;
0087 }
0088
0089 uint8_t tty2_get_register(uintptr_t addr, uint8_t i)
0090 {
0091 uint8_t val;
0092 volatile uint8_t *ptr;
0093
0094 ptr = (volatile uint8_t *) COM_IO_BASE_ADDRESS;
0095 ptr += addr;
0096 ptr += (i * 8);
0097 val = *ptr;
0098
0099 return val;
0100 }
0101
0102 void tty2_set_register(uintptr_t addr, uint8_t i, uint8_t val)
0103 {
0104 volatile uint8_t *ptr;
0105
0106 ptr = (volatile uint8_t *) COM_IO_BASE_ADDRESS;
0107 ptr += addr;
0108 ptr += (i * 8);
0109 *ptr = val;
0110 }
0111
0112 console_tbl Console_Configuration_Ports[] = {
0113 {
0114 "/dev/tty0",
0115 SERIAL_NS16550,
0116 COM_CONSOLE_FUNCTIONS,
0117 NULL,
0118 NULL,
0119 16,
0120 8,
0121 (void *) 9600,
0122 COM1_BASE_IO,
0123 0x00000000,
0124 COM1_BASE_IO,
0125 com_get_register,
0126 com_set_register,
0127 NULL,
0128 NULL,
0129 CLOCK_RATE,
0130 MALTA_IRQ_TTY0
0131 },
0132 {
0133 "/dev/tty1",
0134 SERIAL_NS16550,
0135 COM_CONSOLE_FUNCTIONS,
0136 NULL,
0137 NULL,
0138 16,
0139 8,
0140 (void *) 9600,
0141 COM2_BASE_IO,
0142 0x00000000,
0143 COM2_BASE_IO,
0144 com_get_register,
0145 com_set_register,
0146 NULL,
0147 NULL,
0148 CLOCK_RATE,
0149 MALTA_IRQ_TTY1
0150 },
0151 {
0152 "/dev/tty2",
0153 SERIAL_NS16550,
0154 COM_CONSOLE_FUNCTIONS,
0155 NULL,
0156 NULL,
0157 16,
0158 8,
0159 (void *) 9600,
0160 0,
0161 0,
0162 0,
0163 tty2_get_register,
0164 tty2_set_register,
0165 NULL,
0166 NULL,
0167 CLOCK_RATE,
0168 MALTA_CPU_INT2
0169 },
0170 };
0171
0172
0173
0174
0175
0176 unsigned long Console_Configuration_Count = \
0177 (sizeof(Console_Configuration_Ports)/sizeof(console_tbl));