summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@localhost>2011-05-18 19:58:00 +0000
committercinap_lenrek <cinap_lenrek@localhost>2011-05-18 19:58:00 +0000
commitdf687d3840503e4811a5572bf5ce97b74cb21727 (patch)
tree510bf028fa1d04b9900644689c1082fd705a752a
parentb74418c2ce5c64ba39473e2eb50ea1112be63109 (diff)
parent61660acf68c41098fda04f8f761e038148c4115e (diff)
merge
-rw-r--r--sys/src/9/pc/mp.c10
-rw-r--r--sys/src/cmd/tput.c42
2 files changed, 48 insertions, 4 deletions
diff --git a/sys/src/9/pc/mp.c b/sys/src/9/pc/mp.c
index b74fa1250..e8316ac74 100644
--- a/sys/src/9/pc/mp.c
+++ b/sys/src/9/pc/mp.c
@@ -883,13 +883,14 @@ mpintrenablex(Vctl* v, int tbdf)
enum {
MSICtrl = 0x02, /* message control register (16 bit) */
MSIAddr = 0x04, /* message address register (64 bit) */
- MSIData = 0x0C, /* message data register (16 bit) */
+ MSIData32 = 0x08, /* message data register for 32 bit MSI (16 bit) */
+ MSIData64 = 0x0C, /* message data register for 64 bit MSI (16 bit) */
};
static int
msiintrenable(Vctl *v)
{
- int tbdf, vno, cap, cpu;
+ int tbdf, vno, cap, cpu, ok64;
Pcidev *pci;
if(getconf("*msi") == nil)
@@ -913,9 +914,10 @@ msiintrenable(Vctl *v)
vno = allocvector();
cpu = mpintrcpu();
+ ok64 = (pcicfgr16(pci, cap + MSICtrl) & (1<<7)) != 0;
pcicfgw32(pci, cap + MSIAddr, (0xFEE << 20) | (cpu << 12));
- pcicfgw32(pci, cap + MSIAddr + 4, 0);
- pcicfgw16(pci, cap + MSIData, vno | (1<<14));
+ if(ok64) pcicfgw32(pci, cap + MSIAddr + 4, 0);
+ pcicfgw16(pci, cap + (ok64 ? MSIData64 : MSIData32), vno | (1<<14));
pcicfgw16(pci, cap + MSICtrl, 1);
print("msiintrenable: success with tbdf %.8x, vector %d, cpu %d\n", tbdf, vno, cpu);
v->isr = lapicisr;
diff --git a/sys/src/cmd/tput.c b/sys/src/cmd/tput.c
new file mode 100644
index 000000000..47ef99b89
--- /dev/null
+++ b/sys/src/cmd/tput.c
@@ -0,0 +1,42 @@
+#include <u.h>
+#include <libc.h>
+
+enum {buflen = 4096};
+
+void
+main(int argc, char **argv)
+{
+ int rc, cpid, fd, dopipe;
+ static char buf[buflen];
+ static uvlong bc, sec;
+ double speed;
+
+ dopipe = 0;
+ ARGBEGIN {
+ case 'p': dopipe = 1;
+ } ARGEND
+
+ bc = 0;
+ sec = 0;
+ cpid = rfork(RFPROC | RFMEM);
+ if(cpid == 0) {
+ while(1) {
+ sleep(1000);
+ speed = bc / ++sec;
+ if(speed >= 1073741824) fprint(2, "%.2f GB/s\n", speed / 1073741824);
+ else if(speed >= 1048576) fprint(2, "%.2f MB/s\n", speed / 1048576);
+ else if(speed >= 1024) fprint(2, "%.2f KB/s\n", speed / 1024);
+ else fprint(2, "%.2f B/s\n", speed);
+ }
+ }
+ while(1) {
+ rc = read(0, buf, buflen);
+ if(rc <= 0) break;
+ if(dopipe) write(1, buf, rc);
+ bc += rc;
+ }
+ sprint(buf, "/proc/%d/note", cpid);
+ fd = open(buf, OWRITE);
+ write(fd, "kill", 4);
+ if(rc < 0) sysfatal("%r");
+}