MCPcopy Create free account
hub / github.com/F-Stack/f-stack / orm_identify

Function orm_identify

freebsd/x86/isa/orm.c:83–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83static void
84orm_identify(driver_t* driver, device_t parent)
85{
86 bus_space_handle_t bh;
87 bus_space_tag_t bt;
88 device_t child;
89 u_int32_t chunk = IOMEM_START;
90 struct resource *res;
91 int rid;
92 u_int32_t rom_size;
93 struct orm_softc *sc;
94 u_int8_t buf[3];
95
96 if (resource_disabled("orm", 0))
97 return;
98
99 child = BUS_ADD_CHILD(parent, ISA_ORDER_SENSITIVE, "orm", -1);
100 device_set_driver(child, driver);
101 isa_set_logicalid(child, ORM_ID);
102 isa_set_vendorid(child, ORM_ID);
103 sc = device_get_softc(child);
104 sc->rnum = 0;
105 while (sc->rnum < MAX_ROMS && chunk < IOMEM_END) {
106 bus_set_resource(child, SYS_RES_MEMORY, sc->rnum, chunk,
107 IOMEM_STEP);
108 rid = sc->rnum;
109 res = bus_alloc_resource_any(child, SYS_RES_MEMORY, &rid,
110 RF_ACTIVE);
111 if (res == NULL) {
112 bus_delete_resource(child, SYS_RES_MEMORY, sc->rnum);
113 chunk += IOMEM_STEP;
114 continue;
115 }
116 bt = rman_get_bustag(res);
117 bh = rman_get_bushandle(res);
118 bus_space_read_region_1(bt, bh, 0, buf, sizeof(buf));
119
120 /*
121 * We need to release and delete the resource since we're
122 * changing its size, or the rom isn't there. There
123 * is a checksum field in the ROM to prevent false
124 * positives. However, some common hardware (IBM thinkpads)
125 * neglects to put a valid checksum in the ROM, so we do
126 * not double check the checksum here. On the ISA bus
127 * areas that have no hardware read back as 0xff, so the
128 * tests to see if we have 0x55 followed by 0xaa are
129 * generally sufficient.
130 */
131 bus_release_resource(child, SYS_RES_MEMORY, rid, res);
132 bus_delete_resource(child, SYS_RES_MEMORY, sc->rnum);
133 if (buf[0] != 0x55 || buf[1] != 0xAA || (buf[2] & 0x03) != 0) {
134 chunk += IOMEM_STEP;
135 continue;
136 }
137 rom_size = buf[2] << 9;
138 bus_set_resource(child, SYS_RES_MEMORY, sc->rnum, chunk,
139 rom_size);
140 rid = sc->rnum;

Callers

nothing calls this directly

Calls 12

resource_disabledFunction · 0.85
device_set_driverFunction · 0.85
device_get_softcFunction · 0.85
bus_set_resourceFunction · 0.85
bus_alloc_resource_anyFunction · 0.85
bus_delete_resourceFunction · 0.85
rman_get_bustagFunction · 0.85
rman_get_bushandleFunction · 0.85
bus_space_read_region_1Function · 0.85
bus_release_resourceFunction · 0.85
device_delete_childFunction · 0.85
device_set_descFunction · 0.85

Tested by

no test coverage detected