TT Zephyr Platforms 18.11.99
Tenstorrent Firmware
Loading...
Searching...
No Matches
tt_boot_fs.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <zephyr/device.h>
#include <zephyr/drivers/flash.h>
#include <zephyr/devicetree.h>

Go to the source code of this file.

Data Structures

struct  fd_flags
union  fd_flags_u
struct  security_fd_flags
union  security_fd_flags_u
struct  tt_boot_fs_fd
struct  tt_boot_fs

Macros

#define TT_BOOT_FS_FD_HEAD_ADDR   (0x0)
#define TT_BOOT_FS_SECURITY_BINARY_FD_ADDR   (0x3FE0)
#define TT_BOOT_FS_FAILOVER_HEAD_ADDR   (0x4000)
#define TT_BOOT_FS_IMAGE_TAG_SIZE   8

Typedefs

typedef int(* tt_boot_fs_read) (uint32_t addr, uint32_t size, uint8_t *dst)
typedef int(* tt_boot_fs_write) (uint32_t addr, uint32_t size, const uint8_t *src)
typedef int(* tt_boot_fs_erase) (uint32_t addr, uint32_t size)

Enumerations

enum  {
  TT_BOOT_FS_OK = 0 ,
  TT_BOOT_FS_ERR = -1
}
enum  tt_checksum_res_t {
  TT_BOOT_FS_CHK_OK ,
  TT_BOOT_FS_CHK_FAIL
}

Functions

uint32_t tt_boot_fs_next (uint32_t prev)
int tt_boot_fs_mount (tt_boot_fs *tt_boot_fs, tt_boot_fs_read hal_read, tt_boot_fs_write hal_write, tt_boot_fs_erase hal_erase)
int tt_boot_fs_add_file (const tt_boot_fs *tt_boot_fs, tt_boot_fs_fd fd_data, const uint8_t *image_data_src, bool isFailoverEntry, bool isSecurityBinaryEntry)
uint32_t tt_boot_fs_cksum (uint32_t cksum, const uint8_t *data, size_t size)
int tt_boot_fs_get_file (const tt_boot_fs *tt_boot_fs, const uint8_t *tag, uint8_t *buf, size_t buf_size, size_t *file_size)
int tt_boot_fs_ls (const struct device *dev, tt_boot_fs_fd *fds, size_t nfds, size_t offset)
 List file descriptors in boot filesystem.
int tt_boot_fs_find_fd_by_tag (const struct device *flash_dev, const uint8_t *tag, tt_boot_fs_fd *fd)
 Find a boot filesystem file descriptor by name on a given flash device.

Variables

tt_boot_fs boot_fs_data

Macro Definition Documentation

◆ TT_BOOT_FS_FAILOVER_HEAD_ADDR

#define TT_BOOT_FS_FAILOVER_HEAD_ADDR   (0x4000)

◆ TT_BOOT_FS_FD_HEAD_ADDR

#define TT_BOOT_FS_FD_HEAD_ADDR   (0x0)

◆ TT_BOOT_FS_IMAGE_TAG_SIZE

#define TT_BOOT_FS_IMAGE_TAG_SIZE   8

◆ TT_BOOT_FS_SECURITY_BINARY_FD_ADDR

#define TT_BOOT_FS_SECURITY_BINARY_FD_ADDR   (0x3FE0)

Typedef Documentation

◆ tt_boot_fs_erase

typedef int(* tt_boot_fs_erase) (uint32_t addr, uint32_t size)

◆ tt_boot_fs_read

typedef int(* tt_boot_fs_read) (uint32_t addr, uint32_t size, uint8_t *dst)

◆ tt_boot_fs_write

typedef int(* tt_boot_fs_write) (uint32_t addr, uint32_t size, const uint8_t *src)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
TT_BOOT_FS_OK 
TT_BOOT_FS_ERR -1 

◆ tt_checksum_res_t

Enumerator
TT_BOOT_FS_CHK_OK 
TT_BOOT_FS_CHK_FAIL 

Function Documentation

◆ tt_boot_fs_add_file()

int tt_boot_fs_add_file ( const tt_boot_fs * tt_boot_fs,
tt_boot_fs_fd fd_data,
const uint8_t * image_data_src,
bool isFailoverEntry,
bool isSecurityBinaryEntry )

◆ tt_boot_fs_cksum()

uint32_t tt_boot_fs_cksum ( uint32_t cksum,
const uint8_t * data,
size_t size )

◆ tt_boot_fs_find_fd_by_tag()

int tt_boot_fs_find_fd_by_tag ( const struct device * flash_dev,
const uint8_t * tag,
tt_boot_fs_fd * fd )

Find a boot filesystem file descriptor by name on a given flash device.

If fd is NULL, then a return value of 0 indicates that a file named name exists in the boot filesystem residing on flash_dev.

If fd is non-NULL, then file descriptor contents are written to the memory pointed to by it. The output file descriptor includes useful information about the file, like

  • the address of the file in flash_dev,
  • the size of the file, and
  • the checksum of the file, and more.
Parameters
flash_devflash device containing the boot filesystem
tagname of the image to search for
[out]fdoptional pointer to memory where the file descriptor will be written, if found
Return values
0on success
-EIOif an I/O error occurs
-ENXIOif flash_dev does not contain a boot filesystem
-ENOENTif no file was found matching the specified tag

◆ tt_boot_fs_get_file()

int tt_boot_fs_get_file ( const tt_boot_fs * tt_boot_fs,
const uint8_t * tag,
uint8_t * buf,
size_t buf_size,
size_t * file_size )

◆ tt_boot_fs_ls()

int tt_boot_fs_ls ( const struct device * dev,
tt_boot_fs_fd * fds,
size_t nfds,
size_t offset )

List file descriptors in boot filesystem.

Read up to nfds file descriptors from a boot filesystem on flash device flash_dev starting from index offset. If reading from flash_dev causes an error, then this function will return -EIO. If flash_dev does not contain a valid boot fs, this function returns -ENXIO. On success, the number of file descriptors is returned.

This function may also be used to count the number of files that exist on a boot filesystem if fds is NULL. In that case, the nfds and offset parameters are ignored.

Parameters
devFlash device containing the boot filesystem
fdsOutput array to store file descriptors, or NULL to count files
nfdsMaximum number of file descriptors to read
offsetFile index from which to begin reading file descriptors
Returns
the number of file descriptors successfully read or a negative error code on failure.

◆ tt_boot_fs_mount()

int tt_boot_fs_mount ( tt_boot_fs * tt_boot_fs,
tt_boot_fs_read hal_read,
tt_boot_fs_write hal_write,
tt_boot_fs_erase hal_erase )

◆ tt_boot_fs_next()

uint32_t tt_boot_fs_next ( uint32_t prev)

Variable Documentation

◆ boot_fs_data

tt_boot_fs boot_fs_data
extern