1 /*
2 * Copyright (c) 2012 Corey Tabaka
3 *
4 * Use of this source code is governed by a MIT-style
5 * license that can be found in the LICENSE file or at
6 * https://opensource.org/licenses/MIT
7 */
8
9 #include <dev/driver.h>
10 #include <dev/class/block.h>
11 #include <dev/class/netif.h>
12 #include <platform/uart.h>
13 #include <platform/ide.h>
14 #include <platform/pcnet.h>
15 #include <platform.h>
16 #include <target.h>
17 #include <malloc.h>
18 #include <string.h>
19 #include <lk/debug.h>
20
21 #if 0
22 static const struct platform_uart_config uart0_config = {
23 .io_port = 0x3f8,
24 .irq = 0x24,
25 .baud_rate = 115200,
26 .rx_buf_len = 1024,
27 .tx_buf_len = 1024,
28 };
29
30 DEVICE_INSTANCE(uart, uart0, &uart0_config);
31 #endif
32
33 // two legacy ISA IDE devices
34 static const struct platform_ide_config ide0_config = {
35 .legacy_index = 0,
36 };
37 DEVICE_INSTANCE(ide, ide0, &ide0_config, 0);
38
39 static const struct platform_ide_config ide1_config = {
40 .legacy_index = 1,
41 };
42 DEVICE_INSTANCE(ide, ide1, &ide1_config, 0);
43
44 // two PCI IDE devices
45 static const struct platform_ide_config pci_ide0_config = {
46 .legacy_index = 0x80,
47 };
48 DEVICE_INSTANCE(ide, pci_ide0, &pci_ide0_config, 0);
49
50 static const struct platform_ide_config pci_ide1_config = {
51 .legacy_index = 0x81,
52 };
53 DEVICE_INSTANCE(ide, pci_ide1, &pci_ide1_config, 0);
54
target_init(void)55 void target_init(void) {
56 // initialize static devices
57 device_init_all();
58
59 // try to initialize pci ide first
60 if (device_init(&__device_ide_pci_ide0) < 0 || device_init(&__device_ide_pci_ide1) < 0) {
61 // if that fails, initialize the legacy ISA IDE controllers
62 device_init(&__device_ide_ide0);
63 device_init(&__device_ide_ide1);
64 }
65
66 }
67
68