In the Hardware Driver Foundation \(HDF\) framework, the real-time clock \(RTC\) uses the independent service mode for API adaptation. In this mode, each device independently publishes a device service to handle external access requests. After receiving an access request from an API, the device manager extracts the parameters in the request to call the internal method of the target device. In the independent service mode, the service management capabilities of the HDFDeviceManager can be directly used. However, you need to configure a device node for each device, which increases the memory usage.
## Overview
**Figure 1** Independent service mode<aname="fig6742142611299"></a>
The real-time clock (RTC) is a real-time clock device in the operating system. In the Hardware Driver Foundation (HDF), the RTC uses the independent service mode for API adaptation. In this mode, each device independently publishes a service to process external access requests. When receiving an access request, the HDF DeviceManager extracts parameters from the request to call the internal APIs of the target device. In the independent service mode, the HDF DeviceManager provides service management capabilities. However, you need to configure a node for each device, which increases memory usage.
## Available APIs<a name="section752964871810"></a>
**Figure 1** Independent service mode

## Available APIs
**RtcMethod**:
RtcMethod
```
struct RtcMethod {
...
...
@@ -27,191 +31,53 @@ struct RtcMethod {
};
```
**Table 1** Callbacks for the members in the RtcMethod structure
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.2 "><pid="p094112118314"><aname="p094112118314"></a><aname="p094112118314"></a><strongid="b1264214345404"><aname="b1264214345404"></a><aname="b1264214345404"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
</td>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.3 "><pid="p19945219318"><aname="p19945219318"></a><aname="p19945219318"></a><strongid="b6902125819406"><aname="b6902125819406"></a><aname="b6902125819406"></a>time</strong>: structure pointer to the output time value.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.5 "><pid="p094132115317"><aname="p094132115317"></a><aname="p094132115317"></a>Reads the RTC time information.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.2 "><pid="p10306227052"><aname="p10306227052"></a><aname="p10306227052"></a><strongid="b1330617271556"><aname="b1330617271556"></a><aname="b1330617271556"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<pid="p89418214311"><aname="p89418214311"></a><aname="p89418214311"></a><strongid="b1411813377426"><aname="b1411813377426"></a><aname="b1411813377426"></a>time</strong>: structure pointer to the input time.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.5 "><pid="p5941521123118"><aname="p5941521123118"></a><aname="p5941521123118"></a>Writes the RTC time information (from milliseconds to years).</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.2 "><pid="p1362015341251"><aname="p1362015341251"></a><aname="p1362015341251"></a><strongid="b14620934553"><aname="b14620934553"></a><aname="b14620934553"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<pid="p9951721113113"><aname="p9951721113113"></a><aname="p9951721113113"></a><strongid="b477221417458"><aname="b477221417458"></a><aname="b477221417458"></a>alarmIndex</strong>: clock alarm index, which is an enumerated value.</p>
</td>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.3 "><pid="p1995921113112"><aname="p1995921113112"></a><aname="p1995921113112"></a><strongid="b0371144014414"><aname="b0371144014414"></a><aname="b0371144014414"></a>time</strong>: structure pointer to the output time.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.2 "><pid="p136914402055"><aname="p136914402055"></a><aname="p136914402055"></a><strongid="b176918401258"><aname="b176918401258"></a><aname="b176918401258"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<pid="p11512468517"><aname="p11512468517"></a><aname="p11512468517"></a><strongid="b195114613519"><aname="b195114613519"></a><aname="b195114613519"></a>alarmIndex</strong>: clock alarm index, which is an enumerated value.</p>
<pid="p595152114315"><aname="p595152114315"></a><aname="p595152114315"></a><strongid="b1892302045019"><aname="b1892302045019"></a><aname="b1892302045019"></a>time</strong>: structure pointer to the input time.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.2 "><pid="p7793145219520"><aname="p7793145219520"></a><aname="p7793145219520"></a><strongid="b37931529513"><aname="b37931529513"></a><aname="b37931529513"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<pid="p109352055359"><aname="p109352055359"></a><aname="p109352055359"></a><strongid="b393518551159"><aname="b393518551159"></a><aname="b393518551159"></a>alarmIndex</strong>: clock alarm index, which is an enumerated value.</p>
<pid="p1295182163112"><aname="p1295182163112"></a><aname="p1295182163112"></a><strongid="b11371112513"><aname="b11371112513"></a><aname="b11371112513"></a>cb</strong>: pointer to the callback.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.5 "><pid="p39602133113"><aname="p39602133113"></a><aname="p39602133113"></a>Registers <strongid="b176627580513"><aname="b176627580513"></a><aname="b176627580513"></a>RtcAlarmCallback</strong> that will be invoked when an alarm is generated at the specified time.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.2 "><pid="p796015120619"><aname="p796015120619"></a><aname="p796015120619"></a><strongid="b149601210611"><aname="b149601210611"></a><aname="b149601210611"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<pid="p174501061561"><aname="p174501061561"></a><aname="p174501061561"></a><strongid="b7450562062"><aname="b7450562062"></a><aname="b7450562062"></a>alarmIndex</strong>: clock alarm index, which is an enumerated value.</p>
<pid="p59682173112"><aname="p59682173112"></a><aname="p59682173112"></a><strongid="b6999711105518"><aname="b6999711105518"></a><aname="b6999711105518"></a>enable</strong>: specifies whether to enable the RTC alarm interrupt.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.5 "><pid="p996182112316"><aname="p996182112316"></a><aname="p996182112316"></a>Enables or disables the RTC alarm interrupt.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.2 "><pid="p16961021103119"><aname="p16961021103119"></a><aname="p16961021103119"></a><strongid="b17147182285715"><aname="b17147182285715"></a><aname="b17147182285715"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
</td>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.3 "><pid="p09620218318"><aname="p09620218318"></a><aname="p09620218318"></a><strongid="b11413184435713"><aname="b11413184435713"></a><aname="b11413184435713"></a>freq</strong>: pointer to the output frequency, which is of the uint32_t type.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.5 "><pid="p3968214311"><aname="p3968214311"></a><aname="p3968214311"></a>Reads the frequency of the external crystal oscillator connected to the RTC driver.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.2 "><pid="p38121311169"><aname="p38121311169"></a><aname="p38121311169"></a><strongid="b481218117612"><aname="b481218117612"></a><aname="b481218117612"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<pid="p79792114315"><aname="p79792114315"></a><aname="p79792114315"></a><strongid="b1220510308"><aname="b1220510308"></a><aname="b1220510308"></a>freq</strong>: input frequency, which is of the uint32_t type.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.5 "><pid="p11971621193115"><aname="p11971621193115"></a><aname="p11971621193115"></a>Sets the frequency of the external crystal oscillator connected to the RTC driver.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.2 "><pid="p169712123111"><aname="p169712123111"></a><aname="p169712123111"></a><strongid="b13129173210577"><aname="b13129173210577"></a><aname="b13129173210577"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.5 "><pid="p197112116316"><aname="p197112116316"></a><aname="p197112116316"></a>Resets the RTC.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.2 "><pid="p12704168619"><aname="p12704168619"></a><aname="p12704168619"></a><strongid="b1570171616616"><aname="b1570171616616"></a><aname="b1570171616616"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<pid="p18975210312"><aname="p18975210312"></a><aname="p18975210312"></a><strongid="b1020311128520"><aname="b1020311128520"></a><aname="b1020311128520"></a>usrDefIndex</strong>: structure defining the index of a custom register.</p>
</td>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.3 "><pid="p14975211314"><aname="p14975211314"></a><aname="p14975211314"></a><strongid="b10580501973"><aname="b10580501973"></a><aname="b10580501973"></a>value</strong>: pointer to the output register value, which is of the uint8_t type.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.5 "><pid="p1098821143115"><aname="p1098821143115"></a><aname="p1098821143115"></a>Reads the configuration of a custom RTC register based on the register index. One index corresponds to one byte of the configuration value.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.2 "><pid="p1747714196613"><aname="p1747714196613"></a><aname="p1747714196613"></a><strongid="b6477519469"><aname="b6477519469"></a><aname="b6477519469"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<pid="p1527912317612"><aname="p1527912317612"></a><aname="p1527912317612"></a><strongid="b72791123968"><aname="b72791123968"></a><aname="b72791123968"></a>usrDefIndex</strong>: structure defining the index of a custom register.</p>
<pid="p1498172173115"><aname="p1498172173115"></a><aname="p1498172173115"></a><strongid="b68893701014"><aname="b68893701014"></a><aname="b68893701014"></a>value</strong>: input register value, which is of the uint8_t type.</p>
<tdclass="cellrowborder"valign="top"width="20%"headers="mcps1.2.6.1.5 "><pid="p13981421203110"><aname="p13981421203110"></a><aname="p13981421203110"></a>Configures the RTC register based on the register index. One index corresponds to one byte of the configuration value.</p>
</td>
</tr>
</tbody>
</table>
## How to Develop<a name="section1784450860142407"></a>
**Table 1** Description of the callback functions in RtcMethod
| ReadTime | **host**: structure pointer to the RTC controller at the core layer.| **time**: structure pointer to the time read.| HDF_STATUS| Reads the RTC time.|
| WriteTime | **host**: structure pointer to the RTC controller at the core layer.<br>**time**: structure pointer to the time to write.| –| HDF_STATUS| Writes the RTC time (including the year, month, day, day of week, hour, minute, second, and millisecond).|
| ReadAlarm | **host**: structure pointer to the RTC controller at the core layer.<br>**alarmIndex**: RTC alarm index, which is an enumerated value.| **time**: structure pointer to the time read.| HDF_STATUS| Reads the RTC alarm time.|
| WriteAlarm | **host**: structure pointer to the RTC controller at the core layer.<br>**alarmIndex**: RTC alarm index, which is an enumerated value.<br>**time**: structure pointer to the time to write.| –| HDF_STATUS| Writes the RTC alarm time.|
| RegisterAlarmCallback | **host**: structure pointer to the RTC controller at the core layer.<br>**alarmIndex**: RTC alarm index, which is an enumerated value.<br>**cb**: pointer to the callback to register.| –| HDF_STATUS| Registers a callback to be invoked when an alarm is not generated at the specified time.|
| AlarmInterruptEnable | **host**: structure pointer to the RTC controller at the core layer.<br>**alarmIndex**: RTC alarm index, which is an enumerated value.<br>**enable**: whether to enable interrupts for an RTC alarm. | –| HDF_STATUS| Enables or disables interrupts for an RTC alarm.|
| GetFreq | **host**: structure pointer to the RTC controller at the core layer.| **freq**: pointer to the frequency obtained, which is of the uint32_t type.| HDF_STATUS| Obtains the frequency of the external crystal oscillator connected to the RTC driver.|
| SetFreq | **host**: structure pointer to the RTC controller at the core layer.<br>**freq**: frequency to set, which is of the uint32_t type.| –| HDF_STATUS| Sets the frequency of the external crystal oscillator connected to the RTC driver.|
| Reset | **host**: structure pointer to the RTC controller at the core layer.| –| HDF_STATUS| Resets the RTC.|
| ReadReg | **host**: structure pointer to the RTC controller at the core layer.<br>**usrDefIndex**: index of a custom register.| **value**: pointer to the register value obtained, which is of the uint8_t type.| HDF_STATUS| Reads a custom RTC register. A register index corresponds to one byte of the register value.|
| WriteReg | **host**: structure pointer to the RTC controller at the core layer.<br>**usrDefIndex**: index of a custom register.<br>**value**: register value to write, which is of the uint8_t type.| –| HDF_STATUS| Writes a custom RTC register. A register index corresponds to one byte of the register value.|
## How to Develop
The RTC module adaptation involves the following steps:
1. Instantiate the driver entry.
- Instantiate the **HdfDriverEntry** structure.
- Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF.
- Call **HDF_INIT** to register the **HdfDriverEntry** instance with the HDF.
2. Configure attribute files.
- Add the **deviceNode** information to the **device\_info.hcs** file.
-\(Optional\) Add the **rtc\_config.hcs** file.
- Add the **deviceNode** information to the **device_info.hcs** file.
- (Optional) Add the **rtc_config.hcs** file.
3. Instantiate the RTC controller object.
- Initialize **RtcHost**.
- Instantiate **RtcMethod** in the **RtcHost** object.
> For details about the functions in **RtcMethod**, see [Available APIs](#available-apis).
4. Debug the driver.
-\(Optional\) For new drivers, verify the basic functions, such as the RTC control status and response to interrupts.
(Optional) For new drivers, verify the basic functions, such as the RTC status control and response to interrupts.
## Development Example<a name="section1594883301142407"></a>
## Development Example
The following uses **rtc\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions.
The following uses **rtc_hi35xx.c** as an example to present the information required for implementing device functions.
1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
1. Instantiate the driver entry.<br/>The driver entry must be a global variable of the **HdfDriverEntry** type (defined in **hdf_device_desc.h**), and the value of **moduleName** must be the same as that in **device_info.hcs**. In the HDF framework, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
Generally, the HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, the HDF calls **Release** to release driver resources and exit.
Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exit.
- RTC driver entry reference
RTC driver entry example:
```
struct HdfDriverEntry g_rtcDriverEntry = {
...
...
@@ -219,17 +85,19 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents tha
.Bind = HiRtcBind, // See the Bind function.
.Init = HiRtcInit, // See the Init function.
.Release = HiRtcRelease, //See the Release function.
.moduleName = "HDF_PLATFORM_RTC", // (Mandatory) This parameter must be the same as that in the .hcs file.
.moduleName = "HDF_PLATFORM_RTC", // (Mandatory) The value must be the same as that in the .hcs file.
};
// Call HDF_INIT to register the driver entry with the HDF.
HDF_INIT(g_rtcDriverEntry);
```
2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **rtc\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the default values or value ranges of the **RtcHost** members at the core layer.
2. Add the **deviceNode** information to the **device_info.hcs** file and configure the device attributes in the **rtc_config.hcs** file.
The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the default values or value ranges of the **RtcHost** members at the core layer.
In this example, there is only one RTC controller. If there are multiple RTC controllers, you need to add the **deviceNode** information to the **device_info** file and add the corresponding device attributes to the **rtc_config** file for each controller.
In this example, there is only one RTC controller. If there are multiple RTC controllers, you need to add the **deviceNode** information to the **device\_info** file and add the corresponding device attributes to the **rtc\_config** file.
-**device_info.hcs** configuration example
- **device\_info.hcs** configuration reference
```
root {
...
...
@@ -237,11 +105,11 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents tha
platform :: host {
device_rtc :: device {
device0 :: deviceNode {
policy = 1; // 2: The driver publishes user-mode services. 1: The driver publishes kernel-mode services. 0: No service needs to be published.
policy = 1; // The driver publishes services for kernel-mode processes only.
priority = 30; // A smaller value indicates a higher priority.
permission = 0644; // Permission for the driver to create a device node
moduleName = "HDF_PLATFORM_RTC"; // (Mandatory) Driver name, which must be the same as the moduleName in the driver entry.
serviceName = "HDF_PLATFORM_RTC"; // (Mandatory) Unique name of the service published by the driver
moduleName = "HDF_PLATFORM_RTC"; // (Mandatory) Driver name, which must be the same as moduleName in the driver entry.
serviceName = "HDF_PLATFORM_RTC"; // (Mandatory) Unique name of the service published by the driver.
deviceMatchAttr = "hisilicon_hi35xx_rtc";// The value must be the same as that of match_attr in the .hcs file.
}
}
...
...
@@ -250,7 +118,8 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents tha
}
```
- **rtc\_config.hcs** configuration reference
-**rtc_config.hcs** configuration example
```
root {
...
...
@@ -258,9 +127,9 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents tha
rtc_config {
controller_0x12080000 {
match_attr = "hisilicon_hi35xx_rtc";// (Mandatory) The value must be the same as that of deviceMatchAttr in device_info.hcs.
rtcSpiBaseAddr = 0x12080000; // Used for address mapping
regAddrLength = 0x100; // Used for address mapping
irq = 37; // Interruption number
rtcSpiBaseAddr = 0x12080000; // Used for address mapping.
regAddrLength = 0x100; // Used for address mapping.
irq = 37; // Interrupt number.
supportAnaCtrl = false;
supportLock = false;
anaCtrlAddr = 0xff;
...
...
@@ -274,27 +143,28 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents tha
}
```
3. Initialize the **RtcHost** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **RtcMethod**\(used to call underlying functions of the driver\) in **RtcHost**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\).
- Custom structure reference
3. Initialize the **RtcHost** object at the core layer, including defining a custom structure (to pass parameters and data) and implementing the **HdfDriverEntry** member functions (**Bind**, **Init** and **Release**) to instantiate **RtcMethod** in **RtcHost** (so that the underlying driver functions can be called).
- Defining a custom structure
To the driver, the custom structure holds parameters and data. The **DeviceResourceIface** method provided by the HDF reads the values in the **rtc_config.hcs** file to initialize the members in the custom structure.
To the driver, the custom structure carries parameters and data. The values in the **rtc\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**.
```
struct RtcConfigInfo {
uint32_t spiBaseAddr; // Used for address mapping
volatile void *remapBaseAddr; // Used for address mapping
uint16_t regAddrLength; // Used for address mapping
uint8_t supportAnaCtrl; // Indicates whether ANACTRL is supported.
uint8_t supportLock; // Indicates whether lock is supported.
uint8_t irq; // Interrupt number
uint8_t alarmIndex; // Clock alarm index
uint8_t anaCtrlAddr; // ANACTRL address
struct RtcLockAddr lockAddr; // Lock address
RtcAlarmCallback cb; // Callback
struct OsalMutex mutex; // Mutex
uint32_t spiBaseAddr; // Used for address mapping.
volatile void *remapBaseAddr; // Used for address mapping.
uint16_t regAddrLength; // Used for address mapping.
uint8_t supportAnaCtrl; // Whether ANACTRL is supported.
uint8_t supportLock; // Whether lock is supported.
uint8_t irq; // Interrupt number.
uint8_t alarmIndex; // RTC alarm index.
uint8_t anaCtrlAddr; // ANACTRL address.
struct RtcLockAddr lockAddr; // Lock address.
RtcAlarmCallback cb; // Callback.
struct OsalMutex mutex; // Mutex.
};
// RtcHost is the controller structure at the core layer. Its members are assigned with values by using the Init function.
// RtcHost is the controller structure at the core layer. The Init function assigns values to the members of RtcHost.
struct RtcHost {
struct IDeviceIoService service;
struct HdfDeviceObject *device;
...
...
@@ -302,8 +172,8 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents tha
void *data;
};
```
- Instantiating **RtcMethod** in **RtcHost** (other members are initialized by **Init**)
- Instantiate the callback function structure **RtcMethod** in **RtcHost**. Other members are initialized by using the **Init** function.
```
// Example in rtc_hi35xx.c: instantiate the hook.
...
...
@@ -322,130 +192,101 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents tha
};
```
- Bind function
Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values:
HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\)
**Table 2** Input parameters and return values of the Bind function
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs information.
Return value:
HDF_STATUS<br/>The table below describes some status. For more information, see **HDF_STATUS** in the **/drivers/framework/include/utils/hdf_base.h** file.
host = RtcHostFromDevice(device);// A forced conversion from HdfDeviceObject to RtcHost is involved.
host = RtcHostFromDevice(device);// Forcibly convert HdfDeviceObject to RtcHost.
rtcInfo = OsalMemCalloc(sizeof(*rtcInfo));
...
// HiRtcConfigData reads attributes from the device configuration tree and fills in supportAnaCtrl, supportLock, spiBaseAddr, regAddrLength, and irq in rtcInfo.
// Provide parameters for HiRtcSwInit and HiRtcSwInit, and perform operations such as releasing memory when the function internal processing fails.
// HiRtcConfigData reads attributes from the device configuration tree and fills the values in supportAnaCtrl, supportLock, spiBaseAddr, regAddrLength, and irq in rtcInfo.
// Provide parameters for HiRtcSwInit and HiRtcSwInit. When HiRtcSwInit and HiRtcSwInit fail to be executed internally, operations such as memory release can be performed.
if (HiRtcConfigData(rtcInfo, device->property) != 0) {
...
}
if (HiRtcSwInit(rtcInfo)! = 0) {// Related to address mapping and interrupt registration
if (HiRtcSwInit(rtcInfo)! = 0) {// Address mapping and interrupt registration.
...
}
if (HiRtcHwInit(rtcInfo)! = 0) {// Initialize ANACTRL and lockAddr.
...
}
host->method = &g_method; // Connect to the UARTHostMethod instance.
host->data = rtcInfo; // Enable conversion between RtcConfigInfo and RtcHost.
host->method = &g_method; // Attach the RtcMethod instance.
host->data = rtcInfo; // Prerequisites for conversion between RtcConfigInfo and RtcHost.
HDF_LOGI("Hdf dev service:%s init success!", HdfDeviceGetServiceName(device));
return HDF_SUCCESS;
}
```
-**Release** function
- Release function
Input parameter:
Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs information.
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return value:
Return values:
No value is returned.
–
Function description:
**Function description**:
Releases the memory and deletes the controller. This function assigns values to the **Release** function in the driver entry structure. If the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** or **Bind** function has the corresponding value assignment operations.
Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** or **Bind** function has the corresponding value assignment operations.