Changeset f834dd81 in mainline
- Timestamp:
- 2017-10-31T19:24:58Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3654684
- Parents:
- eca820c (diff), 2b11c3c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 3 added
- 4 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
Makefile
reca820c rf834dd81 1 #1 x# 2 2 # Copyright (c) 2006 Martin Decky 3 3 # All rights reserved. -
boot/arch/sparc64/Makefile.inc
reca820c rf834dd81 43 43 bus/pci/pciintel \ 44 44 bus/isa \ 45 intctl/obio \ 45 46 char/ns8250 46 47 47 48 RD_DRV_CFG += \ 48 49 bus/isa 49 50 RD_SRVS_NON_ESSENTIAL +=51 52 RD_SRVS_ESSENTIAL += \53 $(USPACE_PATH)/srv/hw/irc/obio/obio54 50 55 51 SOURCES = \ -
uspace/Makefile
reca820c rf834dd81 135 135 srv/hid/remcons \ 136 136 srv/hw/char/s3c24xx_uart \ 137 srv/hw/irc/obio \138 137 srv/hid/rfb \ 139 138 drv/audio/hdaudio \ … … 170 169 drv/intctl/i8259 \ 171 170 drv/intctl/icp-ic \ 171 drv/intctl/obio \ 172 172 drv/nic/ne2k \ 173 173 drv/nic/e1k \ -
uspace/drv/intctl/obio/Makefile
reca820c rf834dd81 28 28 # 29 29 30 USPACE_PREFIX = ../../../.. 30 USPACE_PREFIX = ../../.. 31 LIBS = $(LIBDRV_PREFIX)/libdrv.a 32 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include 31 33 BINARY = obio 32 34 33 35 SOURCES = \ 36 main.c \ 34 37 obio.c 35 38 -
uspace/drv/intctl/obio/obio.c
reca820c rf834dd81 42 42 */ 43 43 44 #include <align.h> 45 #include <as.h> 46 #include <async.h> 47 #include <ddf/driver.h> 48 #include <ddf/log.h> 49 #include <ddi.h> 50 #include <errno.h> 51 #include <inttypes.h> 44 52 #include <ipc/irc.h> 45 #include <loc.h>46 #include <as.h>47 #include <ddi.h>48 #include <align.h>49 #include <inttypes.h>50 53 #include <stdbool.h> 51 #include <errno.h>52 #include <async.h>53 #include <align.h>54 #include <async.h>55 54 #include <stdio.h> 55 56 #include "obio.h" 56 57 57 58 #define NAME "obio" … … 67 68 #define INO_MASK 0x1f 68 69 69 static uintptr_t base_phys;70 static volatile uint64_t *base_virt = (volatile uint64_t *) AS_AREA_ANY;71 72 70 /** Handle one connection to obio. 73 71 * … … 80 78 ipc_callid_t callid; 81 79 ipc_call_t call; 80 obio_t *obio; 82 81 83 82 /* … … 86 85 async_answer_0(iid, EOK); 87 86 87 obio = (obio_t *)ddf_dev_data_get(ddf_fun_get_dev((ddf_fun_t *)arg)); 88 88 89 while (1) { 89 90 int inr; 90 91 91 92 callid = async_get_call(&call); 92 93 switch (IPC_GET_IMETHOD(call)) { 93 94 case IRC_ENABLE_INTERRUPT: 94 95 inr = IPC_GET_ARG1(call); 95 base_virt[OBIO_IMR(inr & INO_MASK)] |= (1UL << 31);96 ((volatile uint64_t *)(obio->regs))[OBIO_IMR(inr & INO_MASK)] |= (1UL << 31); 96 97 async_answer_0(callid, EOK); 97 98 break; … … 102 103 case IRC_CLEAR_INTERRUPT: 103 104 inr = IPC_GET_ARG1(call); 104 base_virt[OBIO_CIR(inr & INO_MASK)] = 0;105 ((volatile uint64_t *)(obio->regs))[OBIO_CIR(inr & INO_MASK)] = 0; 105 106 async_answer_0(callid, EOK); 106 107 break; … … 112 113 } 113 114 114 /** Initialize the OBIO driver. 115 * 116 * In the future, the OBIO driver should be integrated with the sun4u platform driver. 117 */ 118 static bool obio_init(void) 115 /** Add OBIO device. */ 116 int obio_add(obio_t *obio, obio_res_t *res) 119 117 { 120 category_id_t irc_cat; 121 service_id_t svc_id; 118 ddf_fun_t *fun_a = NULL; 119 int flags; 120 int retval; 122 121 int rc; 123 124 base_phys = (uintptr_t) 0x1fe00000000ULL; 125 126 int flags = AS_AREA_READ | AS_AREA_WRITE; 127 int retval = physmem_map(base_phys, 122 123 flags = AS_AREA_READ | AS_AREA_WRITE; 124 obio->regs = (volatile uint64_t *)AS_AREA_ANY; 125 retval = physmem_map(res->base, 128 126 ALIGN_UP(OBIO_SIZE, PAGE_SIZE) >> PAGE_WIDTH, flags, 129 (void *) & base_virt);130 127 (void *) &obio->regs); 128 131 129 if (retval < 0) { 132 printf("%s: Error mapping OBIO registers\n", NAME); 133 return false; 130 ddf_msg(LVL_ERROR, "Error mapping OBIO registers"); 131 rc = EIO; 132 goto error; 134 133 } 135 136 printf("%s: OBIO registers with base at 0x%" PRIun "\n", NAME, base_phys); 137 138 async_set_fallback_port_handler(obio_connection, NULL); 139 140 rc = loc_server_register(NAME); 134 135 ddf_msg(LVL_NOTE, "OBIO registers with base at 0x%" PRIun, res->base); 136 137 fun_a = ddf_fun_create(obio->dev, fun_exposed, "a"); 138 if (fun_a == NULL) { 139 ddf_msg(LVL_ERROR, "Failed creating function 'a'."); 140 rc = ENOMEM; 141 goto error; 142 } 143 144 ddf_fun_set_conn_handler(fun_a, obio_connection); 145 146 rc = ddf_fun_bind(fun_a); 141 147 if (rc != EOK) { 142 printf("%s: Failed registering server. (%d)\n", NAME, rc);143 return false;148 ddf_msg(LVL_ERROR, "Failed binding function 'a'. (%d)", rc); 149 goto error; 144 150 } 145 146 rc = loc_service_register("irc/" NAME, &svc_id); 147 if (rc != EOK) { 148 printf("%s: Failed registering service. (%d)\n", NAME, rc); 149 return false; 150 } 151 152 rc = loc_category_get_id("irc", &irc_cat, IPC_FLAG_BLOCKING); 153 if (rc != EOK) { 154 printf("%s: Failed resolving category 'iplink' (%d).\n", NAME, 155 rc); 156 return false; 157 } 158 159 rc = loc_service_add_to_cat(svc_id, irc_cat); 160 if (rc != EOK) { 161 printf("%s: Failed adding service to category (%d).\n", NAME, 162 rc); 163 return false; 164 } 165 166 return true; 151 152 rc = ddf_fun_add_to_category(fun_a, "irc"); 153 if (rc != EOK) 154 goto error; 155 156 return EOK; 157 error: 158 if (fun_a != NULL) 159 ddf_fun_destroy(fun_a); 160 return rc; 167 161 } 168 162 169 int main(int argc, char **argv) 163 /** Remove OBIO device */ 164 int obio_remove(obio_t *obio) 170 165 { 171 printf("%s: HelenOS OBIO driver\n", NAME); 172 173 if (!obio_init()) 174 return -1; 175 176 printf("%s: Accepting connections\n", NAME); 177 task_retval(0); 178 async_manager(); 179 180 /* Never reached */ 181 return 0; 166 return ENOTSUP; 182 167 } 168 169 /** OBIO device gone */ 170 int obio_gone(obio_t *obio) 171 { 172 return ENOTSUP; 173 } 174 183 175 184 176 /** -
uspace/drv/platform/sun4u/sun4u.c
reca820c rf834dd81 68 68 #define PBM_PCI_MEM_SIZE UINT64_C(0x00100000000) 69 69 70 #define PBM_OBIO_BASE UINT64_C(0) 71 #define PBM_OBIO_SIZE UINT64_C(0x1898) 72 73 70 74 typedef struct sun4u_fun { 71 75 hw_resource_list_t hw_resources; … … 85 89 .name = NAME, 86 90 .driver_ops = &sun4u_ops 91 }; 92 93 static hw_resource_t obio_res[] = { 94 { 95 .type = MEM_RANGE, 96 .res.mem_range = { 97 .address = PBM_BASE + PBM_OBIO_BASE, 98 .size = PBM_OBIO_SIZE, 99 .relative = false, 100 .endianness = LITTLE_ENDIAN 101 } 102 } 103 }; 104 105 static sun4u_fun_t obio_data = { 106 .hw_resources = { 107 .count = sizeof(obio_res) / sizeof(obio_res[0]), 108 .resources = obio_res 109 }, 110 .pio_window = { 111 .mem = { 112 .base = PBM_BASE + PBM_OBIO_BASE, 113 .size = PBM_OBIO_SIZE 114 } 115 } 87 116 }; 88 117 … … 201 230 static bool sun4u_add_functions(ddf_dev_t *dev) 202 231 { 232 if (!sun4u_add_fun(dev, "obio", "ebus/obio", &obio_data)) 233 return false; 234 203 235 return sun4u_add_fun(dev, "pci0", "intel_pci", &pci_data); 204 236 }
Note:
See TracChangeset
for help on using the changeset viewer.