proc.c 3.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/*
 *  This program is free software; you can distribute it and/or modify it
 *  under the terms of the GNU General Public License (Version 2) as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope it will be useful, but WITHOUT
 *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 *  for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
 */
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/irq.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/kernel_stat.h>
#include <linux/random.h>

#include <asm/io.h>
#include <int.h>
#include <uart.h>


29
static int pnx8550_timers_read(char* page, char** start, off_t offset, int count, int* eof, void* data)
30 31 32 33 34
{
        int len = 0;
	int configPR = read_c0_config7();

        if (offset==0) {
35 36
		len += sprintf(&page[len], "Timer:       count,  compare, tc, status\n");
                len += sprintf(&page[len], "    1: %11i, %8i,  %1i, %s\n",
37 38
			       read_c0_count(), read_c0_compare(),
			      (configPR>>6)&0x1, ((configPR>>3)&0x1)? "off":"on");
39
                len += sprintf(&page[len], "    2: %11i, %8i,  %1i, %s\n",
40 41
			       read_c0_count2(), read_c0_compare2(),
			      (configPR>>7)&0x1, ((configPR>>4)&0x1)? "off":"on");
42
                len += sprintf(&page[len], "    3: %11i, %8i,  %1i, %s\n",
43 44 45 46 47 48 49
			       read_c0_count3(), read_c0_compare3(),
			      (configPR>>8)&0x1, ((configPR>>5)&0x1)? "off":"on");
        }

        return len;
}

50
static int pnx8550_registers_read(char* page, char** start, off_t offset, int count, int* eof, void* data)
51 52 53 54
{
        int len = 0;

        if (offset==0) {
55 56 57 58 59 60 61 62 63 64 65 66
                len += sprintf(&page[len], "config1:   %#10.8x\n", read_c0_config1());
                len += sprintf(&page[len], "config2:   %#10.8x\n", read_c0_config2());
                len += sprintf(&page[len], "config3:   %#10.8x\n", read_c0_config3());
                len += sprintf(&page[len], "configPR:  %#10.8x\n", read_c0_config7());
                len += sprintf(&page[len], "status:    %#10.8x\n", read_c0_status());
                len += sprintf(&page[len], "cause:     %#10.8x\n", read_c0_cause());
                len += sprintf(&page[len], "count:     %#10.8x\n", read_c0_count());
                len += sprintf(&page[len], "count_2:   %#10.8x\n", read_c0_count2());
                len += sprintf(&page[len], "count_3:   %#10.8x\n", read_c0_count3());
                len += sprintf(&page[len], "compare:   %#10.8x\n", read_c0_compare());
                len += sprintf(&page[len], "compare_2: %#10.8x\n", read_c0_compare2());
                len += sprintf(&page[len], "compare_3: %#10.8x\n", read_c0_compare3());
67 68 69 70 71 72 73 74 75 76 77 78 79
        }

        return len;
}

static struct proc_dir_entry* pnx8550_dir        = NULL;
static struct proc_dir_entry* pnx8550_timers     = NULL;
static struct proc_dir_entry* pnx8550_registers  = NULL;

static int pnx8550_proc_init( void )
{

	// Create /proc/pnx8550
80
        pnx8550_dir = proc_mkdir("pnx8550", NULL);
81
        if (!pnx8550_dir) {
82 83 84 85 86
                printk(KERN_ERR "Can't create pnx8550 proc dir\n");
                return -1;
        }

	// Create /proc/pnx8550/timers
87 88 89 90 91 92 93 94
        pnx8550_timers = create_proc_read_entry(
		"timers",
		0,
		pnx8550_dir,
		pnx8550_timers_read,
		NULL);

        if (!pnx8550_timers)
95 96 97
                printk(KERN_ERR "Can't create pnx8550 timers proc file\n");

	// Create /proc/pnx8550/registers
98 99 100 101 102 103 104 105
        pnx8550_registers = create_proc_read_entry(
		"registers",
		0,
		pnx8550_dir,
		pnx8550_registers_read,
		NULL);

        if (!pnx8550_registers)
106 107 108 109 110 111
                printk(KERN_ERR "Can't create pnx8550 registers proc file\n");

	return 0;
}

__initcall(pnx8550_proc_init);