...
 
Commits (4)
......@@ -29,7 +29,7 @@ endif
m_dep = cc.find_library('m', required: true)
dl_dep = cc.find_library('dl', required: false)
pthread_dep = cc.find_library('pthread', required: false)
pthread_dep = dependency('threads')
spd_dep = dependency('ShaderProgramDisassembler', required: true)
common_dep = [
......
......@@ -147,7 +147,7 @@ static inline char *panwrap_decode_fbd_type(enum mali_fbd_type type)
}
static bool
panwrap_deduplicate(struct panwrap_mapped_memory *mem, uint64_t gpu_va, const char *name, int number)
panwrap_deduplicate(const struct panwrap_mapped_memory *mem, uint64_t gpu_va, const char *name, int number)
{
if (mem->touched[(gpu_va - mem->gpu_va) / sizeof(uint32_t)]) {
/* XXX: Is this correct? */
......@@ -306,7 +306,7 @@ void panwrap_replay_attributes(const struct panwrap_mapped_memory *mem,
panwrap_indent++;
int flags = attr[i].elements & 3;
panwrap_prop("elements = (%s_%d_p) | %d", base, i, attr[i].elements & 3);
panwrap_prop("elements = (%s_%d_p) | %d", base, i, (int) attr[i].elements & 3);
panwrap_prop("stride = 0x%" PRIx32, attr[i].stride);
panwrap_prop("size = 0x%" PRIx32, attr[i].size);
......@@ -333,8 +333,24 @@ panwrap_replay_shader_address(const char *name, mali_ptr ptr)
return shader_ptr;
}
static int panwrap_replay_fragment_job_bfr(const struct panwrap_mapped_memory *mem,
mali_ptr payload, int job_no)
{
const uint8_t *PANWRAP_PTR_VAR(s, mem, payload);
panwrap_log_hexdump(s, sizeof(struct mali_payload_fragment));
}
static int
panwrap_replay_vertex_or_tiler_job(const struct mali_job_descriptor_header *h,
panwrap_replay_vertex_or_tiler_job_bfr(const struct mali_job_descriptor_header *h,
const struct panwrap_mapped_memory *mem,
mali_ptr payload, int job_no)
{
const uint8_t *PANWRAP_PTR_VAR(v, mem, payload);
panwrap_log_hexdump(v, sizeof(struct mali_payload_vertex_tiler));
}
static int
panwrap_replay_vertex_or_tiler_job_mdg(const struct mali_job_descriptor_header *h,
const struct panwrap_mapped_memory *mem,
mali_ptr payload, int job_no)
{
......@@ -729,7 +745,7 @@ panwrap_replay_vertex_or_tiler_job(const struct mali_job_descriptor_header *h,
panwrap_prop("flags = %d", v->flags);
if (v->unknown6)
panwrap_prop("unknown6 = (unknown6_%d_p) | 0x%X", job_no, v->unknown6 & 0xF);
panwrap_prop("unknown6 = (unknown6_%d_p) | 0x%zX", job_no, v->unknown6 & 0xF);
panwrap_indent--;
panwrap_log("};\n");
......@@ -796,7 +812,7 @@ static int panwrap_replay_fragment_job(const struct panwrap_mapped_memory *mem,
static int job_descriptor_number = 0;
int panwrap_replay_jc(mali_ptr jc_gpu_va)
int panwrap_replay_jc(mali_ptr jc_gpu_va, bool bifrost)
{
struct mali_job_descriptor_header *h;
......@@ -887,7 +903,10 @@ int panwrap_replay_jc(mali_ptr jc_gpu_va)
}
case JOB_TYPE_TILER:
case JOB_TYPE_VERTEX:
payload_size = panwrap_replay_vertex_or_tiler_job(h, mem, payload_ptr, job_no);
if (bifrost)
payload_size = panwrap_replay_vertex_or_tiler_job_bfr(h, mem, payload_ptr, job_no);
else
payload_size = panwrap_replay_vertex_or_tiler_job_mdg(h, mem, payload_ptr, job_no);
break;
case JOB_TYPE_FRAGMENT:
......
......@@ -19,7 +19,7 @@
#include <mali-job.h>
#include "panwrap.h"
int panwrap_replay_jc(mali_ptr jc_gpu_va);
int panwrap_replay_jc(mali_ptr jc_gpu_va, bool bifrost);
int panwrap_replay_soft_replay(mali_ptr jc_gpu_va);
#endif /* !PANWRAP_DECODER_H */
......@@ -100,7 +100,7 @@ void replay_memory()
fclose(fp);
panwrap_log("// FILE *f_%s = fopen(\"%s\", \"rb\");\n", pos->name, filename);
panwrap_log("// fread(%s, 1, %d, f_%s);\n", pos->name, pos->length, pos->name);
panwrap_log("// fread(%s, 1, %zd, f_%s);\n", pos->name, pos->length, pos->name);
panwrap_log("// fclose(f_%s);\n", pos->name);
} else {
/* Fill it with dumped memory, skipping zeroes */
......@@ -193,7 +193,7 @@ void panwrap_track_mmap(mali_ptr gpu_va, void *addr, size_t length,
/* Map region itself */
panwrap_log("uint32_t *%s = mmap64(NULL, %d, %d, %d, fd, alloc_gpu_va_%d);\n\n",
panwrap_log("uint32_t *%s = mmap64(NULL, %zd, %d, %d, fd, alloc_gpu_va_%d);\n\n",
mapped_mem->name, length, prot, flags, mapped_mem->allocation_number);
panwrap_log("if (%s == MAP_FAILED) printf(\"Error mapping %s\\n\");\n\n",
......@@ -340,7 +340,7 @@ __panwrap_fetch_mem_err(const struct panwrap_mapped_memory *mem,
struct panwrap_mapped_memory *pos;
list_for_each_entry(pos, &mmaps, node) {
panwrap_msg("%llx (%p)\n", pos->gpu_va, pos->addr);
panwrap_msg(MALI_PTR_FMT " (%p)\n", pos->gpu_va, pos->addr);
}
}
......
......@@ -46,12 +46,12 @@ struct panwrap_mapped_memory {
};
#define TOUCH_MEMSET(mem, addr, sz, offset) \
memset(mem->touched + ((addr - mem->gpu_va) / sizeof(uint32_t)), 1, (sz - offset) / sizeof(uint32_t)); \
memset((mem)->touched + (((addr) - (mem)->gpu_va) / sizeof(uint32_t)), 1, ((sz) - (offset)) / sizeof(uint32_t)); \
panwrap_log("\n");
#define TOUCH_LEN(mem, addr, sz, ename, number, dyn) \
TOUCH_MEMSET(mem, addr, sz, 0) \
panwrap_log("mali_ptr %s_%d_p = pandev_upload(%d, alloc_gpu_va_%d, %s, &%s_%d, sizeof(%s_%d), false);\n\n", ename, number, dyn ? -1 : (int) ((addr - mem->gpu_va)), mem->allocation_number, mem->name, ename, number, ename, number);
panwrap_log("mali_ptr %s_%d_p = pandev_upload(%d, alloc_gpu_va_%d, %s, &%s_%d, sizeof(%s_%d), false);\n\n", ename, number, (dyn) ? -1 : (int) (((addr) - (mem)->gpu_va)), (mem)->allocation_number, (mem)->name, ename, number, ename, number);
/* Job payloads are touched somewhat different than other structures, due to the
* variable lengths and odd packing requirements */
......
......@@ -48,7 +48,7 @@ panwrap_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type)
/* ...but reassemble at runtime! */
panwrap_log("pandev_shader_%s(%s + %d, shader_src_%d, %d);\n\n",
panwrap_log("pandev_shader_%s(%s + %zd, shader_src_%d, %d);\n\n",
type == SHADER_FRAGMENT ? "compile" : "assemble",
shaders->name,
offset / sizeof(uint32_t),
......
......@@ -548,7 +548,7 @@ ioctl_decode_pre_sync(unsigned long int request, void *ptr)
else
panwrap_prop("handle = " MALI_PTR_FMT, args->handle);
panwrap_prop("user_addr = %s + %d", mem->name, args->user_addr - mem->addr);
panwrap_prop("user_addr = %s + %zd", mem->name, args->user_addr - mem->addr);
panwrap_prop("type = %s", args->type == MALI_SYNC_TO_DEVICE ? "MALI_SYNC_TO_DEVICE" : "MALI_SYNC_TO_CPU");
}
......@@ -576,7 +576,7 @@ ioctl_decode_pre_stream_create(unsigned long int request, void *ptr)
static int job_count = 0;
static void emit_atoms(void *ptr) {
static void emit_atoms(void *ptr, bool bifrost) {
const struct mali_ioctl_job_submit *args = ptr;
const struct mali_jd_atom_v2 *atoms = args->addr;
......@@ -592,7 +592,7 @@ static void emit_atoms(void *ptr) {
int req = a->core_req | a->compat_core_req;
if (!(req & MALI_JD_REQ_SOFT_JOB))
job_numbers[i] = panwrap_replay_jc(a->jc);
job_numbers[i] = panwrap_replay_jc(a->jc, bifrost);
else if (req & MALI_JD_REQ_SOFT_REPLAY)
job_numbers[i] = panwrap_replay_soft_replay(a->jc);
}
......@@ -976,14 +976,17 @@ static char *panwrap_lower_string(const char *str)
static int ioctl_count = 0;
/* HW version */
static bool bifrost = false;
/* XXX: Android has a messed up ioctl signature */
int ioctl(int fd, int request, ...)
int ioctl(int fd, int _request, ...)
{
const char *name;
char *lname;
int number;
union mali_ioctl_header *header;
PROLOG(ioctl);
unsigned long int request = _request;
int ioc_size = _IOC_SIZE(request);
int ret;
void *ptr;
......@@ -1004,7 +1007,6 @@ int ioctl(int fd, int request, ...)
LOCK();
msleep(log_delay);
name = ioctl_get_info(request)->name ?: "???";
header = ptr;
bool ignore = false;
......@@ -1030,7 +1032,7 @@ int ioctl(int fd, int request, ...)
if (IOCTL_CASE(request) == IOCTL_CASE(MALI_IOCTL_JOB_SUBMIT)) {
panwrap_log("for (int i = 0; i < 30; ++i) {\n");
panwrap_indent++;
emit_atoms(ptr);
emit_atoms(ptr, bifrost);
replay_memory();
}
......@@ -1074,6 +1076,15 @@ int ioctl(int fd, int request, ...)
panwrap_track_allocation(args->gpu_va, args->flags, number, args->va_pages * 4096);
}
if (IOCTL_CASE(request) == IOCTL_CASE(MALI_IOCTL_GPU_PROPS_REG_DUMP)) {
const struct mali_ioctl_gpu_props_reg_dump *dump = ptr;
unsigned product_id = dump->core.product_id;
panwrap_msg("product id: %d\n", product_id);
/* based on mali_kbase_gpu_id.h and mali_kbase_hw.c */
if (product_id >> 12 == 6 && product_id != 0x6956 /* T60x */)
bifrost = true;
}
if (!ignore) {
panwrap_indent--;
panwrap_log("};\n\n");
......
......@@ -7,7 +7,11 @@ srcs = [
'trans-builder.c'
]
X_dep = cc.find_library('X11', required: true)
if is_android
X_dep = []
else
X_dep = cc.find_library('X11', required: true)
endif
executable(
'panloader',
......
......@@ -28,9 +28,11 @@
/* From Linux arch/arm/include/asm/page.h */
#ifndef PAGE_SIZE
#define PAGE_SHIFT 12
#define PAGE_SIZE (1 << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE - 1))
#endif
/* From the kernel module */
......
#include <X11/Xlib.h>
#include <stdint.h>
#ifndef __ANDROID__
#include <X11/Xlib.h>
Display *d;
Window w;
XImage *image;
......@@ -23,3 +26,13 @@ void slowfb_init(uint8_t *framebuffer, int width, int height) {
void slowfb_update(uint8_t *framebuffer, int width, int height) {
XPutImage(d, w, gc, image, 0, 0, 0, 0, width, height);
}
#else
void slowfb_init(uint8_t *framebuffer, int width, int height) {
}
void slowfb_update(uint8_t *framebuffer, int width, int height) {
}
#endif
......@@ -12,7 +12,7 @@
#include "pandev.h"
#include "trans-builder.h"
void main(void) {
int main(void) {
int fd = pandev_raw_open(), rc;
if (fd < 0) {
......@@ -421,4 +421,5 @@ void main(void) {
slowfb_update((uint8_t*) framebuffer, 400, 320);
}
printf("Replay finished.\n");
return 0;
}