Adjust directory structure

This commit is contained in:
Zhao_Jiasheng
2021-06-03 17:38:11 +08:00
parent 92301257f3
commit 89a2236b18
1993 changed files with 40 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
SRC_FILES +=bus_sdio.c dev_sdio.c drv_sdio.c
include $(KERNEL_ROOT)/compiler.mk
+117
View File
@@ -0,0 +1,117 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file bus_sdio.c
* @brief register sdio bus function using bus driver framework
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-04-24
*/
#include <bus_sdio.h>
#include <dev_sdio.h>
int SdioBusInit(struct SdioBus *sdio_bus, const char *bus_name)
{
NULL_PARAM_CHECK(sdio_bus);
NULL_PARAM_CHECK(bus_name);
x_err_t ret = EOK;
if (BUS_INSTALL != sdio_bus->bus.bus_state) {
strncpy(sdio_bus->bus.bus_name, bus_name, NAME_NUM_MAX);
sdio_bus->bus.bus_type = TYPE_SDIO_BUS;
sdio_bus->bus.bus_state = BUS_INSTALL;
sdio_bus->bus.private_data = sdio_bus->private_data;
ret = BusRegister(&sdio_bus->bus);
if (EOK != ret) {
KPrintf("SdioBusInit BusRegister error %u\n", ret);
return ret;
}
} else {
KPrintf("SdioBusInit BusRegister bus has been register state%u\n", sdio_bus->bus.bus_state);
}
return ret;
}
int SdioDriverInit(struct SdioDriver *sdio_driver, const char *driver_name)
{
NULL_PARAM_CHECK(sdio_driver);
NULL_PARAM_CHECK(driver_name);
x_err_t ret = EOK;
if (DRV_INSTALL != sdio_driver->driver.driver_state) {
sdio_driver->driver.driver_type = TYPE_SDIO_DRV;
sdio_driver->driver.driver_state = DRV_INSTALL;
strncpy(sdio_driver->driver.drv_name, driver_name, NAME_NUM_MAX);
sdio_driver->driver.configure = sdio_driver->configure;
ret = SdioDriverRegister(&sdio_driver->driver);
if (EOK != ret) {
KPrintf("SdioDriverInit DriverRegister error %u\n", ret);
return ret;
}
} else {
KPrintf("SdioDriverInit DriverRegister driver has been register state%u\n", sdio_driver->driver.driver_state);
}
return ret;
}
int SdioReleaseBus(struct SdioBus *sdio_bus)
{
NULL_PARAM_CHECK(sdio_bus);
return BusRelease(&sdio_bus->bus);
}
int SdioDriverAttachToBus(const char *drv_name, const char *bus_name)
{
NULL_PARAM_CHECK(drv_name);
NULL_PARAM_CHECK(bus_name);
x_err_t ret = EOK;
struct Bus *bus;
struct Driver *driver;
bus = BusFind(bus_name);
if (NONE == bus) {
KPrintf("SdioDriverAttachToBus find sdio bus error!name %s\n", bus_name);
return ERROR;
}
if (TYPE_SDIO_BUS == bus->bus_type) {
driver = SdioDriverFind(drv_name);
if (NONE == driver) {
KPrintf("SdioDriverAttachToBus find sdio driver error!name %s\n", drv_name);
return ERROR;
}
if (TYPE_SDIO_DRV == driver->driver_type) {
ret = DriverRegisterToBus(bus, driver);
if (EOK != ret) {
KPrintf("SdioDriverAttachToBus DriverRegisterToBus error %u\n", ret);
return ERROR;
}
}
}
return ret;
}
+114
View File
@@ -0,0 +1,114 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file dev_sdio.c
* @brief register sdio dev function using bus driver framework
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-04-24
*/
#include <bus_sdio.h>
#include <dev_sdio.h>
static DoubleLinklistType sdiodev_linklist;
/*Create the sdio device linklist*/
static void SdioDeviceLinkInit()
{
InitDoubleLinkList(&sdiodev_linklist);
}
HardwareDevType SdioDeviceFind(const char *dev_name)
{
NULL_PARAM_CHECK(dev_name);
struct HardwareDev *device = NONE;
DoubleLinklistType *node = NONE;
DoubleLinklistType *head = &sdiodev_linklist;
for (node = head->node_next; node != head; node = node->node_next) {
device = SYS_DOUBLE_LINKLIST_ENTRY(node, struct HardwareDev, dev_link);
if (!strcmp(device->dev_name, dev_name)) {
return device;
}
}
KPrintf("SdioDeviceFind cannot find the %s device.return NULL\n", dev_name);
return NONE;
}
int SdioDeviceRegister(struct SdioHardwareDevice *sdio_device, const char *device_name)
{
NULL_PARAM_CHECK(sdio_device);
NULL_PARAM_CHECK(device_name);
x_err_t ret = EOK;
static x_bool dev_link_flag = RET_FALSE;
if (!dev_link_flag) {
SdioDeviceLinkInit();
dev_link_flag = RET_TRUE;
}
if (DEV_INSTALL != sdio_device->haldev.dev_state) {
strncpy(sdio_device->haldev.dev_name, device_name, NAME_NUM_MAX);
sdio_device->haldev.dev_type = TYPE_SDIO_DEV;
sdio_device->haldev.dev_state = DEV_INSTALL;
sdio_device->haldev.dev_done = (struct HalDevDone *)sdio_device->dev_done;
sdio_device->haldev.private_data = sdio_device->private_data;
DoubleLinkListInsertNodeAfter(&sdiodev_linklist, &(sdio_device->haldev.dev_link));
} else {
KPrintf("SdioDeviceRegister device has been register state%u\n", sdio_device->haldev.dev_state);
}
return ret;
}
int SdioDeviceAttachToBus(const char *dev_name, const char *bus_name)
{
NULL_PARAM_CHECK(dev_name);
NULL_PARAM_CHECK(bus_name);
x_err_t ret = EOK;
struct Bus *bus;
struct HardwareDev *device;
bus = BusFind(bus_name);
if (NONE == bus) {
KPrintf("SdioDeviceAttachToBus find sdio bus error!name %s\n", bus_name);
return ERROR;
}
if (TYPE_SDIO_BUS == bus->bus_type) {
device = SdioDeviceFind(dev_name);
if (NONE == device) {
KPrintf("SdioDeviceAttachToBus find sdio device error!name %s\n", dev_name);
return ERROR;
}
if (TYPE_SDIO_DEV == device->dev_type) {
ret = DeviceRegisterToBus(bus, device);
if (EOK != ret) {
KPrintf("SdioDeviceAttachToBus DeviceRegisterToBus error %u\n", ret);
return ERROR;
}
}
}
return EOK;
}
@@ -0,0 +1,67 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file drv_sdio.c
* @brief register sdio drv function using bus driver framework
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-04-24
*/
#include <bus_sdio.h>
#include <dev_sdio.h>
static DoubleLinklistType sdiodrv_linklist;
/*Create the driver linklist*/
static void SdioDrvLinkInit()
{
InitDoubleLinkList(&sdiodrv_linklist);
}
DriverType SdioDriverFind(const char *drv_name)
{
NULL_PARAM_CHECK(drv_name);
struct Driver *driver = NONE;
DoubleLinklistType *node = NONE;
DoubleLinklistType *head = &sdiodrv_linklist;
for (node = head->node_next; node != head; node = node->node_next) {
driver = SYS_DOUBLE_LINKLIST_ENTRY(node, struct Driver, driver_link);
if (!strcmp(driver->drv_name, drv_name)) {
return driver;
}
}
KPrintf("SdioDriverFind cannot find the %s driver.return NULL\n", drv_name);
return NONE;
}
int SdioDriverRegister(struct Driver *driver)
{
NULL_PARAM_CHECK(driver);
x_err_t ret = EOK;
static x_bool driver_link_flag = RET_FALSE;
if (!driver_link_flag) {
SdioDrvLinkInit();
driver_link_flag = RET_TRUE;
}
DoubleLinkListInsertNodeAfter(&sdiodrv_linklist, &(driver->driver_link));
return ret;
}