Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ch32v003fun
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Horn
ch32v003fun
Commits
519e8b66
Commit
519e8b66
authored
1 year ago
by
cnlohr
Browse files
Options
Downloads
Patches
Plain Diff
Move .xw to header + fix compilation of b003fun
parent
42499c0b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ch32v003fun/ch32v003fun.h
+62
-0
62 additions, 0 deletions
ch32v003fun/ch32v003fun.h
minichlink/pgm-b003fun.c
+5
-2
5 additions, 2 deletions
minichlink/pgm-b003fun.c
with
67 additions
and
2 deletions
ch32v003fun/ch32v003fun.h
+
62
−
0
View file @
519e8b66
...
...
@@ -5082,6 +5082,68 @@ int _write(int fd, const char *buf, int size);
#endif
// xw_ext.inc, thanks to @macyler, @jnk0le, @duk for this reverse engineering.
/*
Encoder for some of the proprietary 'XW' RISC-V instructions present on the QingKe RV32 processor.
Examples:
XW_C_LBU(a3, a1, 27); // c.xw.lbu a3, 27(a1)
XW_C_SB(a0, s0, 13); // c.xw.sb a0, 13(s0)
XW_C_LHU(a5, a5, 38); // c.xw.lhu a5, 38(a5)
XW_C_SH(a2, s1, 14); // c.xw.sh a2, 14(s1)
*/
// Let us do some compile-time error checking.
#define ASM_ASSERT(COND) .if (!(COND)); .err; .endif
// Integer encodings of the possible compressed registers.
#define C_s0 0
#define C_s1 1
#define C_a0 2
#define C_a1 3
#define C_a2 4
#define C_a3 5
#define C_a4 6
#define C_a5 7
// register to encoding
#define REG2I(X) (C_ ## X)
// XW opcodes
#define XW_OP_LBUSP 0b1000000000000000
#define XW_OP_STSP 0b1000000001000000
#define XW_OP_LHUSP 0b1000000000100000
#define XW_OP_SHSP 0b1000000001100000
#define XW_OP_LBU 0b0010000000000000
#define XW_OP_SB 0b1010000000000000
#define XW_OP_LHU 0b0010000000000010
#define XW_OP_SH 0b1010000000000010
// The two different XW encodings supported at the moment.
#define XW_ENCODE1(OP, R1, R2, IMM) ASM_ASSERT((IMM) >= 0 && (IMM) < 32); .2byte ((OP) | (REG2I(R1) << 2) | (REG2I(R2) << 7) | \
(((IMM) & 0b1) << 12) | (((IMM) & 0b110) << (5 - 1)) | (((IMM) & 0b11000) << (10 - 3)))
#define XW_ENCODE2(OP, R1, R2, IMM) ASM_ASSERT((IMM) >= 0 && (IMM) < 32); .2byte ((OP) | (REG2I(R1) << 2) | (REG2I(R2) << 7) | \
(((IMM) & 0b11) << 5) | (((IMM) & 0b11100) << (10 - 2))
// Compressed load byte, zero-extend result
#define XW_C_LBU(RD, RS, IMM) XW_ENCODE1(XW_OP_LBU, RD, RS, IMM)
// Compressed store byte
#define XW_C_SB(RS1, RS2, IMM) XW_ENCODE1(XW_OP_SB, RS1, RS2, IMM)
// Compressed load half, zero-extend result
#define XW_C_LHU(RD, RS, IMM) ASM_ASSERT(((IMM) & 1) == 0); XW_ENCODE2(XW_OP_LHU, RD, RS, ((IMM) >> 1)))
// Compressed store half
#define XW_C_SH(RS1, RS2, IMM) ASM_ASSERT(((IMM) & 1) == 0); XW_ENCODE2(XW_OP_SH, RS1, RS2, ((IMM) >> 1)))
#ifdef __cplusplus
};
#endif
...
...
This diff is collapsed.
Click to expand it.
minichlink/pgm-b003fun.c
+
5
−
2
View file @
519e8b66
#if 0
#include <stdint.h>
#include "hidapi.h"
#include "minichlink.h"
...
...
@@ -103,7 +104,7 @@ static void CommitOp( struct B003FunProgrammerStruct * eps )
void
*
TryInit_
ESP32S2CHFUN
()
void * TryInit_
B003Fun
()
{
#define VID 0x1209
#define PID 0xb003
...
...
@@ -144,4 +145,6 @@ void * TryInit_ESP32S2CHFUN()
return eps;
}
#else
void
*
TryInit_B003Fun
()
{
return
0
;
}
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment