summaryrefslogtreecommitdiff
path: root/device.c
blob: 249d7784a2ebb5b1e46396e46b914709599811e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
 * Copyright (C) 2010 chysun2000@gmail.com
 *
 * This file is part of nios2sim-ng.
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License. See the file "COPYING" in the main directory of this archive
 * for more details.
 */

#include <stdio.h>

#include "nios2sim-ng.h"
#include "device.h"
#include "uart.h"
#include "jtag_uart.h"

static struct device *devices[] = {
	&uart_core,
	&jtag_uart_core,
};
#define DEVICES_COUNT	ARRAY_SIZE(devices)

int device_init_all(void)
{
	unsigned int i;
	int ret = 0;

	for (i = 0; i < DEVICES_COUNT; i++) {
		struct device *dev = devices[i];

		if (dev->init == NULL)
			continue;

		ret = dev->init(dev);
		if (ret) {
			err("Failed to initialize device '%s'\n", dev->name);
			break;
		}

		vinfo("%s at 0x%08x\n", dev->name, dev->base);
	}

	return ret;
}