mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 19:10:14 +01:00
freedreno/afuc: Replace readfile with os_read_file.
Tested afuc-disasm produced same output. $ ./builddir/src/freedreno/afuc/afuc-disasm -g 6 src/freedreno/.gitlab-ci/reference/afuc_test.fw > /tmp/afuc_test.asm $ diff ./src/freedreno/.gitlab-ci/reference/afuc_test.asm /tmp/afuc_test.asm $ echo $? 0 Suggested-by: Rob Clark <robdclark@chromium.org> Signed-off-by: Vinson Lee <vlee@freedesktop.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8290>
This commit is contained in:
parent
18a0f07957
commit
03999595e7
1 changed files with 5 additions and 32 deletions
|
|
@ -33,6 +33,8 @@
|
|||
#include <assert.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "util/os_file.h"
|
||||
|
||||
#include "afuc.h"
|
||||
#include "rnn.h"
|
||||
#include "rnndec.h"
|
||||
|
|
@ -773,36 +775,6 @@ static void disasm(uint32_t *buf, int sizedwords)
|
|||
}
|
||||
}
|
||||
|
||||
#define CHUNKSIZE 4096
|
||||
|
||||
static char * readfile(const char *path, int *sz)
|
||||
{
|
||||
char *buf = NULL;
|
||||
int fd, ret, n = 0;
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
*sz = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
buf = realloc(buf, n + CHUNKSIZE);
|
||||
ret = read(fd, buf + n, CHUNKSIZE);
|
||||
if (ret < 0) {
|
||||
free(buf);
|
||||
*sz = 0;
|
||||
return NULL;
|
||||
} else if (ret < CHUNKSIZE) {
|
||||
n += ret;
|
||||
*sz = n;
|
||||
return buf;
|
||||
} else {
|
||||
n += CHUNKSIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n"
|
||||
|
|
@ -819,7 +791,8 @@ int main(int argc, char **argv)
|
|||
uint32_t *buf;
|
||||
char *file, *control_reg_name;
|
||||
bool colors = false;
|
||||
int sz, c;
|
||||
size_t sz;
|
||||
int c;
|
||||
|
||||
/* Argument parsing: */
|
||||
while ((c = getopt (argc, argv, "g:vc")) != -1) {
|
||||
|
|
@ -886,7 +859,7 @@ int main(int argc, char **argv)
|
|||
|
||||
rnndec_varadd(ctx, "chip", variant);
|
||||
|
||||
buf = (uint32_t *)readfile(file, &sz);
|
||||
buf = (uint32_t *)os_read_file(file, &sz);
|
||||
|
||||
printf("; Disassembling microcode: %s\n", file);
|
||||
printf("; Version: %08x\n\n", buf[1]);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue