cake
/
libp7
Archived
1
0
Fork 1
This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
libp7/include/libp7/protocol/seven/commands.h

160 lines
6.7 KiB
C

/* *****************************************************************************
* libp7/protocol/seven/commands.h -- Protocol 7.00 classical commands.
* 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_PROTOCOL_SEVEN_COMMANDS_H
# define LIBP7_PROTOCOL_SEVEN_COMMANDS_H
# include <libp7/protocol/seven.h>
/* Simple command format */
# define p7_sevencmd(C, CODE) \
static inline int p7_seven_send_cmd##C(p7_handle_t *handle) { \
return (p7_seven_send_cmd(handle, CODE)); }
/* ************************************************************************** */
/* Main Memory command formats */
/* ************************************************************************** */
/* Interact with an MCS file */
# define p7_sevencmd_mcsfile(C, CODE) \
static inline int p7_send_cmd##C(p7_handle_t *handle, \
const g1m_mcshead_t *head) { \
return (p7_seven_send_cmd_data(handle, CODE, 0, head->_rawtype, 0, \
(char*)head->_dirname, (char*)head->name, (char*)head->_group, \
NULL, NULL, NULL)); }
/* ************************************************************************** */
/* Storage command formats */
/* ************************************************************************** */
/* Interact with a storage device */
# define p7_sevencmd_dev(C, CODE) \
static inline int p7_seven_send_cmd##C(p7_handle_t *handle, \
const char *devname) { \
return (p7_seven_send_cmd_data(handle, CODE, 0, 0, 0, \
NULL, NULL, NULL, NULL, devname, NULL)); }
/* Interact with a storage directory */
# define p7_sevencmd_dir(C, CODE) \
static inline int p7_seven_send_cmd##C(p7_handle_t *handle, \
const char *dirname, const char *devname) { \
return (p7_seven_send_cmd_data(handle, CODE, 0, 0, 0, \
dirname, NULL, NULL, NULL, devname, NULL)); }
/* Rename a storage directory */
# define p7_sevencmd_rendir(C, CODE) \
static inline int p7_seven_send_cmd##C(p7_handle_t *handle, \
const char *dirname, const char *newdir, const char *devname) { \
return (p7_seven_send_cmd_data(handle, CODE, 0, 0, 0, \
dirname, newdir, NULL, NULL, devname, NULL)); }
/* Interact with a storage file */
# define p7_sevencmd_file(C, CODE) \
static inline int p7_seven_send_cmd##C(p7_handle_t *handle, \
const char *dirname, const char *filename, const char *devname) { \
return (p7_seven_send_cmd_data(handle, CODE, 0, 0, 0, \
dirname, filename, NULL, NULL, devname, NULL)); }
/* Send a file to storage memory */
# define p7_sevencmd_send(C, CODE) \
static inline int p7_seven_send_cmd##C(p7_handle_t *handle, \
int ow, p7uint_t fs, \
const char *dirname, const char *filename, const char *devname) { \
return (p7_seven_send_cmd_data(handle, CODE, ow, 0, fs, \
dirname, filename, NULL, NULL, devname, NULL)); }
/* Copy a file on storage memory */
# define p7_sevencmd_copy(C, CODE) \
static inline int p7_seven_send_cmd##C(p7_handle_t *handle, \
const char *dirname, const char *filename, \
const char *newdir, const char *newname, const char *devname) { \
return (p7_seven_send_cmd_data(handle, CODE, 0, 0, 0, \
dirname, filename, newdir, newname, devname, NULL)); }
/* Rename a file on storage memory */
# define p7_sevencmd_rename(C, CODE) \
static inline int p7_seven_send_cmd##C(p7_handle_t *handle, \
const char *dirname, const char *filename, \
const char *newname, const char *devname) { \
return (p7_seven_send_cmd_data(handle, CODE, 0, 0, 0, \
dirname, filename, NULL, newname, devname, NULL)); }
/* ************************************************************************** */
/* Known commands */
/* ************************************************************************** */
/* Basic commands */
# define p7_seven_cmdsys_getinfo 0x01
p7_sevencmd(sys_getinfo, 0x01)
/* Backup commands */
# define p7_seven_cmdbak_reqram 0x2F
p7_sevencmd(bak_reqram, 0x2F)
# define p7_seven_cmdbak_putram 0x30
p7_sevencmd(bak_putram, 0x30)
# define p7_seven_cmdbak_reqrom 0x4F
p7_sevencmd(bak_reqrom, 0x4F)
# define p7_seven_cmdbak_putrom 0x50
p7_sevencmd(bak_putrom, 0x50)
# define p7_seven_cmdbak_reqcwe 0x52
p7_sevencmd(bak_reqcwe, 0x52)
# define p7_seven_cmdbak_putcwe 0x53
p7_sevencmd(bak_putcwe, 0x53)
# define p7_seven_cmdbak_reqboot 0x54
p7_sevencmd(bak_reqboot, 0x54)
# define p7_seven_cmdbak_putboot 0x55
p7_sevencmd(bak_putboot, 0x55)
/* Main memory commands */
# define p7_seven_cmdmcs_reqfile 0x24
p7_sevencmd_mcsfile(mcs_reqfile, 0x24)
# define p7_seven_cmdmcs_reqallinfo 0x2D
p7_sevencmd(mcs_reqallinfo, 0x2D)
/* Storage commands */
# define p7_seven_cmdfls_mkdir 0x40
p7_sevencmd_dir(fls_mkdir, 0x40)
# define p7_seven_cmdfls_rmdir 0x41
p7_sevencmd_dir(fls_rmdir, 0x41)
# define p7_seven_cmdfls_mvdir 0x42
p7_sevencmd_dir(fls_mvdir, 0x42)
# define p7_seven_cmdfls_cwd 0x43
p7_sevencmd_dir(fls_cwd, 0x43)
# define p7_seven_cmdfls_reqfile 0x44
p7_sevencmd_file(fls_reqfile, 0x44)
# define p7_seven_cmdfls_sendfile 0x45
p7_sevencmd_send(fls_sendfile, 0x45)
# define p7_seven_cmdfls_delfile 0x46
p7_sevencmd_file(fls_delfile, 0x46)
# define p7_seven_cmdfls_renamefile 0x47
p7_sevencmd_rename(fls_renamefile, 0x47)
# define p7_seven_cmdfls_copyfile 0x48
p7_sevencmd_copy(fls_copyfile, 0x48)
# define p7_seven_cmdfls_reset 0x4A
p7_sevencmd_dev(fls_reset, 0x4A)
# define p7_seven_cmdfls_reqcapacity 0x4B
p7_sevencmd_dev(fls_reqcapacity, 0x4B)
# define p7_seven_cmdfls_reqallinfo 0x4D
p7_sevencmd_dev(fls_reqallinfo, 0x4D)
# define p7_seven_cmdfls_opt 0x51
p7_sevencmd_dev(fls_opt, 0x51)
/* Special commands */
# define p7_seven_cmdsys_setlink 0x02
extern int p7_seven_send_cmdsys_setlink(p7_handle_t *handle,
int baudrate, int parity, int stopbits);
# define p7_seven_cmdosu_upandrun 0x56
extern int p7_seven_send_cmdosu_upandrun(p7_handle_t *handle,
p7uint_t upsize, p7uint_t loadaddr, p7uint_t straddr);
#endif /* LIBP7_PROTOCOL_SEVEN_COMMANDS_H */