bus_space_handle_t ch, dh;
u_int cbase, clen, l; bus_space_handle_t ch16, ch32, dh;
apmattach(parent, self, aux)	struct device *parent, *self;	void *aux;{	extern union descriptor *dynamic_gdt;	struct bios_attach_args *ba = aux;	bios_apminfo_t *ap = ba->bios_apmp;	struct apm_softc *sc = (void *)self;	struct apmregs regs;	bus_space_handle_t ch, dh;	/*	 * set up GDT descriptors for APM	 */	if (ap->apm_detail & APM_32BIT_SUPPORTED) {		apm_flags = ap->apm_detail;		apm_ep.seg = GSEL(GAPM32CODE_SEL,SEL_KPL);		apm_ep.entry = ap->apm_entry;		if ((ap->apm_code32_base <= ap->apm_data_base &&		     ap->apm_code32_base+ap->apm_code_len >= ap->apm_data_base)		  ||(ap->apm_code32_base >= ap->apm_data_base &&		     ap->apm_data_base+ap->apm_data_len>=ap->apm_code32_base)){			int l;			l = max(ap->apm_data_base + ap->apm_data_len,				ap->apm_code32_base + ap->apm_data_len) -			    min(ap->apm_data_base, ap->apm_code32_base);			bus_space_map(ba->bios_memt,				min(ap->apm_data_base, ap->apm_code32_base),				l, 1, &ch);			dh = ch;			if (ap->apm_data_base < ap->apm_code32_base)				ch += ap->apm_code32_base - ap->apm_data_base;			else				dh += ap->apm_data_base - ap->apm_code32_base;		} else {			bus_space_map(ba->bios_memt,				      ba->bios_apmp->apm_code32_base,				      ba->bios_apmp->apm_code_len, 1, &ch);			bus_space_map(ba->bios_memt,				      ba->bios_apmp->apm_data_base,				      ba->bios_apmp->apm_data_len, 1, &dh);		}		setsegment(&dynamic_gdt[GAPM32CODE_SEL].sd, (void *)ch,			   ap->apm_code_len-1, SDT_MEMERA, SEL_KPL, 1, 0);		setsegment(&dynamic_gdt[GAPM16CODE_SEL].sd, (void *)ch,			   ap->apm_code_len-1, SDT_MEMERA, SEL_KPL, 0, 0);		setsegment(&dynamic_gdt[GAPMDATA_SEL].sd, (void *)dh,			   ap->apm_data_len-1, SDT_MEMRWA, SEL_KPL, 1, 0);		DPRINTF((": flags %x code 32:%x/%x 16:%x/%x %x "		       "data %x/%x/%x ep %x (%x:%x)\n%s", apm_flags,		    ap->apm_code32_base, ch, ap->apm_code16_base, ch,		    ap->apm_code_len, ap->apm_data_base, dh, ap->apm_data_len,		    ap->apm_entry, apm_ep.seg, ap->apm_entry+ch,		    sc->sc_dev.dv_xname));		apm_set_ver(sc);		/*		 * Engage cooperative power mgt (we get to do it)		 * on all devices (v1.1).		 */		apm_powmgt_engage(1, APM_DEV_ALLDEVS);#if 0		/* doesn't seem to work, sigh. */		apm_powmgt_engage(1, APM_DEV_DISPLAY(APM_DEV_ALLUNITS));		apm_powmgt_engage(1, APM_DEV_DISK(APM_DEV_ALLUNITS));		apm_powmgt_engage(1, APM_DEV_PARALLEL(APM_DEV_ALLUNITS));		apm_powmgt_engage(1, APM_DEV_NETWORK(APM_DEV_ALLUNITS));		apm_powmgt_engage(1, APM_DEV_PCMCIA(APM_DEV_ALLUNITS));#endif				if (apm_get_powstat(regs) == 0) {			apm_power_print(sc, &regs);		} else			apm_perror("get power status", &regs);		apm_cpu_busy();		apm_periodic_check(sc);	} else {		dynamic_gdt[GAPM32CODE_SEL] = dynamic_gdt[GNULL_SEL];		dynamic_gdt[GAPM16CODE_SEL] = dynamic_gdt[GNULL_SEL];		dynamic_gdt[GAPMDATA_SEL] = dynamic_gdt[GNULL_SEL];	}}