Rev 3969 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3969 | Rev 3978 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup fhc |
29 | /** @addtogroup obio |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** |
33 | /** |
34 | * @file fhc.c |
34 | * @file obio.c |
35 | * @brief FHC bus driver. |
35 | * @brief OBIO driver. |
- | 36 | * |
|
- | 37 | * OBIO is a short for on-board I/O. On UltraSPARC IIi and systems with U2P, |
|
- | 38 | * there is a piece of the root PCI bus controller address space, which |
|
- | 39 | * contains interrupt mapping and clear registers for all on-board devices. |
|
- | 40 | * Although UltraSPARC IIi and U2P are different in general, these registers can |
|
- | 41 | * be found at the same addresses. |
|
36 | */ |
42 | */ |
37 | 43 | ||
38 | #include <ipc/ipc.h> |
44 | #include <ipc/ipc.h> |
39 | #include <ipc/services.h> |
45 | #include <ipc/services.h> |
40 | #include <ipc/bus.h> |
46 | #include <ipc/bus.h> |
Line 49... | Line 55... | ||
49 | #include <align.h> |
55 | #include <align.h> |
50 | #include <async.h> |
56 | #include <async.h> |
51 | #include <stdio.h> |
57 | #include <stdio.h> |
52 | #include <ipc/devmap.h> |
58 | #include <ipc/devmap.h> |
53 | 59 | ||
54 | #define NAME "fhc" |
60 | #define NAME "obio" |
- | 61 | ||
- | 62 | #define OBIO_SIZE 0x1898 |
|
55 | 63 | ||
56 | #define FHC_UART_INR 0x39 |
64 | #define OBIO_IMR_BASE 0x200 |
- | 65 | #define OBIO_IMR(ino) (OBIO_IMR_BASE + ((ino) & INO_MASK)) |
|
57 | 66 | ||
58 | #define FHC_UART_IMAP 0x0 |
67 | #define OBIO_CIR_BASE 0x300 |
59 | #define FHC_UART_ICLR 0x4 |
68 | #define OBIO_CIR(ino) (OBIO_CIR_BASE + ((ino) & INO_MASK)) |
60 | 69 | ||
61 | static void *fhc_uart_phys; |
- | |
62 | static volatile uint32_t *fhc_uart_virt; |
- | |
63 | static size_t fhc_uart_size; |
70 | #define INO_MASK 0x1f |
64 | 71 | ||
- | 72 | static void *base_phys; |
|
- | 73 | static volatile uint64_t *base_virt; |
|
- | 74 | ||
65 | /** Handle one connection to ramdisk. |
75 | /** Handle one connection to obio. |
66 | * |
76 | * |
67 | * @param iid Hash of the request that opened the connection. |
77 | * @param iid Hash of the request that opened the connection. |
68 | * @param icall Call data of the request that opened the connection. |
78 | * @param icall Call data of the request that opened the connection. |
69 | */ |
79 | */ |
70 | static void fhc_connection(ipc_callid_t iid, ipc_call_t *icall) |
80 | static void obio_connection(ipc_callid_t iid, ipc_call_t *icall) |
71 | { |
81 | { |
72 | ipc_callid_t callid; |
82 | ipc_callid_t callid; |
73 | ipc_call_t call; |
83 | ipc_call_t call; |
74 | 84 | ||
75 | /* |
85 | /* |
Line 82... | Line 92... | ||
82 | 92 | ||
83 | callid = async_get_call(&call); |
93 | callid = async_get_call(&call); |
84 | switch (IPC_GET_METHOD(call)) { |
94 | switch (IPC_GET_METHOD(call)) { |
85 | case BUS_CLEAR_INTERRUPT: |
95 | case BUS_CLEAR_INTERRUPT: |
86 | inr = IPC_GET_ARG1(call); |
96 | inr = IPC_GET_ARG1(call); |
87 | switch (inr) { |
- | |
88 | case FHC_UART_INR: |
- | |
89 | fhc_uart_virt[FHC_UART_ICLR] = 0; |
97 | base_virt[OBIO_CIR(inr) & INO_MASK] = 0; |
90 | ipc_answer_0(callid, EOK); |
98 | ipc_answer_0(callid, EOK); |
91 | break; |
99 | break; |
92 | default: |
100 | default: |
93 | ipc_answer_0(callid, ENOTSUP); |
- | |
94 | break; |
- | |
95 | } |
- | |
96 | break; |
- | |
97 | default: |
- | |
98 | ipc_answer_0(callid, EINVAL); |
101 | ipc_answer_0(callid, EINVAL); |
99 | break; |
102 | break; |
100 | } |
103 | } |
101 | } |
104 | } |
102 | } |
105 | } |
103 | 106 | ||
104 | /** Initialize the FHC driver. |
107 | /** Initialize the OBIO driver. |
105 | * |
108 | * |
106 | * So far, the driver heavily depends on information provided by the kernel via |
109 | * So far, the driver heavily depends on information provided by the kernel via |
107 | * sysinfo. In the future, there should be a standalone FHC driver. |
110 | * sysinfo. In the future, there should be a standalone OBIO driver. |
108 | */ |
111 | */ |
109 | static bool fhc_init(void) |
112 | static bool obio_init(void) |
110 | { |
113 | { |
111 | ipcarg_t phonead; |
114 | ipcarg_t phonead; |
112 | 115 | ||
113 | fhc_uart_size = sysinfo_value("fhc.uart.size"); |
- | |
114 | fhc_uart_phys = (void *) sysinfo_value("fhc.uart.physical"); |
116 | base_phys = (void *) sysinfo_value("obio.base.physical"); |
115 | 117 | ||
116 | if (!fhc_uart_size) { |
118 | if (!base_phys) { |
117 | printf(NAME ": no FHC UART registers found\n"); |
119 | printf(NAME ": no OBIO registers found\n"); |
118 | return false; |
120 | return false; |
119 | } |
121 | } |
120 | 122 | ||
121 | fhc_uart_virt = as_get_mappable_page(fhc_uart_size); |
123 | base_virt = as_get_mappable_page(OBIO_SIZE); |
122 | 124 | ||
123 | int flags = AS_AREA_READ | AS_AREA_WRITE; |
125 | int flags = AS_AREA_READ | AS_AREA_WRITE; |
124 | int retval = physmem_map(fhc_uart_phys, (void *) fhc_uart_virt, |
126 | int retval = physmem_map(base_phys, (void *) base_virt, |
125 | ALIGN_UP(fhc_uart_size, PAGE_SIZE) >> PAGE_WIDTH, flags); |
127 | ALIGN_UP(OBIO_SIZE, PAGE_SIZE) >> PAGE_WIDTH, flags); |
126 | 128 | ||
127 | if (retval < 0) { |
129 | if (retval < 0) { |
128 | printf(NAME ": Error mapping FHC UART registers\n"); |
130 | printf(NAME ": Error mapping OBIO registers\n"); |
129 | return false; |
131 | return false; |
130 | } |
132 | } |
131 | 133 | ||
132 | printf(NAME ": FHC UART registers at %p, %d bytes\n", fhc_uart_phys, |
134 | printf(NAME ": OBIO registers with base at %p\n", base_phys); |
133 | fhc_uart_size); |
- | |
134 | 135 | ||
135 | async_set_client_connection(fhc_connection); |
136 | async_set_client_connection(obio_connection); |
136 | ipc_connect_to_me(PHONE_NS, SERVICE_FHC, 0, 0, &phonead); |
137 | ipc_connect_to_me(PHONE_NS, SERVICE_OBIO, 0, 0, &phonead); |
137 | 138 | ||
138 | return true; |
139 | return true; |
139 | } |
140 | } |
140 | 141 | ||
141 | int main(int argc, char **argv) |
142 | int main(int argc, char **argv) |
142 | { |
143 | { |
143 | printf(NAME ": HelenOS FHC bus driver\n"); |
144 | printf(NAME ": HelenOS OBIO driver\n"); |
144 | 145 | ||
145 | if (!fhc_init()) |
146 | if (!obio_init()) |
146 | return -1; |
147 | return -1; |
147 | 148 | ||
148 | printf(NAME ": Accepting connections\n"); |
149 | printf(NAME ": Accepting connections\n"); |
149 | async_manager(); |
150 | async_manager(); |
150 | 151 |