1
0
Fork 0
mirror of https://github.com/eliboa/TegraRcmGUI.git synced 2024-11-28 13:12:05 +00:00
TegraRcmGUI/kourou/kourou.h

80 lines
2.7 KiB
C
Raw Permalink Normal View History

2020-06-24 19:31:54 +01:00
/*
* Copyright (c) 2020 eliboa
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
2020-12-11 11:46:53 +00:00
* Kourou class is derived from RcmDevice class
* Provides additionnal functions to communicate with device with Ariane (backend payload based program)
2020-06-24 19:31:54 +01:00
*/
2020-06-24 19:30:39 +01:00
#ifndef KOUROU_H
#define KOUROU_H
2020-06-24 19:31:54 +01:00
#include "libs/rcm_device.h"
#include "usb_command.h"
typedef enum _KRESULT : DWORD
{
2020-12-11 11:46:53 +00:00
RCM_REBOOT_FAILED = 0x100,
ARIANE_NOT_READY = 0x101,
WRONG_PARAM_GENERIC = 0x102,
FAILED_TO_SET_AUTORCM = 0x103,
FAILED_TO_MKDIR = 0x104,
SD_FILE_WRITE_FAILED = 0x105
2020-06-24 19:30:39 +01:00
2020-06-24 19:31:54 +01:00
} KRESULT;
2020-06-24 19:30:39 +01:00
2020-06-24 19:31:54 +01:00
class Kourou : public RcmDevice
2020-06-24 19:30:39 +01:00
{
public:
Kourou();
2020-06-24 19:31:54 +01:00
bool initDevice(KLST_DEVINFO_HANDLE deviceInfo = nullptr);
2020-12-11 11:46:53 +00:00
int hack(const char* payload_path);
int hack(u8 *payload_buff, u32 buff_size);
2020-06-24 19:31:54 +01:00
void disconnect();
2020-12-11 11:46:53 +00:00
bool readResponse(void* buffer, u32 size);
bool sendResponse(void* buffer, u32 size);
u32 sdmmc_fileSize(const char* path);
bool sdmmc_isDir(const char* path);
bool sdmmc_mkDir(const char* path);
bool sdmmc_mkPath(const char* path);
int sdmmc_readFile(const char* path, u8 *buffer, u32 size, u32 *bytesRead);
int sdmmc_readFile(const char* path, Bytes *dest, u32 *bytesRead = nullptr);
int sdmmc_writeFile(const char* in_path, const char* out_path, bool create_always = false);
int sdmmc_writeFile(Bytes *in_bytes, const char *out_path, bool create_always = false);
int pushPayload(const char* path);
int getDeviceInfo(UC_DeviceInfo* di);
2020-06-24 19:31:54 +01:00
bool arianeIsReady() { return m_ariane_ready; }
bool rcmIsReady() { return m_rcm_ready; }
void setRcmReady(bool b) { m_rcm_ready = b; }
2020-12-11 11:46:53 +00:00
bool arianeIsReady_sync(bool skip_rcm = false);
2020-06-24 19:31:54 +01:00
void setArianeReady(bool b) { m_ariane_ready = b; }
bool rebootToRcm();
bool setAutoRcmEnabled(bool state);
2020-12-11 11:46:53 +00:00
bool isReadyToReceivePayload() { return (m_rcm_ready || m_ariane_ready); }
bool isDeviceInfoAvailable() { return m_di_set; }
UC_DeviceInfo deviceInfo() { return m_di; }
2020-06-24 19:31:54 +01:00
2020-12-11 11:46:53 +00:00
private:
2020-06-24 19:31:54 +01:00
bool m_ariane_ready = false;
bool m_rcm_ready = false;
2020-12-11 11:46:53 +00:00
UC_DeviceInfo m_di;
bool m_di_set = false;
int sendBinPackets(char* buffer, u32 len);
2020-06-24 19:30:39 +01:00
};
#endif // KOUROU_H