blob: cddcd09396ff61bca4a7877c5526f67cffb78b65 [file] [log] [blame]
/* Copyright 2019 The Fuchsia Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
/* Define this to zero to remove all standard library dependencies. Note you'll
* need to define some standard types and implement the abr_* functions declared
* below.
/* Local changes for Estelle. */
#include <linux/types.h>
/* libabr doesn't expose any way to check if metadata is valid or not, so we
have to expose an extra function. */
bool AbrIsValidMetadata(const uint8_t* buffer, size_t size);
/* End local changes for Estelle. */
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
/* This should work for clang and gcc. */
#define ABR_ATTR_PACKED __attribute__((packed))
#define AbrMemcpy memcpy
#define AbrMemset memset
#define AbrPrint printf
#define AbrAbort abort
/* Like standard memcpy. Copy |n| bytes from |src| to |dest|. Returns |dest|. */
void* AbrMemcpy(void* dest, const void* src, size_t n);
/* Like standard memset. Set |n| bytes at |dest| to |c|. Returns |dest|. */
void* AbrMemset(void* dest, const int c, size_t n);
/* Prints out a NUL-terminated string. Note this is much simpler than the standard printf, but
* printf can safely replace this at call-sites.
void AbrPrint(const char* message);
/* Like standard abort. Aborts the program or reboots the device if |abort| is not implemented in a
* platform. */
void AbrAbort(void);
/* Calculates the CRC-32 for data in |buf| of size |buf_size|. An implementation is not provided
* because most environments already have an implementation available.
uint32_t AbrCrc32(const void* buf, size_t buf_size);
#ifdef __cplusplus