summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-04-24 07:14:13 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-04-24 07:14:13 +0200
commit33fcf6f036ceb43e6766a3c3dceea7b31db38b69 (patch)
treeaba69d9d362a68ef10b57d07eefa87cab0b6a9bd /lib
parent6d8d4718dea52236e8c5e8284bc6edad7c589ab8 (diff)
dev, lib: 30pin protocol added, fix bootnet header too.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/30pin.h27
-rw-r--r--lib/bootnet.h18
2 files changed, 33 insertions, 12 deletions
diff --git a/lib/30pin.h b/lib/30pin.h
index 71d998d..d4f0de9 100644
--- a/lib/30pin.h
+++ b/lib/30pin.h
@@ -8,7 +8,15 @@
#include <lib/boot.h>
-/// @note This version is for the 30-pin recovery system.
+/// @file 30pin.h
+/// @brief 30pin recovery protocol.
+/// @details This file contains the definitions and structures used for the 30pin recovery protocol.
+
+#define CB_30PIN_MAG "TP"
+#define CP_30PIN_MAG_LEN (2)
+
+#define CB_30PIN_BUFFER_LEN (498)
+#define CB_30PIN_EOP_LEN (11)
/// @brief 30pin recovery header.
/// @param mag magic number.
@@ -17,10 +25,21 @@
/// @param eop end of packet data.
struct _cb_tpin_recovery_packet
{
- uint8_t mag[2];
+ uint8_t mag[CP_30PIN_MAG_LEN];
uint8_t kind;
- uint8_t buffer[498];
- uint8_t eop[11];
+ uint8_t buffer[CB_30PIN_BUFFER_LEN];
+ uint8_t eop[CB_30PIN_EOP_LEN];
+};
+
+/// @brief 30pin recovery packet kinds.
+enum
+{
+ TPIN_RECOVERY_PACKET_KIND_UNKNOWN = 0,
+ TPIN_RECOVERY_PACKET_KIND_BOOT = 1,
+ TPIN_RECOVERY_PACKET_KIND_DATA = 2,
+ TPIN_RECOVERY_PACKET_KIND_EOP = 3,
+ TPIN_RECOVERY_PACKET_KIND_EOP_ACK = 4,
+ TPIN_RECOVERY_PACKET_KIND_EOP_NACK = 5,
};
typedef struct _cb_tpin_recovery_packet cb_tpin_recovery_packet_t; \ No newline at end of file
diff --git a/lib/bootnet.h b/lib/bootnet.h
index 3ce6763..81e0981 100644
--- a/lib/bootnet.h
+++ b/lib/bootnet.h
@@ -9,22 +9,24 @@
#include <lib/boot.h>
#define BOOTNET_INET_MAGIC "NETB"
-#define BOOTNET_INET_MAGIC_LEN 4
+#define BOOTNET_INET_MAGIC_LEN (4)
+
+#define BOOTNET_NAME_LEN (256)
/// @brief Netboot Internet Header
/// Consists of 4 magic characters, and a set of fields describing the current patch that's being sent (if m_preflight = 0)
/// @note Can be used to patch ROMs too (if m_implies_rom = 1)
typedef struct bootnet_inet_header
{
- char m_nb1; /// magic char 1 'N'
- char m_nb2; /// magic char 2 'E'
- char m_nb3; /// magic char 3 'T'
- char m_nb4; /// magic char 4 'B'
+ ascii_char_t m_nb1; /// magic char 1 'N'
+ ascii_char_t m_nb2; /// magic char 2 'E'
+ ascii_char_t m_nb3; /// magic char 3 'T'
+ ascii_char_t m_nb4; /// magic char 4 'B'
- char m_patch_name[255]; /// example: ColdChoco
+ ascii_char_t m_patch_name[BOOTNET_NAME_LEN]; /// example: ColdChoco
int32_t m_length; /// The patch's length.
- char m_target[255]; /// The target file.
- uint8_t m_implies_rom; /// does it imply an EEPROM program?
+ ascii_char_t m_target[BOOTNET_NAME_LEN]; /// The target file.
+ uint8_t m_implies_program; /// does it imply reprogramming?
uint8_t m_preflight; /// Do we just check if this endpoint exists/is valid?
uint8_t m_blob[];
} bootnet_inet_header;