2 JPC-RR: A x86 PC Hardware Emulator
5 Copyright (C) 2007-2009 Isis Innovation Limited
6 Copyright (C) 2009-2010 H. Ilari Liusvaara
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as published by
10 the Free Software Foundation.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 Based on JPC x86 PC Hardware emulator,
22 A project from the Physics Dept, The University of Oxford
24 Details about original JPC can be found at:
26 www-jpc.physics.ox.ac.uk
30 package org
.jpc
.output
;
34 public abstract class OutputFrame
39 public OutputFrame(long timeStamp
, byte minorType
)
45 protected void adjustTime(long delta
)
50 public byte[] dump(short channel
, long timeBase
) throws IOException
56 throw new IOException("Channel 0xFFFF is reserved");
57 long delta
= time
- timeBase
;
59 throw new IOException("Event times must be monotonic");
61 byte[] internal
= dumpInternal();
63 //Calculate length of frame and allocate it.
64 while(delta
>= 0xFFFFFFFFL
) {
69 int ilen
= (internal
!= null) ? internal
.length
: 0;
75 len
+= ((internal
!= null) ? internal
.length
: 0);
76 byte[] frame
= new byte[len
];
79 int offset
= 6 * skips
;
80 for(int i
= 0; i
< offset
; i
++)
82 frame
[offset
+ 0] = (byte)((channel
>>> 8) & 0xFF);
83 frame
[offset
+ 1] = (byte)(channel
& 0xFF);
84 frame
[offset
+ 2] = (byte)((delta
>>> 24) & 0xFF);
85 frame
[offset
+ 3] = (byte)((delta
>>> 16) & 0xFF);
86 frame
[offset
+ 4] = (byte)((delta
>>> 8) & 0xFF);
87 frame
[offset
+ 5] = (byte)(delta
& 0xFF);
88 frame
[offset
+ 6] = minor
;
89 ilen
= (internal
!= null) ? internal
.length
: 0;
90 for(int i
= llen
; i
> 0; i
--) {
91 frame
[offset
+ 6 + i
] = (byte)(((i
== llen
) ?
0x00 : 0x80) | (ilen
& 0x7F));
95 System
.arraycopy(internal
, 0, frame
, offset
+ 7 + llen
, internal
.length
);
104 protected abstract byte[] dumpInternal();