cleanup: include/: move disk_access.h to disk/disk_access.h
move disk_access.h to disk/disk_access.h and create a shim for backward-compatibility. No functional changes to the headers. A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES. Related to #16539 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
4e48e87fd2
commit
f641d099cc
9 changed files with 142 additions and 127 deletions
131
include/disk/disk_access.h
Normal file
131
include/disk/disk_access.h
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Intel Corporation.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* @brief Disk Access layer APIs and defines
|
||||||
|
*
|
||||||
|
* This file contains APIs for disk access. Apart from disks, various
|
||||||
|
* other storage media like Flash and RAM disks may implement this interface to
|
||||||
|
* be used by various higher layers(consumers) like USB Mass storage
|
||||||
|
* and Filesystems.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZEPHYR_INCLUDE_DISK_DISK_ACCESS_H_
|
||||||
|
#define ZEPHYR_INCLUDE_DISK_DISK_ACCESS_H_
|
||||||
|
|
||||||
|
#include <kernel.h>
|
||||||
|
#include <zephyr/types.h>
|
||||||
|
#include <misc/dlist.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Possible Cmd Codes for disk_ioctl() */
|
||||||
|
|
||||||
|
/* Get the number of sectors in the disk */
|
||||||
|
#define DISK_IOCTL_GET_SECTOR_COUNT 1
|
||||||
|
/* Get the size of a disk SECTOR in bytes */
|
||||||
|
#define DISK_IOCTL_GET_SECTOR_SIZE 2
|
||||||
|
/* How many sectors constitute a FLASH Erase block */
|
||||||
|
#define DISK_IOCTL_GET_ERASE_BLOCK_SZ 4
|
||||||
|
/* Commit any cached read/writes to disk */
|
||||||
|
#define DISK_IOCTL_CTRL_SYNC 5
|
||||||
|
|
||||||
|
/* 3 is reserved. It used to be DISK_IOCTL_GET_DISK_SIZE */
|
||||||
|
|
||||||
|
/* Possible return bitmasks for disk_status() */
|
||||||
|
#define DISK_STATUS_OK 0x00
|
||||||
|
#define DISK_STATUS_UNINIT 0x01
|
||||||
|
#define DISK_STATUS_NOMEDIA 0x02
|
||||||
|
#define DISK_STATUS_WR_PROTECT 0x04
|
||||||
|
|
||||||
|
struct disk_operations;
|
||||||
|
|
||||||
|
struct disk_info {
|
||||||
|
sys_dnode_t node;
|
||||||
|
char *name;
|
||||||
|
const struct disk_operations *ops;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct disk_operations {
|
||||||
|
int (*init)(struct disk_info *disk);
|
||||||
|
int (*status)(struct disk_info *disk);
|
||||||
|
int (*read)(struct disk_info *disk, u8_t *data_buf,
|
||||||
|
u32_t start_sector, u32_t num_sector);
|
||||||
|
int (*write)(struct disk_info *disk, const u8_t *data_buf,
|
||||||
|
u32_t start_sector, u32_t num_sector);
|
||||||
|
int (*ioctl)(struct disk_info *disk, u8_t cmd, void *buff);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief perform any initialization
|
||||||
|
*
|
||||||
|
* This call is made by the consumer before doing any IO calls so that the
|
||||||
|
* disk or the backing device can do any initialization.
|
||||||
|
*
|
||||||
|
* @return 0 on success, negative errno code on fail
|
||||||
|
*/
|
||||||
|
int disk_access_init(const char *pdrv);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Get the status of disk
|
||||||
|
*
|
||||||
|
* This call is used to get the status of the disk
|
||||||
|
*
|
||||||
|
* @return DISK_STATUS_OK or other DISK_STATUS_*s
|
||||||
|
*/
|
||||||
|
int disk_access_status(const char *pdrv);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief read data from disk
|
||||||
|
*
|
||||||
|
* Function to read data from disk to a memory buffer.
|
||||||
|
*
|
||||||
|
* @param[in] data_buf Pointer to the memory buffer to put data.
|
||||||
|
* @param[in] start_sector Start disk sector to read from
|
||||||
|
* @param[in] num_sector Number of disk sectors to read
|
||||||
|
*
|
||||||
|
* @return 0 on success, negative errno code on fail
|
||||||
|
*/
|
||||||
|
int disk_access_read(const char *pdrv, u8_t *data_buf,
|
||||||
|
u32_t start_sector, u32_t num_sector);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief write data to disk
|
||||||
|
*
|
||||||
|
* Function write data from memory buffer to disk.
|
||||||
|
*
|
||||||
|
* @param[in] data_buf Pointer to the memory buffer
|
||||||
|
* @param[in] start_sector Start disk sector to write to
|
||||||
|
* @param[in] num_sector Number of disk sectors to write
|
||||||
|
*
|
||||||
|
* @return 0 on success, negative errno code on fail
|
||||||
|
*/
|
||||||
|
int disk_access_write(const char *pdrv, const u8_t *data_buf,
|
||||||
|
u32_t start_sector, u32_t num_sector);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Get/Configure disk parameters
|
||||||
|
*
|
||||||
|
* Function to get disk parameters and make any special device requests.
|
||||||
|
*
|
||||||
|
* @param[in] cmd DISK_IOCTL_* code describing the request
|
||||||
|
*
|
||||||
|
* @return 0 on success, negative errno code on fail
|
||||||
|
*/
|
||||||
|
int disk_access_ioctl(const char *pdrv, u8_t cmd, void *buff);
|
||||||
|
|
||||||
|
int disk_access_register(struct disk_info *disk);
|
||||||
|
|
||||||
|
int disk_access_unregister(struct disk_info *disk);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* ZEPHYR_INCLUDE_DISK_DISK_ACCESS_H_ */
|
|
@ -1,131 +1,15 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Intel Corporation.
|
* Copyright (c) 2019 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* @brief Disk Access layer APIs and defines
|
|
||||||
*
|
|
||||||
* This file contains APIs for disk access. Apart from disks, various
|
|
||||||
* other storage media like Flash and RAM disks may implement this interface to
|
|
||||||
* be used by various higher layers(consumers) like USB Mass storage
|
|
||||||
* and Filesystems.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ZEPHYR_INCLUDE_DISK_ACCESS_H_
|
#ifndef ZEPHYR_INCLUDE_DISK_ACCESS_H_
|
||||||
#define ZEPHYR_INCLUDE_DISK_ACCESS_H_
|
#define ZEPHYR_INCLUDE_DISK_ACCESS_H_
|
||||||
|
|
||||||
#include <kernel.h>
|
#ifndef CONFIG_COMPAT_INCLUDES
|
||||||
#include <zephyr/types.h>
|
#warning "This header file has moved, include <disk/disk_access.h> instead."
|
||||||
#include <misc/dlist.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Possible Cmd Codes for disk_ioctl() */
|
#include <disk/disk_access.h>
|
||||||
|
|
||||||
/* Get the number of sectors in the disk */
|
|
||||||
#define DISK_IOCTL_GET_SECTOR_COUNT 1
|
|
||||||
/* Get the size of a disk SECTOR in bytes */
|
|
||||||
#define DISK_IOCTL_GET_SECTOR_SIZE 2
|
|
||||||
/* How many sectors constitute a FLASH Erase block */
|
|
||||||
#define DISK_IOCTL_GET_ERASE_BLOCK_SZ 4
|
|
||||||
/* Commit any cached read/writes to disk */
|
|
||||||
#define DISK_IOCTL_CTRL_SYNC 5
|
|
||||||
|
|
||||||
/* 3 is reserved. It used to be DISK_IOCTL_GET_DISK_SIZE */
|
|
||||||
|
|
||||||
/* Possible return bitmasks for disk_status() */
|
|
||||||
#define DISK_STATUS_OK 0x00
|
|
||||||
#define DISK_STATUS_UNINIT 0x01
|
|
||||||
#define DISK_STATUS_NOMEDIA 0x02
|
|
||||||
#define DISK_STATUS_WR_PROTECT 0x04
|
|
||||||
|
|
||||||
struct disk_operations;
|
|
||||||
|
|
||||||
struct disk_info {
|
|
||||||
sys_dnode_t node;
|
|
||||||
char *name;
|
|
||||||
const struct disk_operations *ops;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct disk_operations {
|
|
||||||
int (*init)(struct disk_info *disk);
|
|
||||||
int (*status)(struct disk_info *disk);
|
|
||||||
int (*read)(struct disk_info *disk, u8_t *data_buf,
|
|
||||||
u32_t start_sector, u32_t num_sector);
|
|
||||||
int (*write)(struct disk_info *disk, const u8_t *data_buf,
|
|
||||||
u32_t start_sector, u32_t num_sector);
|
|
||||||
int (*ioctl)(struct disk_info *disk, u8_t cmd, void *buff);
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief perform any initialization
|
|
||||||
*
|
|
||||||
* This call is made by the consumer before doing any IO calls so that the
|
|
||||||
* disk or the backing device can do any initialization.
|
|
||||||
*
|
|
||||||
* @return 0 on success, negative errno code on fail
|
|
||||||
*/
|
|
||||||
int disk_access_init(const char *pdrv);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief Get the status of disk
|
|
||||||
*
|
|
||||||
* This call is used to get the status of the disk
|
|
||||||
*
|
|
||||||
* @return DISK_STATUS_OK or other DISK_STATUS_*s
|
|
||||||
*/
|
|
||||||
int disk_access_status(const char *pdrv);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief read data from disk
|
|
||||||
*
|
|
||||||
* Function to read data from disk to a memory buffer.
|
|
||||||
*
|
|
||||||
* @param[in] data_buf Pointer to the memory buffer to put data.
|
|
||||||
* @param[in] start_sector Start disk sector to read from
|
|
||||||
* @param[in] num_sector Number of disk sectors to read
|
|
||||||
*
|
|
||||||
* @return 0 on success, negative errno code on fail
|
|
||||||
*/
|
|
||||||
int disk_access_read(const char *pdrv, u8_t *data_buf,
|
|
||||||
u32_t start_sector, u32_t num_sector);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief write data to disk
|
|
||||||
*
|
|
||||||
* Function write data from memory buffer to disk.
|
|
||||||
*
|
|
||||||
* @param[in] data_buf Pointer to the memory buffer
|
|
||||||
* @param[in] start_sector Start disk sector to write to
|
|
||||||
* @param[in] num_sector Number of disk sectors to write
|
|
||||||
*
|
|
||||||
* @return 0 on success, negative errno code on fail
|
|
||||||
*/
|
|
||||||
int disk_access_write(const char *pdrv, const u8_t *data_buf,
|
|
||||||
u32_t start_sector, u32_t num_sector);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief Get/Configure disk parameters
|
|
||||||
*
|
|
||||||
* Function to get disk parameters and make any special device requests.
|
|
||||||
*
|
|
||||||
* @param[in] cmd DISK_IOCTL_* code describing the request
|
|
||||||
*
|
|
||||||
* @return 0 on success, negative errno code on fail
|
|
||||||
*/
|
|
||||||
int disk_access_ioctl(const char *pdrv, u8_t cmd, void *buff);
|
|
||||||
|
|
||||||
int disk_access_register(struct disk_info *disk);
|
|
||||||
|
|
||||||
int disk_access_unregister(struct disk_info *disk);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* ZEPHYR_INCLUDE_DISK_ACCESS_H_ */
|
#endif /* ZEPHYR_INCLUDE_DISK_ACCESS_H_ */
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include <zephyr.h>
|
#include <zephyr.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include <disk_access.h>
|
#include <disk/disk_access.h>
|
||||||
#include <logging/log.h>
|
#include <logging/log.h>
|
||||||
#include <fs/fs.h>
|
#include <fs/fs.h>
|
||||||
#include <ff.h>
|
#include <ff.h>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include <misc/__assert.h>
|
#include <misc/__assert.h>
|
||||||
#include <misc/util.h>
|
#include <misc/util.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <disk_access.h>
|
#include <disk/disk_access.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <zephyr/types.h>
|
#include <zephyr/types.h>
|
||||||
#include <misc/__assert.h>
|
#include <misc/__assert.h>
|
||||||
#include <misc/util.h>
|
#include <misc/util.h>
|
||||||
#include <disk_access.h>
|
#include <disk/disk_access.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <zephyr/types.h>
|
#include <zephyr/types.h>
|
||||||
#include <misc/__assert.h>
|
#include <misc/__assert.h>
|
||||||
#include <disk_access.h>
|
#include <disk/disk_access.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
LOG_MODULE_REGISTER(sdhc, CONFIG_DISK_LOG_LEVEL);
|
LOG_MODULE_REGISTER(sdhc, CONFIG_DISK_LOG_LEVEL);
|
||||||
|
|
||||||
#include <disk_access.h>
|
#include <disk/disk_access.h>
|
||||||
#include <gpio.h>
|
#include <gpio.h>
|
||||||
#include <misc/byteorder.h>
|
#include <misc/byteorder.h>
|
||||||
#include <spi.h>
|
#include <spi.h>
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <misc/byteorder.h>
|
#include <misc/byteorder.h>
|
||||||
#include <misc/__assert.h>
|
#include <misc/__assert.h>
|
||||||
#include <disk_access.h>
|
#include <disk/disk_access.h>
|
||||||
#include <usb/class/usb_msc.h>
|
#include <usb/class/usb_msc.h>
|
||||||
#include <usb/usb_device.h>
|
#include <usb/usb_device.h>
|
||||||
#include <usb/usb_common.h>
|
#include <usb/usb_common.h>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <zephyr/types.h>
|
#include <zephyr/types.h>
|
||||||
#include <misc/__assert.h>
|
#include <misc/__assert.h>
|
||||||
#include <disk_access.h>
|
#include <disk/disk_access.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue