b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync/* $Id$ */
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync/** @file
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync * DTracing VBox - Interrupt Experiment #1.
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync */
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync/*
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync * Copyright (C) 2012 Oracle Corporation
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync *
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync * available from http://www.virtualbox.org. This file is free software;
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync * you can redistribute it and/or modify it under the terms of the GNU
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync * General Public License (GPL) as published by the Free Software
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync */
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync
13080fa6a2040179c8c24cee6d48c4c8d08686f7vboxsync#pragma D option quiet
13080fa6a2040179c8c24cee6d48c4c8d08686f7vboxsync
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsyncuint64_t g_aStarts[uint32_t];
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsyncuint64_t g_cUntaggedHighs;
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsyncuint64_t g_cUntaggedGets;
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsyncuint64_t g_cMissedHighs;
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsyncinline uint32_t kfDevIdMask = 0x3ff;
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync/*
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync * Timestamp the when the device raises the IRQ.
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync */
13080fa6a2040179c8c24cee6d48c4c8d08686f7vboxsyncvboxvmm*:::pdm-irq-high,vboxvmm*:::pdm-irq-hilo
13080fa6a2040179c8c24cee6d48c4c8d08686f7vboxsync/args[1] != 0/
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync{
13080fa6a2040179c8c24cee6d48c4c8d08686f7vboxsync /*printf("high: tag=%#x src=%d %llx -> %llx\n", args[1], args[2], g_aStarts[args[1]], timestamp);*/
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync g_aStarts[args[1]] = timestamp;
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync}
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsyncvboxvmm*:::pdm-irq-high,vboxvmm*:::pdm-irq-hilo
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync/args[1] == 0/
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync{
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync g_cUntaggedHighs++;
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync}
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync
5c953e1a8cc975df9c34f55569519fbfb3388537vboxsync/*
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync * Catch the CPU getting the IRQ from the (A)PIC and preparing for injection.
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync */
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsyncvboxvmm*:::pdm-irq-get
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync/g_aStarts[args[1]] == 0 && args[1] != 0/
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync{
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printf("get: tag=%#x src=%d %llx - %llx = %llx\n", args[1], args[2], timestamp, g_aStarts[args[1]], timestamp - g_aStarts[args[1]]);
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync @g_MissedHighs[args[3], args[2] & kfDevIdMask] = count();
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync g_cMissedHighs++;
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync}
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsyncvboxvmm*:::pdm-irq-get
13080fa6a2040179c8c24cee6d48c4c8d08686f7vboxsync/g_aStarts[args[1]] > 0 && args[1] != 0/
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync{
13080fa6a2040179c8c24cee6d48c4c8d08686f7vboxsync /*printf("get: tag=%#x src=%d %llx - %llx = %llx\n", args[1], args[2], timestamp, g_aStarts[args[1]], timestamp - g_aStarts[args[1]]);*/
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync @g_Interrupts[args[3], args[2] & kfDevIdMask] = count();
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync @g_DispAvg[ args[3], args[2] & kfDevIdMask] = avg(timestamp - g_aStarts[args[1]]);
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync @g_DispMax[ args[3], args[2] & kfDevIdMask] = max(timestamp - g_aStarts[args[1]]);
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync @g_DispMin[ args[3], args[2] & kfDevIdMask] = min(timestamp - g_aStarts[args[1]]);
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync g_aStarts[args[1]] = 0;
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync g_cHits++;
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync}
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsyncvboxvmm*:::pdm-irq-get
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync/args[1] == 0/
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync{
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync @g_UntaggedGets[args[3]] = count();
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync g_cUntaggedGets++;
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync}
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsyncvboxvmm*:::pdm-irq-get
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync/args[2] > kfDevIdMask/
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync{
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync @g_Shared[args[3], args[2] & kfDevIdMask] = count();
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync}
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync/* For the time being, quit after 256 interrupts. */
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsyncvboxvmm*:::pdm-irq-get
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync/g_cHits >= 256/
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync{
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync exit(0);
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync}
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync/*
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync * Catch the device clearing the IRQ.
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync */
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync/*
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync * Report.
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync */
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsyncEND
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync{
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printf("\nInterrupt distribution:\n");
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printa(" irq %3d dev %2d %@12u\n", @g_Interrupts);
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printf("Interrupt sharing (devices detect pushing a line high at the same time):\n");
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printa(" irq %3d dev %2d %@12u\n", @g_Shared);
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printf("Minimum dispatch latency:\n");
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printa(" irq %3d dev %2d %@12u ns\n", @g_DispMin);
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printf("Average dispatch latency:\n");
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printa(" irq %3d dev %2d %@12u ns\n", @g_DispAvg);
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printf("Maximum dispatch latency:\n");
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printa(" irq %3d dev %2d %@12u ns\n", @g_DispMax);
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync}
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsyncEND
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync/g_cUntaggedHighs > 0/
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync{
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printf("Untagged highs: %u\n", g_cUntaggedHighs);
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync}
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsyncEND
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync/g_cUntaggedGets > 0/
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync{
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printf("Untagged gets: %u\n", g_cUntaggedGets);
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printa(" irq %3d %@12u\n", @g_UntaggedGets);
b4d35dedda4bab414ab7dbd94dde4587bd8168e7vboxsync}
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsyncEND
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync/g_cMissedHighs > 0/
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync{
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printf("Missed (or shared?) highs: %u\n", g_cMissedHighs);
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync printa(" irq %3d dev %2d %@12u\n", @g_MissedHighs);
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync}
5f0b2a477f40177194bff6d34581ae1382a3ea33vboxsync