harmony 鸿蒙Dying Gasp

  • 2022-08-09
  • 浏览 (647)

Dying Gasp

When to Use

For a device without a serial port, the dying gasp saves the exception information to a non-volatile storage medium to facilitate fault location during system running.

Available APIs

The system provides a mechanism to save printed exception information to a non-volatile storage medium. You can register the hook function of the information printed when the read and write operations are abnormal. In this way, fault information can be saved on different storage media, facilitating fault locating for devices without serial ports. The API is LOS_ExcInfoRegHook. This function is declared in los_config.h. The function prototype is as follows:

typedef VOID (*log_read_write_fn)(UINT32 startAddr, UINT32 space, UINT32 rwFlag, CHAR *buf);
...
VOID LOS_ExcInfoRegHook(UINT32 startAddr, UINT32 space, CHAR *buf, log_read_write_fn hook);

Parameters

Table 1 LOS_ExcInfoRegHook parameter description

Parameter

Description

startAddr

Start address of the physical medium to be got or set

space

Size of the space

buf

Memory buffer used to get or set the exception information

log_read_write_fn

Function used to get or set the exception information

Table 2 log_read_write_fn parameter description

Parameter

Description

startAddr

Start address of the physical medium to be got or set

space

Size of the space

rwFlag

Read/Write flag. The value 0 indicates write, and the value 1 indicates read.

buf

Memory buffer used to get or set the exception information

How to Develop

The dying gasp function depends on the macro LOSCFG_SAVE_EXCINFO. Before using this function, choose Debug-> Enable Saving Exception Information in the configuration items to enable this macro. If this macro is disabled, this function cannot be used. Then, call LOS_ExcInfoRegHook in SystemInit to register the position, size, memory buffer, and access function for accessing the exception information. When an exception occurs in the system, the system saves the exception information in the memory buffer passed in the registration, and then calls the registered access function to write the exception information to the physical storage medium.

NOTE: - The location registered to store the exception information cannot overlap with other storage locations. - The registered memory buffer should be greater than or equal to 16 KiB. Otherwise, the exception information stored may be incomplete. - The exception information can be accessed successfully only when the driver of the storage medium corresponding to the registered read/write function is normal.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Kernel

harmony 鸿蒙Kernel Coding Specification

harmony 鸿蒙Standard Libraries

harmony 鸿蒙Interrupt Management

harmony 鸿蒙Event

harmony 鸿蒙Mutex

harmony 鸿蒙Queue

harmony 鸿蒙Semaphore

harmony 鸿蒙Doubly Linked List

harmony 鸿蒙Memory Management

0  赞