1
0

initcalls: Add initial implementation

Create simple serial subsystem which makes use of initcalls, and convert
existing serial drivers to its use.
This commit is contained in:
2012-10-04 00:26:35 -04:00
parent 3f624153e7
commit 9d86813d8c
14 changed files with 219 additions and 102 deletions

View File

@ -18,17 +18,31 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <init.h>
#include <drivers/serial.h>
#include <types.h>
#define PL011_SERIAL_BASE 0x10009000
#define PL011_SERIAL_FLAG_REGISTER 0x18
#define PL011_SERIAL_BUFFER_FULL (1 << 5)
void pl011_putc(char c)
int pl011_putc(char c)
{
/* Wait until the serial buffer is empty */
while (*(volatile uint32*)(PL011_SERIAL_BASE + PL011_SERIAL_FLAG_REGISTER) & (PL011_SERIAL_BUFFER_FULL));
/* When it's empty, put our character at the base */
*(volatile uint32*)PL011_SERIAL_BASE = c;
return 0;
}
struct serial_dev pl011_dev = {
.putc = &pl011_putc
};
void pl011_init() {
serial_register_device(&pl011_dev);
}
early_initcall(pl011_init);