devtime.c (1051:d71e55bdc654) devtime.c (1053:2c6d9e60541b)
1/*
2 * Copyright (c) 2004 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 40 unchanged lines hidden (view full) ---

49static char *dataAddr = NULL;
50static int count = 0;
51
52static inline uint32_t cycleCounter(uint32_t dep);
53
54static int __init devtime_start(void)
55{
56 uint64_t addr;
1/*
2 * Copyright (c) 2004 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 40 unchanged lines hidden (view full) ---

49static char *dataAddr = NULL;
50static int count = 0;
51
52static inline uint32_t cycleCounter(uint32_t dep);
53
54static int __init devtime_start(void)
55{
56 uint64_t addr;
57 uint32_t t1, t2;
57 uint32_t t1, t2;
58 uint32_t trash;
59 int x;
60 uint32_t *times;
61 uint32_t num = 0;
62 struct net_device *dev;
63
58 uint32_t trash;
59 int x;
60 uint32_t *times;
61 uint32_t num = 0;
62 struct net_device *dev;
63
64
65 printk("Devtime Driver Version %s Loaded...\n", DRIVER_VER);
66
64 printk("Devtime Driver Version %s Loaded...\n", DRIVER_VER);
65
67 if ((dataAddr != 0) && (count != 0))
68 {
66 if (dataAddr != 0 && count != 0) {
69 addr = simple_strtoull(dataAddr, NULL, 0);
70
71 addr = ioremap(addr, PAGE_SIZE);
72 /**
73 * Make sure that the remapping actually worked. On alpha we have
74 * linear addressing, so its not a problem. But it can fail in x86
75 * if physical memory is mapped to this address.
76 */
77 times = kmalloc(sizeof(uint32_t) * count, GFP_USER);
67 addr = simple_strtoull(dataAddr, NULL, 0);
68
69 addr = ioremap(addr, PAGE_SIZE);
70 /**
71 * Make sure that the remapping actually worked. On alpha we have
72 * linear addressing, so its not a problem. But it can fail in x86
73 * if physical memory is mapped to this address.
74 */
75 times = kmalloc(sizeof(uint32_t) * count, GFP_USER);
78 if (!times)
79 {
76 if (!times) {
80 printk("Could not allocate memory... Try again later.\n");
81 return -1;
82 }
83
77 printk("Could not allocate memory... Try again later.\n");
78 return -1;
79 }
80
84 if (addr)
85 {
81 if (addr) {
86 printk("Preparing to read %#llx %d times.\n", addr, count);
87
88 t1 = cycleCounter(trash);
82 printk("Preparing to read %#llx %d times.\n", addr, count);
83
84 t1 = cycleCounter(trash);
89 for (x=0; x < count; x++)
90 {
85 for (x = 0; x < count; x++) {
91 trash = readl(addr);
92 t2 = cycleCounter(trash);
93 times[num++] = t2 - t1;
94 t1 = t2;
95 }
96
97 /**
98 * Unmap the address.
99 */
100 iounmap(addr);
101
102 printk("Measurements:\n");
86 trash = readl(addr);
87 t2 = cycleCounter(trash);
88 times[num++] = t2 - t1;
89 t1 = t2;
90 }
91
92 /**
93 * Unmap the address.
94 */
95 iounmap(addr);
96
97 printk("Measurements:\n");
103 for (x = 0; x < count; x++)
104 {
98 for (x = 0; x < count; x++) {
105 printk("%d ", times[x]);
99 printk("%d ", times[x]);
106 if (((x+1) % 10) == 0)
100 if (((x + 1) % 10) == 0)
107 printk("\n");
108 }
109 printk("\nDone.\n");
101 printk("\n");
102 }
103 printk("\nDone.\n");
110
111
112 }
113 else
104 } else {
114 printk("Unable to remap address. Please try again later.\n");
105 printk("Unable to remap address. Please try again later.\n");
106 }
115 } else {
116 dev = dev_get_by_name("eth0");
107 } else {
108 dev = dev_get_by_name("eth0");
117 if (dev)
118 {
119 printk("Eth0: MemStart: %#lx MemEnd: %#lx I/O Addr: %#lx\n", dev->mem_start,
120 dev->mem_end, dev->base_addr);
109 if (dev) {
110 printk("Eth0: MemStart: %#lx MemEnd: %#lx I/O Addr: %#lx\n",
111 dev->mem_start, dev->mem_end, dev->base_addr);
121 dev_put(dev);
122 }
123 dev = 0;
124 dev = dev_get_by_name("eth1");
112 dev_put(dev);
113 }
114 dev = 0;
115 dev = dev_get_by_name("eth1");
125 if (dev)
126 {
127 printk("Eth1: MemStart: %#lx MemEnd: %#lx I/O Addr: %#lx\n", dev->mem_start,
128 dev->mem_end, dev->base_addr);
116 if (dev) {
117 printk("Eth1: MemStart: %#lx MemEnd: %#lx I/O Addr: %#lx\n",
118 dev->mem_start, dev->mem_end, dev->base_addr);
129 dev_put(dev);
130 }
131
119 dev_put(dev);
120 }
121
132
133 printk("Required information not supplied.\n");
134 }
135
136 return 0;
137}
138
139#ifdef __i386__
140

--- 13 unchanged lines hidden (view full) ---

154 uint32_t res;
155 asm volatile ("rpcc %0, %1" : "=r"(res) : "r" (dep) : "memory");
156 return res;
157}
158#else
159#error Architecture NOT SUPPORTE
160#endif
161
122 printk("Required information not supplied.\n");
123 }
124
125 return 0;
126}
127
128#ifdef __i386__
129

--- 13 unchanged lines hidden (view full) ---

143 uint32_t res;
144 asm volatile ("rpcc %0, %1" : "=r"(res) : "r" (dep) : "memory");
145 return res;
146}
147#else
148#error Architecture NOT SUPPORTE
149#endif
150
162static void __exit devtime_end(void) {
151static void __exit devtime_end(void)
152{
163 printk("Devtime Driver Version %s Unloaded...\n", DRIVER_VER);
164}
165
166
167module_init(devtime_start);
168module_exit(devtime_end);
169
170MODULE_LICENSE("Dual BSD/GPL");
171MODULE_AUTHOR(DRIVER_AUTHOR);
172MODULE_DESCRIPTION(DRIVER_DESC);
173module_param(dataAddr, charp, 0);
174module_param(count, int, 0);
153 printk("Devtime Driver Version %s Unloaded...\n", DRIVER_VER);
154}
155
156
157module_init(devtime_start);
158module_exit(devtime_end);
159
160MODULE_LICENSE("Dual BSD/GPL");
161MODULE_AUTHOR(DRIVER_AUTHOR);
162MODULE_DESCRIPTION(DRIVER_DESC);
163module_param(dataAddr, charp, 0);
164module_param(count, int, 0);