2022-05-28 12:57:21 +01:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Aaru Data Preservation Suite.
|
|
|
|
|
* Copyright (c) 2019-2022 Natalia Portillo.
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2.1 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2019-03-16 18:38:57 +00:00
|
|
|
|
2020-03-01 19:53:05 +00:00
|
|
|
#ifndef LIBAARUFORMAT_DECLS_H
|
|
|
|
|
#define LIBAARUFORMAT_DECLS_H
|
2019-03-16 18:38:57 +00:00
|
|
|
|
2022-05-28 12:50:10 +01:00
|
|
|
#include "simd.h"
|
2022-05-28 11:49:33 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
#define EXTERNC extern "C"
|
|
|
|
|
#else
|
|
|
|
|
#define EXTERNC
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(_WIN32)
|
|
|
|
|
#define AARU_CALL __stdcall
|
|
|
|
|
#define AARU_EXPORT EXTERNC __declspec(dllexport)
|
|
|
|
|
#define AARU_LOCAL
|
|
|
|
|
#ifndef PATH_MAX
|
|
|
|
|
#define PATH_MAX _MAX_PATH
|
|
|
|
|
#endif
|
|
|
|
|
#else
|
|
|
|
|
#define AARU_CALL
|
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
|
#define AARU_EXPORT EXTERNC __attribute__((visibility("default")))
|
|
|
|
|
#define AARU_LOCAL __attribute__((visibility("hidden")))
|
|
|
|
|
#else
|
|
|
|
|
#if __GNUC__ >= 4
|
|
|
|
|
#define AARU_EXPORT EXTERNC __attribute__((visibility("default")))
|
|
|
|
|
#define AARU_LOCAL __attribute__((visibility("hidden")))
|
|
|
|
|
#else
|
|
|
|
|
#define AARU_EXPORT EXTERNC
|
|
|
|
|
#define AARU_LOCAL
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
2019-03-17 19:07:57 +00:00
|
|
|
|
2022-05-28 11:49:33 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
#define FORCE_INLINE static inline
|
|
|
|
|
#else
|
|
|
|
|
#define FORCE_INLINE static inline __attribute__((always_inline))
|
|
|
|
|
#endif
|
2019-03-17 19:07:57 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT int AARU_CALL aaruf_identify(const char* filename);
|
2019-03-17 20:39:40 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT int AARU_CALL aaruf_identify_stream(FILE* imageStream);
|
2019-03-17 20:39:40 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT void* AARU_CALL aaruf_open(const char* filepath);
|
2019-03-20 00:45:47 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT int AARU_CALL aaruf_close(void* context);
|
2019-03-20 23:41:16 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT int32_t AARU_CALL aaruf_read_media_tag(void* context, uint8_t* data, int32_t tag, uint32_t* length);
|
2019-03-20 23:41:16 +00:00
|
|
|
|
2022-05-28 12:50:10 +01:00
|
|
|
AARU_EXPORT crc64_ctx* AARU_CALL aaruf_crc64_init();
|
|
|
|
|
AARU_EXPORT int AARU_CALL aaruf_crc64_update(crc64_ctx* ctx, const uint8_t* data, uint32_t len);
|
|
|
|
|
AARU_EXPORT int AARU_CALL aaruf_crc64_final(crc64_ctx* ctx, uint64_t* crc);
|
|
|
|
|
AARU_EXPORT void AARU_CALL aaruf_crc64_free(crc64_ctx* ctx);
|
|
|
|
|
AARU_EXPORT void AARU_CALL aaruf_crc64_slicing(uint64_t* previous_crc, const uint8_t* data, uint32_t len);
|
|
|
|
|
AARU_EXPORT uint64_t AARU_CALL aaruf_crc64_data(const uint8_t* data, uint32_t len);
|
2019-03-23 22:02:28 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT int32_t AARU_CALL aaruf_read_sector(void* context, uint64_t sectorAddress, uint8_t* data, uint32_t* length);
|
2019-03-23 22:02:28 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT int32_t AARU_CALL aaruf_cst_transform(const uint8_t* interleaved, uint8_t* sequential, size_t length);
|
2019-03-23 22:59:36 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT int32_t AARU_CALL aaruf_cst_untransform(const uint8_t* sequential, uint8_t* interleaved, size_t length);
|
2019-03-23 22:59:36 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT void* AARU_CALL aaruf_ecc_cd_init();
|
2019-03-23 22:59:36 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT bool AARU_CALL aaruf_ecc_cd_is_suffix_correct(void* context, const uint8_t* sector);
|
2019-03-23 22:59:36 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT bool AARU_CALL aaruf_ecc_cd_is_suffix_correct_mode2(void* context, const uint8_t* sector);
|
2019-03-31 20:52:06 +01:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT bool AARU_CALL aaruf_ecc_cd_check(void* context,
|
2022-05-28 12:10:04 +01:00
|
|
|
const uint8_t* address,
|
|
|
|
|
const uint8_t* data,
|
|
|
|
|
uint32_t majorCount,
|
|
|
|
|
uint32_t minorCount,
|
|
|
|
|
uint32_t majorMult,
|
|
|
|
|
uint32_t minorInc,
|
|
|
|
|
const uint8_t* ecc,
|
|
|
|
|
int32_t addressOffset,
|
|
|
|
|
int32_t dataOffset,
|
|
|
|
|
int32_t eccOffset);
|
2019-03-23 22:59:36 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT void AARU_CALL aaruf_ecc_cd_write(void* context,
|
2022-05-28 12:10:04 +01:00
|
|
|
const uint8_t* address,
|
|
|
|
|
const uint8_t* data,
|
|
|
|
|
uint32_t majorCount,
|
|
|
|
|
uint32_t minorCount,
|
|
|
|
|
uint32_t majorMult,
|
|
|
|
|
uint32_t minorInc,
|
|
|
|
|
uint8_t* ecc,
|
|
|
|
|
int32_t addressOffset,
|
|
|
|
|
int32_t dataOffset,
|
|
|
|
|
int32_t eccOffset);
|
2019-03-23 22:59:36 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT void AARU_CALL aaruf_ecc_cd_write_sector(void* context,
|
2022-05-28 12:10:04 +01:00
|
|
|
const uint8_t* address,
|
|
|
|
|
const uint8_t* data,
|
|
|
|
|
uint8_t* ecc,
|
|
|
|
|
int32_t addressOffset,
|
|
|
|
|
int32_t dataOffset,
|
|
|
|
|
int32_t eccOffset);
|
2019-03-23 22:59:36 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_LOCAL void AARU_CALL aaruf_cd_lba_to_msf(int64_t pos, uint8_t* minute, uint8_t* second, uint8_t* frame);
|
2019-03-23 22:59:36 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT void AARU_CALL aaruf_ecc_cd_reconstruct_prefix(uint8_t* sector, uint8_t type, int64_t lba);
|
2019-03-23 22:59:36 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT void AARU_CALL aaruf_ecc_cd_reconstruct(void* context, uint8_t* sector, uint8_t type);
|
2019-03-23 23:31:04 +00:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_EXPORT uint32_t AARU_CALL aaruf_edc_cd_compute(void* context, uint32_t edc, const uint8_t* src, int size, int pos);
|
2019-03-31 20:30:27 +01:00
|
|
|
|
2022-05-28 11:49:33 +01:00
|
|
|
AARU_EXPORT int32_t AARU_CALL
|
2022-05-28 12:01:55 +01:00
|
|
|
aaruf_read_track_sector(void* context, uint8_t* data, uint64_t sectorAddress, uint32_t* length, uint8_t track);
|
2022-05-28 11:49:33 +01:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_LOCAL int32_t AARU_CALL aaruf_get_media_tag_type_for_datatype(int32_t type);
|
2022-05-28 11:49:33 +01:00
|
|
|
|
2022-05-28 12:01:55 +01:00
|
|
|
AARU_LOCAL int32_t AARU_CALL aaruf_get_xml_mediatype(int32_t type);
|
2019-03-31 15:37:07 +01:00
|
|
|
|
2022-05-28 12:31:54 +01:00
|
|
|
#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
|
|
|
|
|
defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86)
|
|
|
|
|
|
2022-05-28 12:50:10 +01:00
|
|
|
AARU_EXPORT int have_clmul();
|
|
|
|
|
AARU_EXPORT int have_ssse3();
|
|
|
|
|
AARU_EXPORT int have_avx2();
|
|
|
|
|
|
|
|
|
|
AARU_EXPORT CLMUL uint64_t AARU_CALL aaruf_crc64_clmul(uint64_t crc, const uint8_t* data, long length);
|
2022-05-28 12:31:54 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(__aarch64__) || defined(_M_ARM64) || defined(__arm__) || defined(_M_ARM)
|
2022-05-28 12:50:10 +01:00
|
|
|
AARU_EXPORT int have_neon();
|
|
|
|
|
AARU_EXPORT int have_arm_crc32();
|
|
|
|
|
AARU_EXPORT int have_arm_crypto();
|
|
|
|
|
|
|
|
|
|
AARU_EXPORT TARGET_WITH_SIMD uint64_t AARU_CALL crc64_vmull(uint64_t previous_crc, const uint8_t* data, long len);
|
2022-05-28 12:31:54 +01:00
|
|
|
#endif
|
|
|
|
|
|
2020-03-01 19:53:05 +00:00
|
|
|
#endif // LIBAARUFORMAT_DECLS_H
|