acpi_timer.c (5331d61da47e57f58c085bdf2b15147d8c017a90) | acpi_timer.c (6af444b1184d080c1b2540add2046e0c4c2775e7) |
---|---|
1/*- 2 * Copyright (c) 2000, 2001 Michael Smith 3 * Copyright (c) 2000 BSDi 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 116 unchanged lines hidden (view full) --- 125 return_VOID; 126 127 if ((dev = BUS_ADD_CHILD(parent, 0, "acpi_timer", 0)) == NULL) { 128 device_printf(parent, "could not add acpi_timer0\n"); 129 return_VOID; 130 } 131 acpi_timer_dev = dev; 132 | 1/*- 2 * Copyright (c) 2000, 2001 Michael Smith 3 * Copyright (c) 2000 BSDi 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 116 unchanged lines hidden (view full) --- 125 return_VOID; 126 127 if ((dev = BUS_ADD_CHILD(parent, 0, "acpi_timer", 0)) == NULL) { 128 device_printf(parent, "could not add acpi_timer0\n"); 129 return_VOID; 130 } 131 acpi_timer_dev = dev; 132 |
133 switch (AcpiGbl_FADT.XPmTimerBlock.SpaceId) { 134 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 135 rtype = SYS_RES_MEMORY; 136 break; 137 case ACPI_ADR_SPACE_SYSTEM_IO: 138 rtype = SYS_RES_IOPORT; 139 break; 140 default: 141 return_VOID; 142 } |
|
133 rid = 0; | 143 rid = 0; |
134 rtype = AcpiGbl_FADT.XPmTimerBlock.SpaceId ? 135 SYS_RES_IOPORT : SYS_RES_MEMORY; | |
136 rlen = AcpiGbl_FADT.PmTimerLength; 137 rstart = AcpiGbl_FADT.XPmTimerBlock.Address; 138 if (bus_set_resource(dev, rtype, rid, rstart, rlen)) 139 device_printf(dev, "couldn't set resource (%s 0x%lx+0x%lx)\n", 140 (rtype == SYS_RES_IOPORT) ? "port" : "mem", rstart, rlen); 141 return_VOID; 142} 143 144static int 145acpi_timer_probe(device_t dev) 146{ 147 char desc[40]; 148 int i, j, rid, rtype; 149 150 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 151 152 if (dev != acpi_timer_dev) 153 return (ENXIO); 154 | 144 rlen = AcpiGbl_FADT.PmTimerLength; 145 rstart = AcpiGbl_FADT.XPmTimerBlock.Address; 146 if (bus_set_resource(dev, rtype, rid, rstart, rlen)) 147 device_printf(dev, "couldn't set resource (%s 0x%lx+0x%lx)\n", 148 (rtype == SYS_RES_IOPORT) ? "port" : "mem", rstart, rlen); 149 return_VOID; 150} 151 152static int 153acpi_timer_probe(device_t dev) 154{ 155 char desc[40]; 156 int i, j, rid, rtype; 157 158 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 159 160 if (dev != acpi_timer_dev) 161 return (ENXIO); 162 |
163 switch (AcpiGbl_FADT.XPmTimerBlock.SpaceId) { 164 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 165 rtype = SYS_RES_MEMORY; 166 break; 167 case ACPI_ADR_SPACE_SYSTEM_IO: 168 rtype = SYS_RES_IOPORT; 169 break; 170 default: 171 return (ENXIO); 172 } |
|
155 rid = 0; | 173 rid = 0; |
156 rtype = AcpiGbl_FADT.XPmTimerBlock.SpaceId ? 157 SYS_RES_IOPORT : SYS_RES_MEMORY; | |
158 acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE); 159 if (acpi_timer_reg == NULL) { 160 device_printf(dev, "couldn't allocate resource (%s 0x%lx)\n", 161 (rtype == SYS_RES_IOPORT) ? "port" : "mem", 162 (u_long)AcpiGbl_FADT.XPmTimerBlock.Address); 163 return (ENXIO); 164 } 165 acpi_timer_bsh = rman_get_bushandle(acpi_timer_reg); --- 24 unchanged lines hidden (view full) --- 190 acpi_timer_timecounter.tc_quality = 1000; 191 } else { 192 acpi_timer_timecounter.tc_name = "ACPI-safe"; 193 acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount_safe; 194 acpi_timer_timecounter.tc_quality = 850; 195 } 196 tc_init(&acpi_timer_timecounter); 197 | 174 acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE); 175 if (acpi_timer_reg == NULL) { 176 device_printf(dev, "couldn't allocate resource (%s 0x%lx)\n", 177 (rtype == SYS_RES_IOPORT) ? "port" : "mem", 178 (u_long)AcpiGbl_FADT.XPmTimerBlock.Address); 179 return (ENXIO); 180 } 181 acpi_timer_bsh = rman_get_bushandle(acpi_timer_reg); --- 24 unchanged lines hidden (view full) --- 206 acpi_timer_timecounter.tc_quality = 1000; 207 } else { 208 acpi_timer_timecounter.tc_name = "ACPI-safe"; 209 acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount_safe; 210 acpi_timer_timecounter.tc_quality = 850; 211 } 212 tc_init(&acpi_timer_timecounter); 213 |
198 sprintf(desc, "%d-bit timer at 3.579545MHz", 199 (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) ? 32 : 24); | 214 sprintf(desc, "%d-bit timer at %u.%06uMHz", 215 (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) != 0 ? 32 : 24, 216 acpi_timer_frequency / 1000000, acpi_timer_frequency % 1000000); |
200 device_set_desc_copy(dev, desc); 201 202 /* Release the resource, we'll allocate it again during attach. */ 203 bus_release_resource(dev, rtype, rid, acpi_timer_reg); 204 return (0); 205} 206 207static int 208acpi_timer_attach(device_t dev) 209{ 210 int rid, rtype; 211 212 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 213 | 217 device_set_desc_copy(dev, desc); 218 219 /* Release the resource, we'll allocate it again during attach. */ 220 bus_release_resource(dev, rtype, rid, acpi_timer_reg); 221 return (0); 222} 223 224static int 225acpi_timer_attach(device_t dev) 226{ 227 int rid, rtype; 228 229 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 230 |
231 switch (AcpiGbl_FADT.XPmTimerBlock.SpaceId) { 232 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 233 rtype = SYS_RES_MEMORY; 234 break; 235 case ACPI_ADR_SPACE_SYSTEM_IO: 236 rtype = SYS_RES_IOPORT; 237 break; 238 default: 239 return (ENXIO); 240 } |
|
214 rid = 0; | 241 rid = 0; |
215 rtype = AcpiGbl_FADT.XPmTimerBlock.SpaceId ? 216 SYS_RES_IOPORT : SYS_RES_MEMORY; | |
217 acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE); 218 if (acpi_timer_reg == NULL) 219 return (ENXIO); 220 acpi_timer_bsh = rman_get_bushandle(acpi_timer_reg); 221 acpi_timer_bst = rman_get_bustag(acpi_timer_reg); 222 return (0); 223} 224 --- 152 unchanged lines hidden --- | 242 acpi_timer_reg = bus_alloc_resource_any(dev, rtype, &rid, RF_ACTIVE); 243 if (acpi_timer_reg == NULL) 244 return (ENXIO); 245 acpi_timer_bsh = rman_get_bushandle(acpi_timer_reg); 246 acpi_timer_bst = rman_get_bustag(acpi_timer_reg); 247 return (0); 248} 249 --- 152 unchanged lines hidden --- |