Cleanup in elf.c with .bss section clean; adm command mounts cdrom instead of floppy...
[ZeXOS.git] / kernel / arch / arm / bd / verpb.c
blobc72b9173be91f30c25d51886cf7dbeb2fcef9c0f
1 /*
2 * ZeX/OS
3 * Copyright (C) 2009 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <config.h>
21 #ifdef CONFIG_DRV_ARM_BOARD_VERPB
22 #include <arch/bd/verpb.h>
24 /**
25 * PL011
26 * Uart device
27 * Serial cable input/output
30 typedef struct {
31 unsigned char c : 8;
32 unsigned fr_err : 1;
33 unsigned par_err : 1;
34 unsigned break_err : 1;
35 unsigned ovrrun_err : 1;
36 } __attribute__ ((__packed__)) arm_rcv_block;
38 int armbd_uart_write (int port, unsigned char c)
40 unsigned char *uart_addr = (unsigned char *) ARM_VERPB_PL011_BASE0;
42 if (port)
43 uart_addr = (unsigned char *) ARM_VERPB_PL011_BASE1;
45 uart_addr += ARM_VERPB_PL011_DR * 4;
47 *uart_addr = c;
49 return 1;
52 unsigned char armbd_uart_received (int port)
54 unsigned *uart_addr = (unsigned *) ARM_VERPB_PL011_BASE0;
56 if (port)
57 uart_addr = (unsigned *) ARM_VERPB_PL011_BASE1;
59 uart_addr += 6;
61 if (*uart_addr & ARM_VERPB_PL011_RXFE)
62 return 0;
64 return 1;
67 unsigned char armbd_uart_read (int port)
69 arm_rcv_block *uart_addr = (arm_rcv_block *) ARM_VERPB_PL011_BASE0;
71 if (port)
72 uart_addr = (arm_rcv_block *) ARM_VERPB_PL011_BASE1;
74 #ifdef ARM_UART_ERR_LOG
75 unsigned char err = 0;
77 /* there is error on uart, lets clean it */
78 if (uart_addr->ovrrun_err)
79 err ++;
81 if (uart_addr->break_err)
82 err ++;
84 if (uart_addr->par_err)
85 err ++;
87 if (uart_addr->fr_err)
88 err ++;
89 #endif
90 return uart_addr->c;
94 /**
95 * PL110
96 * ARM PrimeCell Color LCD Controller
97 * Display output
100 void armbd_pl110_write (unsigned offset, unsigned val)
102 char *c = (char *) ARM_VERPB_PL110_BASE;
103 unsigned *p = (unsigned *) &c[offset];
105 *p = val;
108 unsigned armbd_pl110_read (unsigned offset)
110 char *c = (char *) ARM_VERPB_PL110_BASE;
111 unsigned *p = (unsigned *) &c[offset];
113 return *p;
116 void armbd_display_enable ()
118 armbd_pl110_write ((0x4 << 2), 0x500000); /* upper video memory address */
119 armbd_pl110_write ((0x5 << 2), 0x600000); /* lower video memory address */
120 armbd_pl110_write ((0x7 << 2), ARM_VERPB_PL110_CR_EN |
121 ARM_VERPB_PL110_CR_PWR); /* enable device */
122 armbd_pl110_write ((0x0 << 2), 157); /* 640 */
123 armbd_pl110_write ((0x1 << 2), 399); /* 400 */
127 * PL050
128 * ARM PrimeCell PS2 Keyboard/Mouse Interface
129 * Keyboard & Mouse over PS2
132 #define KBD_CMD_ENABLE 0xF4 /* Enable scanning */
133 #define KBD_REPLY_ACK 0xFA /* Command ACK */
134 #define KBD_CMD_RESET_ENABLE 0xF6 /* reset and enable scanning */
136 void armbd_pl050_write (unsigned offset, unsigned val)
138 char *c = (char *) ARM_INTCP_PL050_KB_BASE;
139 unsigned *p = (unsigned *) &c[offset];
141 *p = val;
144 unsigned armbd_pl050_read (unsigned offset)
146 char *c = (char *) ARM_INTCP_PL050_KB_BASE;
147 unsigned *p = (unsigned *) &c[offset];
149 return *p;
152 unsigned armbd_kbd_data ()
154 return armbd_pl050_read (1 << 2) == ARM_INTCP_PL050_TXEMPTY ? 0 : 1;
157 unsigned armbd_kbd_scancode ()
159 return armbd_pl050_read (2 << 2);
162 unsigned armbd_kbd_ack ()
164 armbd_pl050_write (2 << 2, KBD_REPLY_ACK);
167 unsigned armbd_kbd_init ()
169 armbd_pl050_write (2 << 2, KBD_CMD_RESET_ENABLE);
171 // armbd_pl050_write (2 << 2, KBD_CMD_SET_RATE);
173 return 1;
176 #endif