|
289 | 289 | //! These functions are weakly defined in the `riscv-rt` crate, but they can be redefined
|
290 | 290 | //! in the user code. Next, we will describe these symbols and how to redefine them.
|
291 | 291 | //!
|
| 292 | +//! ## `abort` |
| 293 | +//! |
| 294 | +//! This function is called when an unrecoverable error occurs. For example, if the |
| 295 | +//! current hart id is greater than `_max_hart_id`, the `abort` function is called. |
| 296 | +//! This function is also called when an exception or an interrupt occurs and there is no |
| 297 | +//! handler for it. |
| 298 | +//! |
| 299 | +//! If this function is not defined, the linker will use the `_default_abort` function |
| 300 | +//! defined in the `riscv-rt` crate. This function is a busy-loop that will never return. |
| 301 | +//! |
| 302 | +//! ### Note |
| 303 | +//! |
| 304 | +//! Recall that the `abort` function is called when an unrecoverable error occurs. |
| 305 | +//! This function should not be used to handle recoverable errors. Additionally, it may |
| 306 | +//! be triggered before the `.bss` and `.data` sections are initialized, so it is not safe |
| 307 | +//! to use any global variable in this function. |
| 308 | +//! |
292 | 309 | //! ## `_pre_init_trap`
|
293 | 310 | //!
|
294 | 311 | //! This function is set as a provisional trap handler for the early trap handling.
|
295 | 312 | //! If either an exception or an interrupt occurs during the boot process, this
|
296 |
| -//! function is triggered. The default implementation of this function is a busy-loop. |
| 313 | +//! function is triggered. |
| 314 | +//! |
| 315 | +//! If this function is not defined, the linker will use the `_default_abort` function |
| 316 | +//! defined in the `riscv-rt` crate. This function is a busy-loop that will never return. |
297 | 317 | //!
|
298 | 318 | //! ### Note
|
299 | 319 | //!
|
|
302 | 322 | //! Recall that this trap is triggered before the `.bss` and `.data` sections are
|
303 | 323 | //! initialized, so it is not safe to use any global variables in this function.
|
304 | 324 | //!
|
| 325 | +//! Furthermore, as this function is expected to behave like a trap handler, it is |
| 326 | +//! necessary to make it be 4-byte aligned. |
| 327 | +//! |
305 | 328 | //! ## `_mp_hook`
|
306 | 329 | //!
|
307 | 330 | //! This function is called from all the harts and must return true only for one hart,
|
|
362 | 385 | //!
|
363 | 386 | //! If exception handler is not explicitly defined, `ExceptionHandler` is called.
|
364 | 387 | //!
|
365 |
| -//! ### `ExceptionHandler` |
| 388 | +//! ## `ExceptionHandler` |
366 | 389 | //!
|
367 | 390 | //! This function is called when exception without defined exception handler is occured.
|
368 |
| -//! The exception reason can be decoded from the |
369 |
| -//! `mcause`/`scause` register. |
| 391 | +//! The exception reason can be decoded from the `mcause`/`scause` register. |
370 | 392 | //!
|
371 | 393 | //! This function can be redefined in the following way:
|
372 | 394 | //!
|
|
384 | 406 | //! }
|
385 | 407 | //! ```
|
386 | 408 | //!
|
387 |
| -//! Default implementation of this function stucks in a busy-loop. |
| 409 | +//! If `ExceptionHandler` is not defined, the linker will use the `abort` function instead. |
388 | 410 | //!
|
389 | 411 | //! ## Core interrupt handlers
|
390 | 412 | //!
|
|
427 | 449 | //!
|
428 | 450 | //! If interrupt handler is not explicitly defined, `DefaultHandler` is called.
|
429 | 451 | //!
|
430 |
| -//! ### `DefaultHandler` |
| 452 | +//! ## `DefaultHandler` |
431 | 453 | //!
|
432 | 454 | //! This function is called when interrupt without defined interrupt handler is occured.
|
433 | 455 | //! The interrupt reason can be decoded from the `mcause`/`scause` register.
|
|
450 | 472 | //! }
|
451 | 473 | //! ```
|
452 | 474 | //!
|
453 |
| -//! Default implementation of this function stucks in a busy-loop. |
| 475 | +//! If `DefaultHandler` is not defined, the linker will use the `abort` function instead. |
454 | 476 | //!
|
455 | 477 | //! # Cargo Features
|
456 | 478 | //!
|
|
0 commit comments