| 85 | } |
| 86 | |
| 87 | void |
| 88 | platform_probe_and_attach(void) |
| 89 | { |
| 90 | platform_def_t **platpp, *platp; |
| 91 | int prio, best_prio; |
| 92 | |
| 93 | plat_obj = &plat_kernel_obj; |
| 94 | best_prio = 0; |
| 95 | |
| 96 | /* |
| 97 | * We are unable to use TUNABLE_STR as the read will happen |
| 98 | * well after this function has returned. |
| 99 | */ |
| 100 | TUNABLE_STR_FETCH("hw.platform", plat_name, sizeof(plat_name)); |
| 101 | |
| 102 | /* |
| 103 | * Try to locate the best platform kobj |
| 104 | */ |
| 105 | SET_FOREACH(platpp, platform_set) { |
| 106 | platp = *platpp; |
| 107 | |
| 108 | /* |
| 109 | * Take care of compiling the selected class, and |
| 110 | * then statically initialise the MMU object |
| 111 | */ |
| 112 | kobj_class_compile_static((kobj_class_t)platp, |
| 113 | &plat_kernel_kops); |
| 114 | kobj_init_static((kobj_t)plat_obj, (kobj_class_t)platp); |
| 115 | |
| 116 | plat_obj->cls = platp; |
| 117 | |
| 118 | prio = PLATFORM_PROBE(plat_obj); |
| 119 | |
| 120 | /* Check for errors */ |
| 121 | if (prio > 0) |
| 122 | continue; |
| 123 | |
| 124 | /* |
| 125 | * Check if this module was specifically requested through |
| 126 | * the loader tunable we provide. |
| 127 | */ |
| 128 | if (strcmp(platp->name,plat_name) == 0) { |
| 129 | plat_def_impl = platp; |
| 130 | break; |
| 131 | } |
| 132 | |
| 133 | /* Otherwise, see if it is better than our current best */ |
| 134 | if (plat_def_impl == NULL || prio > best_prio) { |
| 135 | best_prio = prio; |
| 136 | plat_def_impl = platp; |
| 137 | } |
| 138 | |
| 139 | /* |
| 140 | * We can't free the KOBJ, since it is static. Reset the ops |
| 141 | * member of this class so that we can come back later. |
| 142 | */ |
| 143 | platp->ops = NULL; |
| 144 | } |
no test coverage detected