GK SDK 源码库: XMIPCLinuxV100R005C00SPC030 (kernel/tools/open_source excluded)

This commit is contained in:
lai
2026-09-06 03:52:57 +08:00
commit b1928b41c0
21813 changed files with 4413081 additions and 0 deletions
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef IO_BLOCK_H
#define IO_BLOCK_H
#include <drivers/io/io_storage.h>
/* block devices ops */
typedef struct io_block_ops {
size_t (*read)(int lba, uintptr_t buf, size_t size);
size_t (*write)(int lba, const uintptr_t buf, size_t size);
} io_block_ops_t;
typedef struct io_block_dev_spec {
io_block_spec_t buffer;
io_block_ops_t ops;
size_t block_size;
} io_block_dev_spec_t;
struct io_dev_connector;
int register_io_dev_block(const struct io_dev_connector **dev_con);
#endif /* IO_BLOCK_H */
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2014, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef IO_DRIVER_H
#define IO_DRIVER_H
#include <stdint.h>
#include <drivers/io/io_storage.h>
/* Generic IO entity structure,representing an accessible IO construct on the
* device, such as a file */
typedef struct io_entity {
struct io_dev_info *dev_handle;
uintptr_t info;
} io_entity_t;
/* Device info structure, providing device-specific functions and a means of
* adding driver-specific state */
typedef struct io_dev_info {
const struct io_dev_funcs *funcs;
uintptr_t info;
} io_dev_info_t;
/* Structure used to create a connection to a type of device */
typedef struct io_dev_connector {
/* dev_open opens a connection to a particular device driver */
int (*dev_open)(const uintptr_t dev_spec, io_dev_info_t **dev_info);
} io_dev_connector_t;
/* Structure to hold device driver function pointers */
typedef struct io_dev_funcs {
io_type_t (*type)(void);
int (*open)(io_dev_info_t *dev_info, const uintptr_t spec,
io_entity_t *entity);
int (*seek)(io_entity_t *entity, int mode, signed long long offset);
int (*size)(io_entity_t *entity, size_t *length);
int (*read)(io_entity_t *entity, uintptr_t buffer, size_t length,
size_t *length_read);
int (*write)(io_entity_t *entity, const uintptr_t buffer,
size_t length, size_t *length_written);
int (*close)(io_entity_t *entity);
int (*dev_init)(io_dev_info_t *dev_info, const uintptr_t init_params);
int (*dev_close)(io_dev_info_t *dev_info);
} io_dev_funcs_t;
/* Operations intended to be performed during platform initialisation */
/* Register an IO device */
int io_register_device(const io_dev_info_t *dev_info);
#endif /* IO_DRIVER_H */
@@ -0,0 +1,12 @@
/*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef IO_DUMMY_H
#define IO_DUMMY_H
int register_io_dev_dummy(const struct io_dev_connector **dev_con);
#endif /* IO_DUMMY_H */
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2020, Linaro Limited. All rights reserved.
* Author: Sumit Garg <sumit.garg@linaro.org>
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef IO_ENCRYPTED_H
#define IO_ENCRYPTED_H
struct io_dev_connector;
int register_io_dev_enc(const struct io_dev_connector **dev_con);
#endif /* IO_ENCRYPTED_H */
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef IO_FIP_H
#define IO_FIP_H
struct io_dev_connector;
int register_io_dev_fip(const struct io_dev_connector **dev_con);
int fip_dev_get_plat_toc_flag(io_dev_info_t *dev_info, uint16_t *plat_toc_flag);
#endif /* IO_FIP_H */
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2014, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef IO_MEMMAP_H
#define IO_MEMMAP_H
struct io_dev_connector;
int register_io_dev_memmap(const struct io_dev_connector **dev_con);
#endif /* IO_MEMMAP_H */
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2019-2021, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef IO_MTD_H
#define IO_MTD_H
#include <stdint.h>
#include <stdio.h>
#include <drivers/io/io_storage.h>
/* MTD devices ops */
typedef struct io_mtd_ops {
/*
* Initialize MTD framework and retrieve device information.
*
* @size: [out] MTD device size in bytes.
* @erase_size: [out] MTD erase size in bytes.
* Return 0 on success, a negative error code otherwise.
*/
int (*init)(unsigned long long *size, unsigned int *erase_size);
/*
* Execute a read memory operation.
*
* @offset: Offset in bytes to start read operation.
* @buffer: [out] Buffer to store read data.
* @length: Required length to be read in bytes.
* @out_length: [out] Length read in bytes.
* Return 0 on success, a negative error code otherwise.
*/
int (*read)(unsigned int offset, uintptr_t buffer, size_t length,
size_t *out_length);
/*
* Execute a write memory operation.
*
* @offset: Offset in bytes to start write operation.
* @buffer: Buffer to be written in device.
* @length: Required length to be written in bytes.
* Return 0 on success, a negative error code otherwise.
*/
int (*write)(unsigned int offset, uintptr_t buffer, size_t length);
/*
* Look for an offset to be added to the given offset.
*
* @base: Base address of the area.
* @offset: Offset in bytes to start read operation.
* @extra_offset: [out] Offset to be added to the previous offset.
* Return 0 on success, a negative error code otherwise.
*/
int (*seek)(uintptr_t base, unsigned int offset, size_t *extra_offset);
} io_mtd_ops_t;
typedef struct io_mtd_dev_spec {
unsigned long long device_size;
unsigned int erase_size;
size_t offset;
io_mtd_ops_t ops;
} io_mtd_dev_spec_t;
struct io_dev_connector;
int register_io_dev_mtd(const struct io_dev_connector **dev_con);
#endif /* IO_MTD_H */
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2014, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef IO_SEMIHOSTING_H
#define IO_SEMIHOSTING_H
struct io_dev_connector;
int register_io_dev_sh(const struct io_dev_connector **dev_con);
#endif /* IO_SEMIHOSTING_H */
@@ -0,0 +1,103 @@
/*
* Copyright (c) 2014-2022, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef IO_STORAGE_H
#define IO_STORAGE_H
#include <errno.h>
#include <stdint.h>
#include <stdio.h> /* For ssize_t */
#include <tools_share/uuid.h>
/* Device type which can be used to enable policy decisions about which device
* to access */
typedef enum {
IO_TYPE_INVALID,
IO_TYPE_SEMIHOSTING,
IO_TYPE_MEMMAP,
IO_TYPE_DUMMY,
IO_TYPE_FIRMWARE_IMAGE_PACKAGE,
IO_TYPE_BLOCK,
IO_TYPE_MTD,
IO_TYPE_MMC,
IO_TYPE_ENCRYPTED,
IO_TYPE_MAX
} io_type_t;
/* Modes used when seeking data on a supported device */
typedef enum {
IO_SEEK_INVALID,
IO_SEEK_SET,
IO_SEEK_END,
IO_SEEK_CUR,
IO_SEEK_MAX
} io_seek_mode_t;
/* Connector type, providing a means of identifying a device to open */
struct io_dev_connector;
/* File specification - used to refer to data on a device supporting file-like
* entities */
typedef struct io_file_spec {
const char *path;
unsigned int mode;
} io_file_spec_t;
/* UUID specification - used to refer to data accessed using UUIDs (i.e. FIP
* images) */
typedef struct io_uuid_spec {
uuid_t uuid;
} io_uuid_spec_t;
/* Block specification - used to refer to data on a device supporting
* block-like entities */
typedef struct io_block_spec {
size_t offset;
size_t length;
} io_block_spec_t;
/* Access modes used when accessing data on a device */
#define IO_MODE_INVALID (0)
#define IO_MODE_RO (1 << 0)
#define IO_MODE_RW (1 << 1)
/* Open a connection to a device */
int io_dev_open(const struct io_dev_connector *dev_con,
const uintptr_t dev_spec,
uintptr_t *handle);
/* Initialise a device explicitly - to permit lazy initialisation or
* re-initialisation */
int io_dev_init(uintptr_t dev_handle, const uintptr_t init_params);
/* Close a connection to a device */
int io_dev_close(uintptr_t dev_handle);
/* Synchronous operations */
int io_open(uintptr_t dev_handle, const uintptr_t spec, uintptr_t *handle);
int io_seek(uintptr_t handle, io_seek_mode_t mode, signed long long offset);
int io_size(uintptr_t handle, size_t *length);
int io_read(uintptr_t handle, uintptr_t buffer, size_t length,
size_t *length_read);
int io_write(uintptr_t handle, const uintptr_t buffer, size_t length,
size_t *length_written);
int io_close(uintptr_t handle);
#endif /* IO_STORAGE_H */