summaryrefslogtreecommitdiff
path: root/sys/dev/ic/sti.c
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-04-16 21:03:46 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-04-16 21:03:46 +0000
commit5eaea4c893599bf5f55886960e35fad167db1145 (patch)
tree45f145e462f9caa87c2e92a5cbce0376738b58a9 /sys/dev/ic/sti.c
parent557fd68d34fa0134badbde0239bfeccc70301a61 (diff)
Introduce sti_rom_size() which will compute the size of a card's rom, and
use it instead of duplicating the same logic in 3 places. ok mickey@
Diffstat (limited to 'sys/dev/ic/sti.c')
-rw-r--r--sys/dev/ic/sti.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/sys/dev/ic/sti.c b/sys/dev/ic/sti.c
index 8fbbddccc8f..a6d00a3f0fa 100644
--- a/sys/dev/ic/sti.c
+++ b/sys/dev/ic/sti.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sti.c,v 1.42 2005/02/27 22:10:57 miod Exp $ */
+/* $OpenBSD: sti.c,v 1.43 2006/04/16 21:03:45 miod Exp $ */
/*
* Copyright (c) 2000-2003 Michael Shalayeff
@@ -481,6 +481,26 @@ sti_end_attach(void *v)
config_found(&sc->sc_dev, &waa, wsemuldisplaydevprint);
}
+u_int
+sti_rom_size(bus_space_tag_t iot, bus_space_handle_t ioh)
+{
+ int devtype;
+ u_int romend;
+
+ devtype = bus_space_read_1(iot, ioh, 3);
+ if (devtype == STI_DEVTYPE4) {
+ romend = bus_space_read_4(iot, ioh, 0x18);
+ } else {
+ romend =
+ (bus_space_read_1(iot, ioh, 0x50 + 3) << 24) |
+ (bus_space_read_1(iot, ioh, 0x50 + 7) << 16) |
+ (bus_space_read_1(iot, ioh, 0x50 + 11) << 8) |
+ (bus_space_read_1(iot, ioh, 0x50 + 15));
+ }
+
+ return (round_page(romend));
+}
+
int
sti_fetchfonts(struct sti_screen *scr, struct sti_inqconfout *cfg,
u_int32_t addr)
@@ -1023,8 +1043,7 @@ sti_cnattach(struct sti_screen *scr, bus_space_tag_t iot, bus_addr_t base,
u_int codebase)
{
bus_space_handle_t ioh;
- int devtype;
- u_int32_t romend;
+ u_int romend;
int error;
long defattr;
@@ -1034,20 +1053,10 @@ sti_cnattach(struct sti_screen *scr, bus_space_tag_t iot, bus_addr_t base,
/*
* Compute real PROM size
*/
- devtype = bus_space_read_1(iot, ioh, 3);
- if (devtype == STI_DEVTYPE4) {
- romend = bus_space_read_4(iot, ioh, 0x18);
- } else {
- romend =
- (bus_space_read_1(iot, ioh, 0x50 + 3) << 24) |
- (bus_space_read_1(iot, ioh, 0x50 + 7) << 16) |
- (bus_space_read_1(iot, ioh, 0x50 + 11) << 8) |
- (bus_space_read_1(iot, ioh, 0x50 + 15));
- }
+ romend = sti_rom_size(iot, ioh);
bus_space_unmap(iot, ioh, PAGE_SIZE);
- romend = round_page(romend);
if ((error = bus_space_map(iot, base, romend, 0, &ioh)) != 0)
return (error);