View | Details | Raw Unified | Return to bug 22078
Collapse All | Expand All

(-)src/sys/isa/isa_common.c (+92 lines)
Lines 1047-1049 Link Here
1047
DRIVER_MODULE(isa, nexus, isa_driver, isa_devclass, 0, 0);
1047
DRIVER_MODULE(isa, nexus, isa_driver, isa_devclass, 0, 0);
1048
#endif
1048
#endif
1049
1049
1050
/*
1051
 * Pseudo driver to take care of holes in ISA iomem occupied
1052
 * by option rom(s)
1053
 */
1054
1055
#define	ORM_ID	0x00004d3e
1056
1057
static struct isa_pnp_id orm_ids[] = {
1058
	{ ORM_ID,	NULL },		/* ORM0000 */
1059
	{ 0,		NULL },
1060
};
1061
1062
static int
1063
orm_probe(device_t dev) {
1064
	return ISA_PNP_PROBE(device_get_parent(dev), dev, orm_ids);
1065
}
1066
1067
static int
1068
orm_attach(device_t dev) {
1069
	return 0;
1070
}
1071
1072
#define	IOMEM_START	0x0a0000
1073
#define	IOMEM_STEP	0x000800
1074
#define	IOMEM_END	0x100000
1075
1076
static void
1077
orm_identify(driver_t* driver, device_t parent) {
1078
	device_t	child;
1079
	u_int32_t	chunk;
1080
	int		rnum = 0;
1081
1082
	child = BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, "orm", -1);
1083
	device_set_driver(child, driver);
1084
	device_set_desc(child, "Option ROM(s)");
1085
	isa_set_logicalid(child, ORM_ID);
1086
	isa_set_vendorid(child, ORM_ID);
1087
	for (chunk = IOMEM_START; chunk < IOMEM_END; chunk += IOMEM_STEP) {
1088
		struct resource*	res;
1089
		int			rid;
1090
		bus_space_tag_t		bt;
1091
		bus_space_handle_t	bh;
1092
		u_int32_t		rom_size;
1093
		u_int8_t		buf[3];
1094
1095
		bus_set_resource(child, SYS_RES_MEMORY, rnum, chunk, IOMEM_STEP);
1096
		rid = rnum;
1097
		res = bus_alloc_resource(child, SYS_RES_MEMORY, &rid, 0ul, ~0ul, IOMEM_STEP, RF_ACTIVE);
1098
		if (res == NULL) {
1099
			bus_delete_resource(child, SYS_RES_MEMORY, rnum);
1100
			continue;
1101
		}
1102
		bt = rman_get_bustag(res);
1103
		bh = rman_get_bushandle(res);
1104
		bus_space_read_region_1(bt, bh, 0, buf, sizeof(buf));
1105
		bus_release_resource(child, SYS_RES_MEMORY, rid, res);
1106
		bus_delete_resource(child, SYS_RES_MEMORY, rnum);
1107
		if (buf[0] != 0x55 || buf[1] != 0xAA || (buf[2] & 0x03) != 0) {
1108
			continue;
1109
		}
1110
		rom_size = buf[2] << 9;
1111
		bus_set_resource(child, SYS_RES_MEMORY, rnum, chunk, rom_size);
1112
		rid = rnum;
1113
		res = bus_alloc_resource(child, SYS_RES_MEMORY, &rid, 0ul, ~0ul, rom_size, 0);
1114
		if (res == NULL) {
1115
			bus_delete_resource(child, SYS_RES_MEMORY, rnum);
1116
			continue;
1117
		}
1118
		chunk += rom_size - IOMEM_STEP;
1119
		rnum++;
1120
	}
1121
	if(rnum == 0)
1122
		device_delete_child(parent, child);
1123
}
1124
1125
static device_method_t orm_methods[] = {
1126
	/* Device interface */
1127
	DEVMETHOD(device_identify,	orm_identify),
1128
	DEVMETHOD(device_probe,		orm_probe),
1129
	DEVMETHOD(device_attach,	orm_attach),
1130
	{ 0, 0 }
1131
};
1132
1133
static driver_t orm_driver = {
1134
	"orm",
1135
	orm_methods,
1136
	0
1137
};
1138
1139
static devclass_t orm_devclass;
1140
1141
DRIVER_MODULE(orm, isa, orm_driver, orm_devclass, 0, 0);

Return to bug 22078