Beispiel #1
0
void
platform_probe_and_attach(void)
{
	platform_def_t	**platpp, *platp;
	int		prio, best_prio;

	plat_obj = &plat_kernel_obj;
	best_prio = 0;

	/*
	 * We are unable to use TUNABLE_STR as the read will happen
	 * well after this function has returned.
	 */
	TUNABLE_STR_FETCH("hw.platform", plat_name, sizeof(plat_name));

	/*
	 * Try to locate the best platform kobj
	 */
	SET_FOREACH(platpp, platform_set) {
		platp = *platpp;

		/*
		 * Take care of compiling the selected class, and
		 * then statically initialise the MMU object
		 */
		kobj_class_compile_static((kobj_class_t)platp,
		    &plat_kernel_kops);
		kobj_init_static((kobj_t)plat_obj, (kobj_class_t)platp);

		plat_obj->cls = platp;

		prio = PLATFORM_PROBE(plat_obj);

		/* Check for errors */
		if (prio > 0)
			continue;

		/*
		 * Check if this module was specifically requested through
		 * the loader tunable we provide.
		 */
		if (strcmp(platp->name,plat_name) == 0) {
			plat_def_impl = platp;
			break;
		}

		/* Otherwise, see if it is better than our current best */
		if (plat_def_impl == NULL || prio > best_prio) {
			best_prio = prio;
			plat_def_impl = platp;
		}

		/*
		 * We can't free the KOBJ, since it is static. Reset the ops
		 * member of this class so that we can come back later.
		 */
		platp->ops = NULL;
	}
Beispiel #2
0
/*
 * Routines used in machine-dependent code
 */
void
pmap_bootstrap(vm_offset_t start, vm_offset_t end)
{
	mmu_obj = &mmu_kernel_obj;

	/*
	 * Take care of compiling the selected class, and
	 * then statically initialise the MMU object
	 */
	kobj_class_compile_static(mmu_def_impl, &mmu_kernel_kops);
	kobj_init_static((kobj_t)mmu_obj, mmu_def_impl);

	MMU_BOOTSTRAP(mmu_obj, start, end);
}
Beispiel #3
0
/**
 * Perform static initialization of aa device enumeration table parser using
 * the provided bus space tag and handle.
 * 
 * This may be used to initialize a caller-allocated erom instance state
 * during early boot, prior to malloc availability.
 * 
 * @param cls		The parser class for which an instance will be
 *			allocated.
 * @param erom		The erom parser instance to initialize.
 * @param esize		The total available number of bytes allocated for
 *			@p erom. If this is less than is required by @p cls,
 *			ENOMEM will be returned.
 * @param cid		The device's chip identifier.
 * @param bst		Bus space tag.
 * @param bsh		Bus space handle mapping the device enumeration
 *			space.
 *
 * @retval 0		success
 * @retval ENOMEM	if @p esize is smaller than required by @p cls.
 * @retval non-zero	if an error occurs initializing the EROM parser,
 *			a regular unix error code will be returned.
 */
int
bhnd_erom_init_static(bhnd_erom_class_t *cls, bhnd_erom_t *erom, size_t esize,
    const struct bhnd_chipid *cid, bus_space_tag_t bst, bus_space_handle_t bsh)
{
	kobj_class_t	kcls;

	kcls = (kobj_class_t)cls;

	/* Verify allocation size */
	if (kcls->size > esize)
		return (ENOMEM);

	/* Perform instance initialization */
	kobj_init_static((kobj_t)erom, kcls);
	return (BHND_EROM_INIT_STATIC(erom, cid, bst, bsh)); 
}