diff options
Diffstat (limited to 'device_info_procfs.c')
| -rw-r--r-- | device_info_procfs.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/device_info_procfs.c b/device_info_procfs.c index b139c36..d5350c8 100644 --- a/device_info_procfs.c +++ b/device_info_procfs.c | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | // @param off Requested offset. Updated by number of characters written. | 9 | // @param off Requested offset. Updated by number of characters written. |
| 10 | // @return -errno on error, otherwise number of bytes written to *buf | 10 | // @return -errno on error, otherwise number of bytes written to *buf |
| 11 | // Note: Parent `data` field MUST be the GPU index | 11 | // Note: Parent `data` field MUST be the GPU index |
| 12 | static ssize_t nvdebug_reg32_read(struct file *f, char __user *buf, size_t size, loff_t *off) { | 12 | static ssize_t nvdebug_reg32_read(struct file *f, char __user *buf, size_t size, loff_t *off){ |
| 13 | char out[16]; | 13 | char out[16]; |
| 14 | int chars_written; | 14 | int chars_written; |
| 15 | struct nvdebug_state *g = &g_nvdebug_state[file2parentgpuidx(f)]; | 15 | struct nvdebug_state *g = &g_nvdebug_state[file2parentgpuidx(f)]; |
| @@ -22,10 +22,39 @@ static ssize_t nvdebug_reg32_read(struct file *f, char __user *buf, size_t size, | |||
| 22 | *off += chars_written; | 22 | *off += chars_written; |
| 23 | return chars_written; | 23 | return chars_written; |
| 24 | } | 24 | } |
| 25 | static ssize_t nvdebug_read4_pascal(struct file *f, char __user *buf, size_t size, loff_t *off){ | ||
| 26 | char out[16]; | ||
| 27 | int chars_written; | ||
| 28 | struct nvdebug_state *g = &g_nvdebug_state[file2parentgpuidx(f)]; | ||
| 29 | void* data = PDE_DATA(file_inode(f)); | ||
| 30 | struct combo local_combo = *(struct combo*) &data; | ||
| 31 | |||
| 32 | // 32 bit register will always take less than 16 characters to print | ||
| 33 | if (size < 16 || *off != 0) | ||
| 34 | return 0; | ||
| 35 | if (local_combo.index % 2 == 0) | ||
| 36 | chars_written = scnprintf(out, 16, "%#0x\n", (nvdebug_readl(g, local_combo.offset) & 0x0f)); | ||
| 37 | else | ||
| 38 | chars_written = scnprintf(out, 16, "%#0x\n", (nvdebug_readl(g, local_combo.offset) & 0xf0) >> 4); | ||
| 39 | if (copy_to_user(buf, out, chars_written)) | ||
| 40 | printk(KERN_WARNING "Unable to copy all data for %s\n", file_dentry(f)->d_name.name); | ||
| 41 | *off += chars_written; | ||
| 42 | return chars_written; | ||
| 43 | |||
| 44 | //(nvdebug_readl(g,NV_LCE_FOR_PCE_GP100(*(int*)PDE_DATA(file_inode(f)))) | ||
| 45 | |||
| 46 | |||
| 47 | |||
| 48 | } | ||
| 25 | struct file_operations nvdebug_read_reg32_file_ops = { | 49 | struct file_operations nvdebug_read_reg32_file_ops = { |
| 26 | .read = nvdebug_reg32_read, | 50 | .read = nvdebug_reg32_read, |
| 27 | .llseek = default_llseek, | 51 | .llseek = default_llseek, |
| 28 | }; | 52 | }; |
| 53 | // File operation for reading 4 bits in 32 bit register (used for Pascal copy engine offsets) | ||
| 54 | struct file_operations nvdebug_read4_pascal_file_ops = { | ||
| 55 | .read = nvdebug_read4_pascal, | ||
| 56 | .llseek = default_llseek, | ||
| 57 | }; | ||
| 29 | 58 | ||
| 30 | typedef struct { | 59 | typedef struct { |
| 31 | int idx; // Current index in the device_info table | 60 | int idx; // Current index in the device_info table |
