149 lines
4.7 KiB
C
149 lines
4.7 KiB
C
/* *****************************************************************************
|
|
* libp7/types.h -- types brought to you by libp7.
|
|
* Copyright (C) 2016-2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
|
|
*
|
|
* This file is part of libp7.
|
|
* libp7 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 3.0 of the License,
|
|
* or (at your option) any later version.
|
|
*
|
|
* libp7 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 libp7; if not, see <http://www.gnu.org/licenses/>.
|
|
* ************************************************************************** */
|
|
#ifndef LIBP7_TYPES_H
|
|
# define LIBP7_TYPES_H
|
|
# include <libp7/config.h>
|
|
# include <libg1m.h>
|
|
# if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) \
|
|
&& !defined(__WINDOWS__)
|
|
# define __WINDOWS__
|
|
# endif
|
|
|
|
/* Main includes */
|
|
# include <stdio.h>
|
|
# include <stdlib.h>
|
|
# include <stdint.h>
|
|
# include <inttypes.h>
|
|
# ifdef __cplusplus
|
|
extern "C" {
|
|
# endif
|
|
|
|
/* ************************************************************************** */
|
|
/* Integer types */
|
|
/* ************************************************************************** */
|
|
/* integer types */
|
|
# define PRIuP7SHORT PRIuFAST16
|
|
# define PRIxP7SHORT PRIxFAST16
|
|
typedef uint_fast16_t p7ushort_t;
|
|
# define PRIuP7INT PRIuFAST32
|
|
# define PRIxP7INT PRIxFAST32
|
|
typedef uint_fast32_t p7uint_t;
|
|
|
|
/* Size_t-related printf format */
|
|
# ifndef PRIuSIZE
|
|
# if defined(_WIN64)
|
|
# define PRIuSIZE "l64u"
|
|
# elif defined(_WIN32)
|
|
# define PRIuSIZE "u"
|
|
# else
|
|
# define PRIuSIZE "zu"
|
|
# endif
|
|
# endif
|
|
|
|
/* ************************************************************************** */
|
|
/* Handles - these are actually private */
|
|
/* ************************************************************************** */
|
|
struct p7_handle_s;
|
|
typedef struct p7_handle_s p7_handle_t;
|
|
extern const size_t p7_handle_size;
|
|
|
|
/* ************************************************************************** */
|
|
/* Callbacks */
|
|
/* ************************************************************************** */
|
|
/* Display callback */
|
|
typedef void (*p7_disp_t)(p7ushort_t, p7ushort_t);
|
|
|
|
/* Confirmation callback */
|
|
typedef int (*p7_confirm_t)(void);
|
|
|
|
/* List callback */
|
|
typedef void (*p7_list_t)(void*, const char*, const char*, p7uint_t);
|
|
|
|
/* ************************************************************************** */
|
|
/* Useful types */
|
|
/* ************************************************************************** */
|
|
/* Version (xx.xx.xxxx) */
|
|
typedef struct {
|
|
unsigned int major;
|
|
unsigned int minor;
|
|
unsigned int rev;
|
|
} p7_version_t;
|
|
|
|
/* CASIOWIN entry - the OS entry the bootcode reads to run it */
|
|
typedef struct {
|
|
/* version */
|
|
p7_version_t version;
|
|
|
|
/* syscall table address */
|
|
p7uint_t syscall_table_offset;
|
|
} p7_casiowin_entry_t;
|
|
|
|
/* ************************************************************************** */
|
|
/* Server information */
|
|
/* ************************************************************************** */
|
|
/* Main structure */
|
|
typedef struct {
|
|
/* main information */
|
|
char product_id[17], username[17];
|
|
char hwid[9], cpuid[17];
|
|
|
|
/* preprogrammed ROM info */
|
|
int preprog_rom_wiped;
|
|
p7uint_t preprog_rom_capacity;
|
|
p7_version_t preprog_rom_version;
|
|
|
|
/* flash ROM and RAM info */
|
|
p7uint_t flash_rom_capacity, ram_capacity;
|
|
|
|
/* bootcode info */
|
|
int bootcode_wiped;
|
|
p7_version_t bootcode_version;
|
|
p7uint_t bootcode_offset, bootcode_size;
|
|
|
|
/* OS information */
|
|
int os_wiped;
|
|
p7_version_t os_version;
|
|
p7uint_t os_offset, os_size;
|
|
|
|
/* addresses - for serving */
|
|
const unsigned char *flash_rom, *ram;
|
|
const unsigned char *casiowin_entry, *bootcode;
|
|
} p7_server_t;
|
|
|
|
/* Functions */
|
|
typedef struct {
|
|
/* filesystem name */
|
|
const char *name;
|
|
|
|
/* directory commands */
|
|
int (*directory_exists)(const char *dirname);
|
|
int (*create_directory)(const char *dirname);
|
|
int (*delete_directory)(const char *dirname);
|
|
int (*rename_directory)(const char *dirname, const char *newdir);
|
|
|
|
/* things that should only be manipulated by libp7 */
|
|
char *working_directory, _wd[257];
|
|
} p7_filesystem_t;
|
|
|
|
# ifdef __cplusplus
|
|
}
|
|
# endif
|
|
# include <libp7/buffer.h>
|
|
#endif /* LIBP7_TYPES_H */
|