AFHBA404
AFHBA404 connects ACQ2106 to PCI-Express
afhba_debugfs.c
Go to the documentation of this file.
1 /* ------------------------------------------------------------------------- *
2  * afhba_debugfs.c
3  * ------------------------------------------------------------------------- *
4  * Copyright (C) 2014 Peter Milne, D-TACQ Solutions Ltd
5  * <peter dot milne at D hyphen TACQ dot com>
6  * www.d-tacq.com
7  * Created on: 11 Aug 2014
8  * Author: pgm
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of Version 2 of the GNU General Public License *
12  * as published by the Free Software Foundation; *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the Free Software *
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
22 /* ------------------------------------------------------------------------- */
23 
24 #include "acq-fiber-hba.h"
25 #include <linux/debugfs.h>
26 
27 struct dentry* afhba_debug_root;
28 
29 #define NUM_REG_CREATE(dir, va, reg) \
30  sprintf(pcursor, "0x%04lx", reg); \
31  debugfs_create_x32(pcursor, S_IRUGO|S_IWUGO, dir, va+(reg)); \
32  pcursor += strlen(pcursor) + 1; \
33  if (pcursor-pbase >= 4096) { WARN_ON(true); return; }
34 
35 void afhba_createDebugfs(struct AFHBA_DEV* adev)
36 {
37  char* pcursor, *pbase;
38  int ireg;
39  struct dentry* loc;
40  struct dentry* rem;
41  struct dentry* buf;
42  int rembase;
43 
44  if (!afhba_debug_root){
45  afhba_debug_root = debugfs_create_dir("afhba", 0);
46  if (!afhba_debug_root){
47  dev_warn(pdev(adev), "failed create dir afhba");
48  return;
49  }
50  }
51  adev->debug_dir = debugfs_create_dir(
53  if (!adev->debug_dir){
54  dev_warn(pdev(adev), "failed create dir %s", afhba_devnames[adev->idx]);
55  return;
56  }
57  pbase = pcursor = adev->debug_names = kmalloc(8192, GFP_KERNEL);
58 
59  loc = debugfs_create_dir("LOC", adev->debug_dir);
60  if (!loc){
61  dev_warn(pdev(adev), "failed create dir %s", "LOC");
62  return;
63  }
64  for (ireg = 0; ireg < 50; ++ireg){
65  NUM_REG_CREATE(loc, LOC(adev), ireg*sizeof(u32));
66  }
67  NUM_REG_CREATE(loc, LOC(adev), 0x100*sizeof(u32));
68 
69  rem = debugfs_create_dir("REM", adev->debug_dir);
70  if (!rem){
71  dev_warn(pdev(adev), "failed create dir %s", "REM");
72  return;
73  }
74  for (rembase = 0; rembase <= 4; ++rembase){
75  for (ireg = 0; ireg <= 32; ++ireg){
76  NUM_REG_CREATE(rem, REM(adev), rembase*0x1000+ireg*sizeof(u32));
77  }
78  }
79  //NUM_REG_CREATE(rem, REM(adev), 0x100*sizeof(u32));
80 
81  buf = debugfs_create_dir("BUF", adev->debug_dir);
82 
83  if (adev->hb1 == 0){
84  dev_err(pdev(adev), "bad hb"); return;
85  }
86 
87  debugfs_create_x64("va", S_IRUGO, buf, (u64*)&(adev->hb1->va));
88  debugfs_create_x32("pa", S_IRUGO, buf, &(adev->hb1->pa));
89 }
90 void afhba_removeDebugfs(struct AFHBA_DEV* adev)
91 {
92  debugfs_remove_recursive(adev->debug_dir);
93  kfree(adev->debug_names);
94 }
REM
#define REM(adev)
Definition: acq-fiber-hba.h:179
HostBuffer::pa
u32 pa
Definition: acq-fiber-hba.h:97
pdev
#define pdev(adev)
Definition: acq-fiber-hba.h:176
AFHBA_DEV::hb1
struct HostBuffer * hb1
Definition: acq-fiber-hba.h:141
afhba_createDebugfs
void afhba_createDebugfs(struct AFHBA_DEV *adev)
Definition: afhba_debugfs.c:35
AFHBA_DEV::idx
int idx
Definition: acq-fiber-hba.h:117
NUM_REG_CREATE
#define NUM_REG_CREATE(dir, va, reg)
Definition: afhba_debugfs.c:29
AFHBA_DEV
Definition: acq-fiber-hba.h:111
HostBuffer::va
void * va
Definition: acq-fiber-hba.h:96
afhba_debug_root
struct dentry * afhba_debug_root
Definition: afhba_debugfs.c:27
afhba_removeDebugfs
void afhba_removeDebugfs(struct AFHBA_DEV *adev)
Definition: afhba_debugfs.c:90
LOC
#define LOC(adev)
Definition: acq-fiber-hba.h:178
AFHBA_DEV::debug_names
char * debug_names
Definition: acq-fiber-hba.h:139
acq-fiber-hba.h
afhba_devnames
const char * afhba_devnames[MAXDEV]
Definition: acq-fiber-hba.c:41
u32
unsigned u32
Definition: local.h:60
AFHBA_DEV::debug_dir
struct dentry * debug_dir
Definition: acq-fiber-hba.h:138