예제 #1
1
static char *
use_hwinfo(struct chip_loc *chip) {
	char				*name;
	hwi_tag				*dev_tag;
	hwi_tag				*tag;
	unsigned			off;
	unsigned			loc;
	struct asinfo_entry	*as;

	off = HWI_NULL_OFF;
	for( ;; ) {
		off = hwi_find_tag(off, 0, HWI_TAG_NAME_device);
		if(off == HWI_NULL_OFF) return(NULL);
		dev_tag = hwi_off2tag(off);
		if(dev_tag->item.owner == HWI_NULL_OFF) continue;
		tag = hwi_off2tag(dev_tag->item.owner);
		if(strcmp(__hwi_find_string(tag->item.itemname), HWI_ITEM_DEVCLASS_RTC) == 0) break;
		/* for the new hwinfo structure */
		if(dev_tag->device.pnpid == hwi_devclass_RTC) break;
	}
	tag = hwi_off2tag(off);
	name = __hwi_find_string(tag->item.itemname);
	loc = hwi_find_tag(off, 1, HWI_TAG_NAME_location);
	if(loc != HWI_NULL_OFF) {
		tag = hwi_off2tag(loc);
		chip->phys = tag->location.base;
		chip->reg_shift = tag->location.regshift;
		if(tag->location.addrspace == 0xffff) {
			fprintf(stderr, "\nWrong address space for RTC.\n");
			return NULL;
		}
		as = &SYSPAGE_ENTRY(asinfo)[tag->location.addrspace/sizeof(*as)];
		chip->access_type = (strcmp(__hwi_find_string(as->name), "memory") == 0);
	}
	off = hwi_find_tag(off, 1, HWI_TAG_NAME_regname);
	if(off != HWI_NULL_OFF) {
		tag = hwi_off2tag(off);
		chip->century_reg = tag->regname.offset;
	}
	return(name);
}
예제 #2
0
static int
match_name(struct asinfo_entry *base, struct asinfo_entry *as, const char *name) {
	for( ;; ) {
		if(strcmp(__hwi_find_string(as->name), name) == 0) return(1);
		if(as->owner == AS_NULL_OFF) return(0);
		as = ((struct asinfo_entry *)((uint8_t *)base + as->owner));
	}
}