名称
wait_for_bootstrap - bootstrap が完了するまで待つ
書式
int
wait_for_bootstrap(
uint8_t * mmio_va);
引数
- mmio_va
- bootstrapの完了を待つカードの MMIO の仮想アドレス
説明
引数 mmio_va で指定されたカードの bootstrap が完了するのを最大 60 秒待つ。
bootstrap が完了したかどうかは、
SBOX_SCRATCH2 レジスタの download_status ビットで判断する。
bootstrap が完了している場合、または、待ち時間が 60 秒以上になった場合は、処理を終える。
bootstrap がまだ完了しておらず、かつ、待ち時間が 60 秒に達していない場合は、100 ミリ秒待ってから判断をやり直す。
戻り値
成功した場合 0 を返す。そうでない場合、0 以外の値を返す。
- 0
- bootstrapが既に完了していた場合。
- bootstrapが完了した場合。
- -EIO
- 約60秒待ってもbootstrapが完了しなかった場合。
参照
実装
162 /*
163 DESCRIPTION:: waits for bootstrap loader is finished
164 PARAMETERS::
165 [in]void *mmio_va - virtual address to access MMIO registers
166 RETURN_VALUE:: 0 if successful, non-zero if failure
167 */
168 int
169 wait_for_bootstrap(uint8_t *mmio_va)
170 {
171 uint32_t scratch2 = 0;
172 int count = 0;
173 #ifdef MIC_IS_EMULATION
175 #endif
176
177 // Wait until the boot loader is finished
178 while (!SCRATCH2_DOWNLOAD_STATUS(scratch2)) {
179 msleep(100);
180 if (count == 600) {
181 #ifndef MIC_IS_EMULATION
182 printk("Firmware is not responding with ready bit\n");
183 return -EIO;
184 #else
188 #endif
189 }
190
191 count++;
192 scratch2 = SBOX_READ(mmio_va, SBOX_SCRATCH2);
193 }
194
195 return 0;
196 }
- 180行目のif文でループを抜けるときでも、179行目で無駄にmsleepしている。192行目の直前でmsleepするのが好み。
最終更新:2012年11月10日 23:19