From 99d99cba4ead704a0c77310ed167bfd42a29746c Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 31 Oct 2020 19:29:36 +1100 Subject: [PATCH] implemented userspace reset utility --- userspace/vendor-reset | Bin 17496 -> 21456 bytes userspace/vendor-reset.c | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/userspace/vendor-reset b/userspace/vendor-reset index b6f57c7eaebc1094fe66b9d093ae6b1df158749e..a90b65f8e6500ec4d131977add1c23070dcdec50 100755 GIT binary patch literal 21456 zcmeHPeQ;dWb-!<)cHip5D_Qb~WMi`!Q)IAKvayY9Y_luN_KFHywk2XGHjmZrN?KU$ zYWBm}FeJtf45}k)+S0(3f*Y6whJ=zdGz@gWuI*4#lH#Q4xM>*-;}ko5)ELq+rJ(-K zefO;1KCNgwo#`K)y_)yVJ-_pD?>+B6?Y-~5`@XimdxJ~U1Segr6~rB`vyh+?ynchq zfCNRmsK$ArxLkO^S4hl~2Q31rm4;l!)T?kElaP$RySqBpnM(sp1IvZk)qA4}&+)-T zHW$zI-ncHAPQ`m8{YmmMIGj!?AEu>RQc+gig`Pow)I%mH^$$(-0OkIipOdI0oiAI> zE!^ka?tRlO!FhEbGagiUPtcMx&itwCEu8uyT^mlPZ8+bHBs*)v?f2z*8(zguKrh;G z>f@aFy3zki>i3))gI3M}p{Q{32dy08bU$%w4q7?F<^NqJXtUuYw)30_6ylBT$Y&IRfPf{4XOAKJcD5e9-*{#`EEOj^te9uZIsD_Z};F z9bf)7MB`VS!MXO*AacYHk^J20ailALMLZ2r&%G}BpA%0*#B)a^{}bYAXn5{f$^SL+ zG;}?8Sn@9rPea6Wha}$*e&7&znU=iYHG1;q@aWs&182_n^mdQASHX99Y}zkSWO!`N zQD}|NoCTYYYcK7T(A{9dW9~bMth|_;iROI}KpxGj96w!q={|CNOi{SlBK4QwKxEP9 z;nDNqqaR!!K6+6PYd;R3{5&@U4o)Zs-tp4|vK+SGx8^d~iF|8c_`sTP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O{yTb|GRF*dy_`D1Ux|KK8gW3xl#KdaoqU)C1M_qX$L$>;mq9l&=>+`DeOPi%2C uT@GB0RL&CpiE+ix7xX*2BOPV@~FBvX7UttA@sAKB>;`h5hSD*gk*hCP1( diff --git a/userspace/vendor-reset.c b/userspace/vendor-reset.c index ec9ef50..0ea500e 100644 --- a/userspace/vendor-reset.c +++ b/userspace/vendor-reset.c @@ -16,7 +16,53 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "../include/vendor-reset.h" +#include +#include +#include +#include +#include + int main(int argc, char * argv[]) { + int ret; + + if (argc < 4) + { + fprintf(stderr, + "Usage:\n" + " %s \n", + argv[0] + ); + return -1; + } + + int domain = atoi(argv[1]); + int bus = atoi(argv[2]); + int devfn = atoi(argv[3]); + + int fd = open("/dev/vendor_reset", O_RDWR); + if (fd < 0) + { + perror("open"); + return fd; + } + + struct vendor_reset_ioctl dev = + { + .domain = domain, + .bus = bus, + .devfn = devfn + }; + + ret = ioctl(fd, VENDOR_RESET_RESET, &dev); + if (ret < 0) + { + perror("ioctl"); + goto err; + } + +err: + close(fd); return 0; }