Commit 75f146ff authored by Cedric Champion's avatar Cedric Champion

first TiCkS_FMC hdl commit

parents
/testbench/
/sim/
/Manifest.py
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// Copyright (C) 2011
// GSI Helmholtzzentrum fr Schwerionenforschung GmbH
//
// Author: M.Zweig
//
unit Global;
interface
uses etherbone,wrdevice_unit;
const
First_DNSAdress = 'asl720.acc.gsi.de:8989';
First_PortNumber= '400';
ArrayRange = 256;
var
myDNSAdress :string;
myAddress :eb_address_t;
myDevice :Twrdevice;
DeviceOffsetCount:Word;
DeviceCtrRegCount:Word;
DeviceDataCount :Word;
SendingCnt :integer;
PaketCnt :integer;
DeviceOffset:array[0..ArrayRange] of LongWord;
DeviceCtrReg:array[0..ArrayRange] of LongWord;
DeviceData :array[0..ArrayRange] of LongWord;
type TWrPacket= RECORD CASE Int64 OF
1: (wpack: Int64);
2: (r : PACKED RECORD
data : LongWord;
Adr : LongWord;
END;);
END;
implementation
end.
object SendUserdata_Form: TSendUserdata_Form
Left = 0
Top = 0
Width = 505
Height = 275
AutoSize = True
Caption = 'Send User data'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 19
object Loop_SpeedButton: TSpeedButton
Left = 0
Top = 208
Width = 89
Height = 33
AllowAllUp = True
GroupIndex = 1
Caption = 'Loop'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
OnClick = Loop_SpeedButtonClick
end
object Send_SpeedButton: TSpeedButton
Left = 408
Top = 208
Width = 89
Height = 33
AllowAllUp = True
GroupIndex = 1
Caption = 'Send'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
OnClick = Send_SpeedButtonClick
end
object Panel1: TPanel
Left = 0
Top = 0
Width = 497
Height = 201
BevelInner = bvLowered
TabOrder = 0
object Label1: TLabel
Left = 16
Top = 139
Width = 131
Height = 19
Caption = 'Data to send (hex)'
end
object Label2: TLabel
Left = 16
Top = 8
Width = 79
Height = 19
Caption = 'Offset(hex)'
end
object Label3: TLabel
Left = 16
Top = 72
Width = 130
Height = 19
Caption = 'Register Adr.(hex)'
end
object DataToWrite_Edit: TEdit
Left = 13
Top = 161
Width = 250
Height = 27
TabOrder = 0
OnKeyPress = DataToWrite_EditKeyPress
end
object Offset_Edit: TEdit
Left = 15
Top = 30
Width = 98
Height = 27
TabOrder = 1
OnKeyPress = Offset_EditKeyPress
end
object RegArd_Edit: TEdit
Left = 15
Top = 94
Width = 130
Height = 27
TabOrder = 2
OnKeyPress = RegArd_EditKeyPress
end
object Panel2: TPanel
Left = 272
Top = 0
Width = 225
Height = 201
BevelInner = bvLowered
TabOrder = 3
object Send_Label: TLabel
Left = 16
Top = 16
Width = 80
Height = 19
Caption = 'Sending...'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
end
object Adress_Panel: TPanel
Left = 15
Top = 38
Width = 97
Height = 25
BevelInner = bvLowered
Caption = '00000000'
TabOrder = 0
end
object Data_Panel: TPanel
Left = 110
Top = 38
Width = 97
Height = 25
BevelInner = bvLowered
Caption = '00000000'
TabOrder = 1
end
end
end
object Timer1: TTimer
OnTimer = Timer1Timer
Left = 224
Top = 208
end
end
// Copyright (C) 2011
// GSI Helmholtzzentrum fr Schwerionenforschung GmbH
//
// Author: M.Zweig
//
unit UserSendData;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ExtCtrls,Global, etherbone, wrdevice_unit;
type
TSendUserdata_Form = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Loop_SpeedButton:TSpeedButton;
Send_SpeedButton: TSpeedButton;
Timer1: TTimer;
DataToWrite_Edit: TEdit;
Label2: TLabel;
Offset_Edit: TEdit;
Label3: TLabel;
RegArd_Edit: TEdit;
Panel2: TPanel;
Send_Label: TLabel;
Adress_Panel: TPanel;
Data_Panel: TPanel;
procedure DataToWrite_EditKeyPress(Sender: TObject; var Key: Char);
procedure RegArd_EditKeyPress(Sender: TObject; var Key: Char);
procedure Offset_EditKeyPress(Sender: TObject; var Key: Char);
procedure Loop_SpeedButtonClick(Sender: TObject);
procedure Send_SpeedButtonClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormShow(Sender: TObject);
function ReadUserInput(var WrPacket:TWrPacket):boolean;
const
Text_Send= 'Sending...';
public
{ Public-Deklarationen }
end;
Var
SendUserdata_Form:TSendUserdata_Form;
implementation
{$R *.dfm}
procedure TSendUserdata_Form.FormShow(Sender: TObject);
begin
Send_Label.Caption:='';
end;
procedure TSendUserdata_Form.Timer1Timer(Sender: TObject);
begin
if(Loop_Speedbutton.Down) or (Send_Speedbutton.Down) then begin
if(Send_Label.Caption = Text_Send) then Send_Label.Caption:=''
else Send_Label.Caption:= Text_Send
end else Send_Label.Caption:='';
Application.ProcessMessages;
end;
// User daten einmal an device senden
procedure TSendUserdata_Form.Send_SpeedButtonClick(Sender: TObject);
var status:string;
WrPacket:TWrPacket;
begin
if(Send_SpeedButton.Down) then begin
if (ReadUserInput(WrPacket)) then begin
// datenanzeigen
Adress_Panel.Caption:= IntToHex(WrPacket.r.Adr,8);
Data_Panel.Caption := IntToHex(WrPacket.r.data,8);
// daten schreiben
if not(myDevice.DeviceCacheWR(myAddress,WrPacket.wpack,status)) then
Application.MessageBox(PChar(status),'Dave? What are you doing?', 16);
myDevice.DeviceCacheSend(status);
end;
Send_SpeedButton.Down:=false;
Send_SpeedButton.Click;
end;
end;
// User daten im loop an die device senden
procedure TSendUserdata_Form.Loop_SpeedButtonClick(Sender: TObject);
var WrPacket:TWrPacket;
status:string;
index:integer;
begin
index:= 0;
if (ReadUserInput(WrPacket)) then begin
// datenanzeigen
Adress_Panel.Caption:= IntToHex(WrPacket.r.Adr,8);
Data_Panel.Caption := IntToHex(WrPacket.r.data,8);
while(Loop_SpeedButton.Down) do begin
index:=index+1;
if (ReadUserInput(WrPacket)) then begin
// daten schreiben
if not(myDevice.DeviceCacheWR(myAddress,WrPacket.wpack,status)) then begin
Application.MessageBox(PChar(status),'Finish Him', 16);
Loop_SpeedButton.Down:=false;
Loop_SpeedButton.Click;
end else myDevice.DeviceCacheSend(status);
end;
if((index mod 100)=0) then begin
index:= 0;
Application.ProcessMessages;
end;
end;
end;
end;
// User daten uebernehem und in das record uebertragen
function TSendUserdata_Form.ReadUserInput(var WrPacket:TWrPacket):boolean;
var offset :LongWord;
ErrFound :boolean;
begin
ErrFound:= false;
while length(Offset_Edit.Text)< 8 do
Offset_Edit.Text:='0'+Offset_Edit.Text;
//Offset uebernehem
try
offset:= StrToInt('$'+ Offset_Edit.Text);
except
Application.MessageBox('This is not a valid hex data', 'You will never win !', 16);
ErrFound:= true;
end;
while length(RegArd_Edit.Text)< 8 do
RegArd_Edit.Text:='0'+RegArd_Edit.Text;
//Adresse uebernehmen
if not(ErrFound) then begin
try
WrPacket.r.Adr:= StrToInt('$'+RegArd_Edit.Text);
except
Application.MessageBox('This is not a valid hex Adress', 'You are false data...', 16);
ErrFound:= true;
end;
end;
while length(DataToWrite_Edit.Text)< 8 do
DataToWrite_Edit.Text:='0'+DataToWrite_Edit.Text;
//Daten uebernehmen
if not(ErrFound) then begin
try
WrPacket.r.data:= StrToInt('$'+ DataToWrite_Edit.Text);
except
Application.MessageBox('This is not a valid hex Adress', 'Let there be light...', 16);
ErrFound:= true;
end;
end;
//Adresse + Offset -> device prefix
if not(ErrFound) then begin
WrPacket.r.Adr:= WrPacket.r.Adr + offset;
end;
ReadUserInput:= not(ErrFound)
end;
procedure TSendUserdata_Form.Offset_EditKeyPress(Sender: TObject;
var Key: Char);
begin
if not(Key in ['0'..'9', 'A'..'F', 'a'..'f'])or (length(Offset_Edit.Text)>= 8) then begin
//Edit_WR_Constant.Text:='0000';
Key:= #0;
end;
end;
procedure TSendUserdata_Form.RegArd_EditKeyPress(Sender: TObject;
var Key: Char);
begin
begin
if not(Key in ['0'..'9', 'A'..'F', 'a'..'f'])or (length(RegArd_Edit.Text)>= 8) then begin
//Edit_WR_Constant.Text:='0000';
Key:= #0;
end;
end;
end;
procedure TSendUserdata_Form.DataToWrite_EditKeyPress(Sender: TObject;
var Key: Char);
begin
begin
if not(Key in ['0'..'9', 'A'..'F', 'a'..'f'])or (length(DataToWrite_Edit.Text) >= 8) then begin
//Edit_WR_Constant.Text:='0000';
Key:= #0;
end;
end;
end;
end.
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<BorlandProject>
<PersonalityInfo>
<Option>
<Option Name="Personality">Delphi.Personality</Option>
<Option Name="ProjectType"></Option>
<Option Name="Version">1.0</Option>
<Option Name="GUID">{9F7D8C2C-2DA7-40E2-B9A0-F41948DA895D}</Option>
</Option>
</PersonalityInfo>
<Delphi.Personality>
<Source>
<Source Name="MainSource">WR.dpr</Source>
</Source>
<FileVersion>
<FileVersion Name="Version">7.0</FileVersion>
</FileVersion>
<Compiler>
<Compiler Name="A">8</Compiler>
<Compiler Name="B">1</Compiler>
<Compiler Name="C">1</Compiler>
<Compiler Name="D">1</Compiler>
<Compiler Name="E">0</Compiler>
<Compiler Name="F">0</Compiler>
<Compiler Name="G">1</Compiler>
<Compiler Name="H">1</Compiler>
<Compiler Name="I">1</Compiler>
<Compiler Name="J">0</Compiler>
<Compiler Name="K">0</Compiler>
<Compiler Name="L">1</Compiler>
<Compiler Name="M">0</Compiler>
<Compiler Name="N">1</Compiler>
<Compiler Name="O">0</Compiler>
<Compiler Name="P">1</Compiler>
<Compiler Name="Q">0</Compiler>
<Compiler Name="R">0</Compiler>
<Compiler Name="S">0</Compiler>
<Compiler Name="T">0</Compiler>
<Compiler Name="U">0</Compiler>
<Compiler Name="V">1</Compiler>
<Compiler Name="W">0</Compiler>
<Compiler Name="X">1</Compiler>
<Compiler Name="Y">1</Compiler>
<Compiler Name="Z">1</Compiler>
<Compiler Name="ShowHints">True</Compiler>
<Compiler Name="ShowWarnings">True</Compiler>
<Compiler Name="UnitAliases">WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;</Compiler>
<Compiler Name="NamespacePrefix"></Compiler>
<Compiler Name="GenerateDocumentation">False</Compiler>
<Compiler Name="DefaultNamespace"></Compiler>
<Compiler Name="SymbolDeprecated">True</Compiler>
<Compiler Name="SymbolLibrary">True</Compiler>
<Compiler Name="SymbolPlatform">True</Compiler>
<Compiler Name="SymbolExperimental">True</Compiler>
<Compiler Name="UnitLibrary">True</Compiler>
<Compiler Name="UnitPlatform">True</Compiler>
<Compiler Name="UnitDeprecated">True</Compiler>
<Compiler Name="UnitExperimental">True</Compiler>
<Compiler Name="HResultCompat">True</Compiler>
<Compiler Name="HidingMember">True</Compiler>
<Compiler Name="HiddenVirtual">True</Compiler>
<Compiler Name="Garbage">True</Compiler>
<Compiler Name="BoundsError">True</Compiler>
<Compiler Name="ZeroNilCompat">True</Compiler>
<Compiler Name="StringConstTruncated">True</Compiler>
<Compiler Name="ForLoopVarVarPar">True</Compiler>
<Compiler Name="TypedConstVarPar">True</Compiler>
<Compiler Name="AsgToTypedConst">True</Compiler>
<Compiler Name="CaseLabelRange">True</Compiler>
<Compiler Name="ForVariable">True</Compiler>
<Compiler Name="ConstructingAbstract">True</Compiler>
<Compiler Name="ComparisonFalse">True</Compiler>
<Compiler Name="ComparisonTrue">True</Compiler>
<Compiler Name="ComparingSignedUnsigned">True</Compiler>
<Compiler Name="CombiningSignedUnsigned">True</Compiler>
<Compiler Name="UnsupportedConstruct">True</Compiler>
<Compiler Name="FileOpen">True</Compiler>
<Compiler Name="FileOpenUnitSrc">True</Compiler>
<Compiler Name="BadGlobalSymbol">True</Compiler>
<Compiler Name="DuplicateConstructorDestructor">True</Compiler>
<Compiler Name="InvalidDirective">True</Compiler>
<Compiler Name="PackageNoLink">True</Compiler>
<Compiler Name="PackageThreadVar">True</Compiler>
<Compiler Name="ImplicitImport">True</Compiler>
<Compiler Name="HPPEMITIgnored">True</Compiler>
<Compiler Name="NoRetVal">True</Compiler>
<Compiler Name="UseBeforeDef">True</Compiler>
<Compiler Name="ForLoopVarUndef">True</Compiler>
<Compiler Name="UnitNameMismatch">True</Compiler>
<Compiler Name="NoCFGFileFound">True</Compiler>
<Compiler Name="MessageDirective">True</Compiler>
<Compiler Name="ImplicitVariants">True</Compiler>
<Compiler Name="UnicodeToLocale">True</Compiler>
<Compiler Name="LocaleToUnicode">True</Compiler>
<Compiler Name="ImagebaseMultiple">True</Compiler>
<Compiler Name="SuspiciousTypecast">True</Compiler>
<Compiler Name="PrivatePropAccessor">True</Compiler>
<Compiler Name="UnsafeType">False</Compiler>
<Compiler Name="UnsafeCode">False</Compiler>
<Compiler Name="UnsafeCast">False</Compiler>
<Compiler Name="OptionTruncated">True</Compiler>
<Compiler Name="WideCharReduced">True</Compiler>
<Compiler Name="DuplicatesIgnored">True</Compiler>
</Compiler>
<Linker>
<Linker Name="MapFile">0</Linker>
<Linker Name="OutputObjs">0</Linker>
<Linker Name="ConsoleApp">1</Linker>
<Linker Name="DebugInfo">False</Linker>
<Linker Name="RemoteSymbols">False</Linker>
<Linker Name="GenerateDRC">False</Linker>
<Linker Name="MinStackSize">16384</Linker>
<Linker Name="MaxStackSize">1048576</Linker>
<Linker Name="ImageBase">4194304</Linker>
<Linker Name="ExeDescription"></Linker>
</Linker>
<Directories>
<Directories Name="OutputDir"></Directories>
<Directories Name="UnitOutputDir"></Directories>
<Directories Name="PackageDLLOutputDir"></Directories>
<Directories Name="PackageDCPOutputDir"></Directories>
<Directories Name="SearchPath"></Directories>
<Directories Name="Packages">rtl;vcl;dbrtl;vcldb;vclx;adortl;dbxcds;dbexpress;vclib;ibxpress;IntrawebDB_72_90;Intraweb_72_90;xmlrtl;vclie;inet;inetdbbde;inetdbxpress;IndySystem;IndyCore;dclOfficeXP;VclSmp;soaprtl;dsnap;IndyProtocols;inetdb;bdertl;vcldbx;webdsnap;websnap;vclactnband;vclshlctrls;teeui;teedb;tee;dsnapcon;Rave60VCL</Directories>
<Directories Name="Conditionals"></Directories>
<Directories Name="DebugSourceDirs"></Directories>
<Directories Name="UsePackages">False</Directories>
</Directories>
<Parameters>
<Parameters Name="RunParams"></Parameters>
<Parameters Name="HostApplication"></Parameters>
<Parameters Name="Launcher"></Parameters>
<Parameters Name="UseLauncher">False</Parameters>
<Parameters Name="DebugCWD"></Parameters>
<Parameters Name="RemoteHost"></Parameters>
<Parameters Name="RemotePath"></Parameters>
<Parameters Name="RemoteLauncher"></Parameters>
<Parameters Name="RemoteCWD"></Parameters>
<Parameters Name="RemoteDebug">False</Parameters>
</Parameters>
<Language>
<Language Name="ActiveLang"></Language>
<Language Name="ProjectLang">$00000000</Language>
<Language Name="RootDir"></Language>
</Language>
<VersionInfo>
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
<VersionInfo Name="MajorVer">1</VersionInfo>
<VersionInfo Name="MinorVer">0</VersionInfo>
<VersionInfo Name="Release">0</VersionInfo>
<VersionInfo Name="Build">0</VersionInfo>
<VersionInfo Name="Debug">False</VersionInfo>
<VersionInfo Name="PreRelease">False</VersionInfo>
<VersionInfo Name="Special">False</VersionInfo>
<VersionInfo Name="Private">False</VersionInfo>
<VersionInfo Name="DLL">False</VersionInfo>
<VersionInfo Name="Locale">1031</VersionInfo>
<VersionInfo Name="CodePage">1252</VersionInfo>
</VersionInfo>
<VersionInfoKeys>
<VersionInfoKeys Name="CompanyName"></VersionInfoKeys>
<VersionInfoKeys Name="FileDescription"></VersionInfoKeys>
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="InternalName"></VersionInfoKeys>
<VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys>
<VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys>
<VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys>
<VersionInfoKeys Name="ProductName"></VersionInfoKeys>
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="Comments"></VersionInfoKeys>
</VersionInfoKeys>
</Delphi.Personality>
</BorlandProject>
<?xml version="1.0" encoding="utf-8"?>
<BorlandProject>
<Transactions>
<Transaction>2011.04.01 12:19:06.708.pas,E:\Documents and Settings\localadmin\My Documents\Borland Studio-Projekte\Unit1.pas=F:\Projekte\Timing\xml\whiterabbit\XMLdevice\XML_WR.pas</Transaction>
<Transaction>2011.04.01 12:19:06.708.dfm,E:\Documents and Settings\localadmin\My Documents\Borland Studio-Projekte\Unit1.dfm=F:\Projekte\Timing\xml\whiterabbit\XMLdevice\XML_WR.dfm</Transaction>
<Transaction>2011.04.04 09:14:45.590.pas,F:\Projekte\Timing\xml\whiterabbit\XMLdevice\Unit1.pas=F:\Projekte\Timing\xml\whiterabbit\XMLdevice\device_unit.pas</Transaction>
<Transaction>2011.04.04 12:02:24.754.pas,F:\Projekte\Timing\xml\whiterabbit\XMLdevice\device_unit.pas=F:\Projekte\Timing\xml\whiterabbit\XMLdevice\wrdevice_unit.pas</Transaction>
<Transaction>2011.04.04 16:05:21.523.pas,F:\Projekte\Timing\xml\whiterabbit\XMLdevice\Unit2.pas=F:\Projekte\Timing\xml\whiterabbit\XMLdevice\device_setup.pas</Transaction>
<Transaction>2011.04.04 16:05:21.523.dfm,F:\Projekte\Timing\xml\whiterabbit\XMLdevice\Unit2.dfm=F:\Projekte\Timing\xml\whiterabbit\XMLdevice\device_setup.dfm</Transaction>
<Transaction>2011.04.04 16:34:13.557.pas,F:\Projekte\Timing\xml\whiterabbit\XMLdevice\Unit1.pas=F:\Projekte\Timing\xml\whiterabbit\XMLdevice\Global.pas</Transaction>
<Transaction>2011.04.05 08:57:37.062.pas,F:\Projekte\Timing\xml\whiterabbit\XMLdevice\Unit2.pas=F:\Projekte\Timing\xml\whiterabbit\XMLdevice\UserSendData.pas</Transaction>
<Transaction>2011.04.05 08:57:37.062.dfm,F:\Projekte\Timing\xml\whiterabbit\XMLdevice\Unit2.dfm=F:\Projekte\Timing\xml\whiterabbit\XMLdevice\UserSendData.dfm</Transaction>
<Transaction>2011.04.06 13:59:40.907.pas,F:\Projekte\Timing\xml\whiterabbit\XMLdevice\UserSendData.pas=</Transaction>
<Transaction>2011.04.06 13:59:40.907.dfm,F:\Projekte\Timing\xml\whiterabbit\XMLdevice\UserSendData.dfm=</Transaction>
<Transaction>2011.04.06 15:32:39.998.pas,F:\Projekte\Timing\etherbone-core\api\etherbone.pas=</Transaction>
<Transaction>2011.04.06 15:41:11.594.pas,F:\Projekte\Timing\etherbone-core\GUI\XMLdevice\wrdevice_unit.pas=</Transaction>
<Transaction>2011.04.06 15:41:19.735.pas,F:\Projekte\Timing\etherbone-core\GUI\XMLdevice\UserSendData.pas=</Transaction>
<Transaction>2011.04.06 15:41:19.735.dfm,F:\Projekte\Timing\etherbone-core\GUI\XMLdevice\UserSendData.dfm=</Transaction>
<Transaction>2011.04.06 15:41:27.641.pas,F:\Projekte\Timing\etherbone-core\GUI\XMLdevice\Global.pas=</Transaction>
<Transaction>2011.04.06 15:41:29.485.pas,F:\Projekte\Timing\etherbone-core\api\etherbone.pas=</Transaction>
<Transaction>2011.04.06 15:41:30.172.pas,F:\Projekte\Timing\etherbone-core\GUI\XMLdevice\device_setup.pas=</Transaction>
<Transaction>2011.04.06 15:41:30.172.dfm,F:\Projekte\Timing\etherbone-core\GUI\XMLdevice\device_setup.dfm=</Transaction>
<Transaction>2011.04.08 15:55:31.433.pas,F:\Projekte\Timing\etherbone-core\GUI\XMLdevice\Unit1.pas=F:\Projekte\Timing\etherbone-core\GUI\XMLdevice\XML_collector.pas</Transaction>
</Transactions>
</BorlandProject>
-$A8
-$B+
-$C+
-$D+
-$E-
-$F-
-$G+
-$H+
-$I+
-$J-
-$K-
-$L+
-$M-
-$N+
-$O-
-$P+
-$Q-
-$R-
-$S-
-$T-
-$U-
-$V+
-$W-
-$X+
-$YD
-$Z1
-cg
-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
-H+
-W+
-M
-$M16384,1048576
-K$00400000
-LE"E:\Documents and Settings\localadmin\My Documents\Borland Studio-Projekte\Bpl"
-LN"E:\Documents and Settings\localadmin\My Documents\Borland Studio-Projekte\Bpl"
-w-UNSAFE_TYPE
-w-UNSAFE_CODE
-w-UNSAFE_CAST
program WR;
uses
Forms,
XML_WR in 'XML_WR.pas' {Form1},
wrdevice_unit in 'wrdevice_unit.pas',
device_setup in 'device_setup.pas' {DevSet_Form},
device_unit in 'device_unit.pas',
Global in 'Global.pas',
UserSendData in 'UserSendData.pas' {SendUserdata_Form},
etherbone in '..\..\api\etherbone.pas',
XML_collector in 'XML_collector.pas';
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TDevSet_Form, DevSet_Form);
Application.CreateForm(TSendUserdata_Form, SendUserdata_Form);
Application.Run;
end.
object Form1: TForm1
Left = 0
Top = 0
Width = 657
Height = 601
AutoSize = True
Caption = 'whiterabbit'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = []
Menu = MainMenu1
OldCreateOrder = False
OnClose = FormClose
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 19
object Panel1: TPanel
Left = 0
Top = 0
Width = 457
Height = 385
BevelInner = bvLowered
TabOrder = 0
object Label1: TLabel
Left = 16
Top = 7
Width = 66
Height = 19
Caption = 'XML Tree'
end
object XML_TreeView: TTreeView
Left = 15
Top = 31
Width = 426
Height = 338
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Tahoma'
Font.Style = [fsBold]
Indent = 19
ParentFont = False
TabOrder = 0
end
end
object Panel2: TPanel
Left = 0
Top = 384
Width = 504
Height = 163
BevelInner = bvLowered
TabOrder = 1
object messages_ListBox: TListBox
Left = 8
Top = 8
Width = 487
Height = 129
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = []
ItemHeight = 18
ParentFont = False
TabOrder = 0
end
object Clear_Button: TButton
Left = 429
Top = 140
Width = 65
Height = 17
Caption = 'Clear'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
TabOrder = 1
OnClick = Clear_ButtonClick
end
end
object Panel3: TPanel
Left = 448
Top = 0
Width = 201
Height = 386
BevelInner = bvLowered
TabOrder = 2
object Panel4: TPanel
Left = 0
Top = 0
Width = 201
Height = 49
BevelInner = bvLowered
TabOrder = 0
object Label2: TLabel
Left = 24
Top = 13
Width = 91
Height = 19
Caption = 'Device active'
end
object DeviceActiv_Shape: TShape
Left = 148
Top = 11
Width = 33
Height = 25
Brush.Color = clRed
Shape = stCircle
end
end
object Panel5: TPanel
Left = 0
Top = 46
Width = 201
Height = 108
BevelInner = bvLowered
TabOrder = 1
object Label3: TLabel
Left = 8
Top = 8
Width = 46
Height = 19
Caption = 'Device'
end
object SendData_Button: TButton
Left = 7
Top = 39
Width = 105
Height = 25
Caption = 'Send Data'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
TabOrder = 0
OnClick = SendData_ButtonClick
end
object Panel6: TPanel
Left = 0
Top = 67
Width = 201
Height = 41
BevelInner = bvLowered
TabOrder = 1
object ReadData_Button: TButton
Left = 8
Top = 8
Width = 105
Height = 25
Caption = 'Read Data'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
TabOrder = 0
OnClick = ReadData_ButtonClick
end
object LoopRD_CheckBox: TCheckBox
Left = 129
Top = 12
Width = 65
Height = 17
Caption = 'Loop'
Enabled = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
TabOrder = 1
OnClick = LoopRD_CheckBoxClick
end
end
object LoopSD_CheckBox: TCheckBox
Left = 128
Top = 43
Width = 65
Height = 17
Caption = 'Loop'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
TabOrder = 2
OnClick = LoopSD_CheckBoxClick
end
end
object Panel7: TPanel
Left = 0
Top = 152
Width = 201
Height = 113
BevelInner = bvLowered
TabOrder = 2
object Label4: TLabel
Left = 8
Top = 16
Width = 48
Height = 18
Caption = 'Pakets:'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
end
object Label5: TLabel
Left = 8
Top = 56
Width = 62
Height = 18
Caption = 'Sendings:'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
end
object PaketsCnt_Panel: TPanel
Left = 80
Top = 15
Width = 107
Height = 26
BevelInner = bvLowered
Caption = '0'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
TabOrder = 0
end
object Sendings_Panel: TPanel
Left = 80
Top = 52
Width = 107
Height = 26
BevelInner = bvLowered
Caption = '0'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
TabOrder = 1
end
object ClearCnt_Button: TButton
Left = 120
Top = 87
Width = 65
Height = 17
Caption = 'Clear'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
TabOrder = 2
OnClick = ClearCnt_ButtonClick
end
end
end
object PollSocket_Timer: TTimer
Interval = 100
OnTimer = PollSocket_TimerTimer
Left = 512
Top = 392
end
object OpenDialog1: TOpenDialog
Filter = 'XML Files |*.xml'
Left = 512
Top = 424
end
object MainMenu1: TMainMenu
Left = 512
Top = 456
object D1: TMenuItem
Caption = 'Datei'
object XMLLaden1: TMenuItem
Caption = 'XML-Laden'
OnClick = XMLLaden1Click
end
object Exit1: TMenuItem
Caption = 'Exit'
OnClick = Exit1Click
end
end
object Device1: TMenuItem
Caption = 'Device'
object Setup1: TMenuItem
Caption = 'Setup'
OnClick = Setup1Click
end
object ConnectDevice1: TMenuItem
Caption = 'Connect Device'
OnClick = ConnectDevice1Click
end
object DisconnectDevice1: TMenuItem
Caption = 'Disconnect Device'
OnClick = DisconnectDevice1Click
end
end
object Extras1: TMenuItem
Caption = 'Extras'
object SendManual1: TMenuItem
Caption = 'Send Manual'
OnClick = SendManual1Click
end
end
end
object XMLDoc: TXMLDocument
Left = 512
Top = 488
DOMVendorDesc = 'MSXML'
end
object Lamp_Timer: TTimer
OnTimer = Lamp_TimerTimer
Left = 544
Top = 392
end
end
This diff is collapsed.
unit XML_collector;
interface
uses
xmldom, XMLIntf, StdCtrls, ComCtrls, ExtCtrls, Menus, msxmldom,
SysUtils, Variants, XMLDoc, Global;
type
TXML_collector = class
public
{ Public-Deklarationen }
function AnalyseXMLTree (deep1: IXMLNodeList):boolean;
procedure ConvertData(var data:longword;BitPosL:Byte;BitPosH:Byte);
private
procedure ClearDataClrArray();
{ Private-Deklarationen }
end;
implementation
//durchsucht den XML-baum und sammelt daten [value] und fomatierungsanweisungen
//bekommt den XML Baum mit der tiefe 1-> deviceXXX ab dann gilt:
//deep1 (led/timer/signal) keine daten keine fomatierungsanweisungen
//deep2 (ctrl/settime/gettime etc) evt. ctr-daten vorhanden
//deep3 (onoff/pwmoutput/startstop etc) endknoten enthalten sende daten/formatierungen
function TXML_collector.AnalyseXMLTree(deep1: IXMLNodeList):boolean;
var deep1_index:integer;
deep2_index:integer;
deep2 : IXMLNodeList;
deep3_index:integer;
deep3 : IXMLNodeList;
BitPosL :Byte;
BitPosH :Byte;
BitPosStr :String;
Data :longword;
i :integer;
StringTemp :string;
begin
ClearDataClrArray();
DeviceCtrRegCount:= 0;
DeviceDataCount := 0;
deep1_index:=0;
while (deep1_index <= deep1.Count-1) do begin //deep1 hat keine daten(led/timer/signal)
deep2:= deep1[deep1_index].ChildNodes;
deep2_index:=0;
while (deep2_index <= deep2.Count-1) do begin //deep 2 hat daten f. ctrl-reg.
deep3:= deep2[deep2_index].ChildNodes;
deep3_index:=0;
if(deep3.Count = 0) then begin //letzte ebene nur daten x
DeviceData[DeviceDataCount]:= 0;
end;
while (deep3_index <= deep3.Count-1) do begin //reine daten, keine ctr
if(deep3[deep3_index].GetAttribute('bitpos')<>'')then begin
BitPosStr:= VarToStr(deep3[deep3_index].GetAttribute('bitpos'));
StringTemp:='';
i:=1;
while BitPosStr[i] <> '.' do begin
StringTemp:= StringTemp+ BitPosStr[i];
i:=i+1;
end;
try
BitPosL:=StrToInt(StringTemp);
except
BitPosL:=0;
end;
i:=i+1;
StringTemp:='';
while i <= Length (BitPosStr) do begin
StringTemp:= StringTemp+ BitPosStr[i];
i:=i+1;
end;
try
BitPosH:=StrToInt(StringTemp);
except
BitPosH:=0;
end;
data:= StrToInt('$'+VarToStr(deep3[deep3_index].GetAttribute('value')));
ConvertData(data,BitPosL,BitPosH);
DeviceData[DeviceDataCount]:= DeviceData[DeviceDataCount] OR data;
end;
deep3_index:=deep3_index + 1;
end;//deep3
DeviceCtrReg[DeviceCtrRegCount]:= StrToInt('$'+VarToStr(deep2[deep2_index].GetAttribute('value')));
DeviceCtrRegCount:=DeviceCtrRegCount+1;
DeviceDataCount:=DeviceDataCount+1;
deep2_index:=deep2_index+1;
end;//deep2
deep1_index:=deep1_index+1;
end;//deep1
end;
//convertiere data nach vorgabe im XML Baum
procedure TXML_collector.ConvertData(var data:longword;BitPosL:Byte;BitPosH:Byte);
var mask:longword;
begin
{ mask:=$FFFF;
mask:=mask SHL (BitPosH-BitPosL);
data:=data XOR mask; }
data:= data SHL BitPosL;
end;
//Loesche Control Register array und Daten array
procedure TXML_collector.ClearDataClrArray();
var i:integer;
begin
for i:= 0 to ArrayRange do begin
DeviceCtrReg[i] := 0;
DeviceData[i] := 0;
end;
end;
end.
object DevSet_Form: TDevSet_Form
Left = 0
Top = 0
Width = 329
Height = 251
AutoSize = True
Caption = 'Device Setup'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 18
object Panel1: TPanel
Left = 0
Top = 0
Width = 321
Height = 161
BevelInner = bvLowered
TabOrder = 0
object Label1: TLabel
Left = 24
Top = 16
Width = 92
Height = 18
Caption = 'Device Adress'
end
object Label2: TLabel
Left = 24
Top = 80
Width = 87
Height = 18
Caption = 'Port Nr.(hex)'
end
object DevAdr_Edit: TEdit
Left = 24
Top = 37
Width = 265
Height = 26
TabOrder = 0
end
object PortNr_Edit: TEdit
Left = 24
Top = 104
Width = 265
Height = 26
TabOrder = 1
end
end
object OK: TButton
Left = 96
Top = 168
Width = 145
Height = 49
Caption = 'OK'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
TabOrder = 1
OnClick = OKClick
end
end
// Copyright (C) 2011
// GSI Helmholtzzentrum fr Schwerionenforschung GmbH
//
// Author: M.Zweig
//
unit device_setup;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls,etherbone, Global;
type
TDevSet_Form = class(TForm)
Panel1: TPanel;
DevAdr_Edit: TEdit;
Label1: TLabel;
Label2: TLabel;
PortNr_Edit: TEdit;
OK: TButton;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure OKClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
DevSet_Form: TDevSet_Form;
implementation
{$R *.dfm}
procedure TDevSet_Form.OKClick(Sender: TObject);
var error:boolean;
begin
error:= false;
myDNSAdress:= DevAdr_Edit.Text;
try
myAddress := StrToInt('$'+ PortNr_Edit.Text);
except
Application.MessageBox('This is not a valid hex-adress', 'So What ?', 16);
error:= true;
end;
if not (error) then DevSet_Form.Close;
end;
procedure TDevSet_Form.FormShow(Sender: TObject);
begin
DevAdr_Edit.Text:= myDNSAdress;
PortNr_Edit.Text:= IntToHex(myAddress, 4);
end;
procedure TDevSet_Form.FormCreate(Sender: TObject);
begin
DevAdr_Edit.Text:= First_DNSAdress;
PortNr_Edit.Text:= First_PortNumber;
myDNSAdress:= First_DNSAdress;
myAddress := StrToInt('$'+ First_PortNumber);
end;
end.
unit device_unit;
interface
implementation
end.
// Copyright (C) 2011
// GSI Helmholtzzentrum fr Schwerionenforschung GmbH
//
// Author: M.Zweig
//
unit wrdevice_unit;
interface
uses etherbone,SysUtils,StdCtrls;
type
Twrdevice = class
constructor Create;
function DeviceOpen(netaddress:eb_network_address_t;address :eb_address_t;var status:string):boolean;
function DeviceClose(var status:string):boolean;
function DeviceCacheWR(address :eb_address_t;data: eb_data_t;var status:string):boolean;
function DeviceCacheSend(var status:string):boolean;
function DeviceRead(cb:eb_read_callback_t;address :eb_address_t;var status:string):boolean;
procedure DevicePoll();
private
IsDeviceOpen:boolean;
socket :eb_socket_t;
device :eb_device_t;
public
end;
implementation
var my_status: eb_status;
constructor Twrdevice.Create;
begin
inherited;
IsDeviceOpen:=false;
end;
function Twrdevice.DeviceOpen(netaddress:eb_network_address_t;address :eb_address_t;var status:string):boolean;
begin
if not (IsDeviceOpen) then begin
IsDeviceOpen:= true;
// eb socket oeffnen
my_status:=eb_socket_open(0, 0, @socket);
if(my_status<> EB_OK) then begin
status:='ERROR: Failed to open Etherbone socket';
IsDeviceOpen:=false;
end else status:='Open Etherbone socket successful';
// etherbone device oeffnen
if(IsDeviceOpen) then begin
my_status:= eb_device_open(socket, netaddress, EB_DATAX, @device);
if(my_status<> EB_OK) then begin
status:='ERROR: Failed to open Etherbone device';
IsDeviceOpen:=false;
end else status:= 'Open Etherbone device successful';
end;
end;
DeviceOpen:= IsDeviceOpen;
end;
function Twrdevice.DeviceClose(var status:string):boolean;
var my_status:eb_status ;
begin
if(IsDeviceOpen) then begin
// etherbone device schliessen
my_status:= eb_device_close(device);
if(my_status<> EB_OK) then status:= 'ERROR: Failed to close Etherbone device'
else begin
status:='Close Etherbone device successful';
IsDeviceOpen:=false;
end;
// eb socket schliesen
my_status:= eb_socket_close(socket);
if(my_status<> EB_OK) then status:='ERROR: Failed to close Etherbone socket'
else begin
status:='Close Etherbone socket successful';
IsDeviceOpen:=false;
end;
end else status:='Nothing to close here';
DeviceClose:= not(IsDeviceOpen);
end;
function Twrdevice.DeviceCacheWR(address :eb_address_t;data: eb_data_t;var status:string):boolean;
begin
if(IsDeviceOpen) then begin
// daten schreiben
eb_device_write(device, address, data);
//eb_device_flush(device);
status:='Data sending:'+IntToHex(data,32);
DeviceCacheWR:= true;
end else begin
status:='ERROR: Device/socket not open yet';
DeviceCacheWR:= false;
end;
end;
function Twrdevice.DeviceCacheSend(var status:string):boolean;
begin
DeviceCacheSend:=false;
if(IsDeviceOpen) then begin
eb_device_flush(device);
status:= 'The Cache is gone';
DeviceCacheSend:=true;
end else status:= 'ERROR: Device/socket not open yet fool';
end;
function Twrdevice.DeviceRead(cb:eb_read_callback_t;address :eb_address_t;var status:string):boolean;
var stop:integer;
begin
DeviceRead:=false;
if(IsDeviceOpen) then begin
eb_device_read(device, address, @stop, cb);
eb_device_flush(device);
DeviceRead:= true;
end else status:='ERROR: Device/socket not open, buddy';
end;
procedure Twrdevice.DevicePoll();
begin
if(IsDeviceOpen) then eb_socket_poll(socket);
end;
end.
*/*.o
etherbone.def
etherbone.dll
libetherbone.dll.a
libetherbone.a
libetherbone.so*
Support for posix/win32/lm32
Support for 16/32/64 bit processors
Simultaneous master and slave operation
- user can attach software devices to bus
Maximum bus width autonegotiation (8/16/32/64)
- sub-word access automagically controls select lines
Post-cycle operation inspection
- individual operation error flags
SDWB support
- all included tools respect target device endian
Cycle compression
- library compacts supplied IO sequence into records
TCP/UDP transports
- TCP allows cycles with unconstrained length
IPv6 support
Proxy/tunnel support
- use ssh for part of the link on the way to a UDP slave
Wireshark script adds support for Etherbone packets
Event loop can be integrated with external libraries
# The installation prefix default to /usr/local, but can be set on the cmdline
PREFIX ?= /usr/local
STAGING ?=
EXTRA_FLAGS ?=
#BUILD = lm32
#BUILD = win32
BUILD = unix
ifeq ($(BUILD), lm32)
TARGET = lm32-elf-
FLAGS = -I/home/mkreider/hdlprojects/wrpc-sw/ptp-noposix/libptpnetif -I/home/mkreider/hdlprojects/wrpc-sw/lib
endif
ifeq ($(BUILD), win32)
LIBS = -lwsock32 -lws2_32
LIBRARY = etherbone.dll
EXTRA = libetherbone.dll.a
endif
ifeq ($(BUILD), unix)
FLAGS = -fPIC
LIBS = -Wl,-rpath,$(PREFIX)/lib
LIBRARY = libetherbone.so
EXTRA = libetherbone.so.*
endif
ifeq ($(BUILD), lm32)
TOOLS =
TESTS =
CPLUSPLUS =
TRANSPORT = transport/lm32.c
else
TOOLS = tools/eb-read tools/eb-write tools/eb-put tools/eb-get tools/eb-snoop tools/eb-ls tools/eb-find tools/eb-tunnel tools/eb-discover
TESTS = test/sizes test/loopback test/etherbonetest
CPLUSPLUS = glue/cplusplus.cpp
TRANSPORT = transport/posix-ip.c \
transport/posix-udp.c \
transport/posix-tcp.c \
transport/tunnel.c \
transport/dev.c \
transport/transports.c \
transport/run.c
endif
ARCHIVE = libetherbone.a
FLAGS := $(FLAGS) -Wall -O2
#FLAGS := $(FLAGS) -DEB_USE_DYNAMIC # deterministic untill table overflow (default)
#FLAGS := $(FLAGS) -DEB_USE_STATIC=200 # fully deterministic
#FLAGS := $(FLAGS) -DEB_USE_MALLOC # non-deterministic
#FLAGS := $(FLAGS) -DDISABLE_SLAVE
#FLAGS := $(FLAGS) -DDISABLE_MASTER
CFLAGS = $(EXTRA_FLAGS) $(FLAGS) -Wmissing-declarations -Wmissing-prototypes
CXXFLAGS= $(EXTRA_FLAGS) $(FLAGS)
CC = $(TARGET)gcc
CXX = $(TARGET)g++
OBJECTS = $(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SOURCES)))
SOURCES = memory/static.c \
memory/dynamic.c \
memory/array.c \
memory/malloc.c \
format/slave.c \
format/master.c \
glue/widths.c \
glue/operation.c \
glue/cycle.c \
glue/device.c \
glue/format.c \
glue/socket.c \
glue/handler.c \
glue/readwrite.c \
glue/strncasecmp.c \
glue/sdb.c \
$(CPLUSPLUS) \
$(TRANSPORT)
all: glue/version.h $(TOOLS) $(TESTS) $(ARCHIVE) $(LIBRARY)
install: all
mkdir -p $(STAGING)$(PREFIX)/bin $(STAGING)$(PREFIX)/include $(STAGING)$(PREFIX)/lib/pkgconfig
cp -d $(LIBRARY) $(EXTRA) $(ARCHIVE) $(STAGING)$(PREFIX)/lib
cp etherbone.h $(STAGING)$(PREFIX)/include
sed "s#@PREFIX@#$(PREFIX)#" < etherbone.pc.in > $(STAGING)$(PREFIX)/lib/pkgconfig/etherbone.pc
cp $(TOOLS) $(STAGING)$(PREFIX)/bin
glue/version.h::
git log -n1 --pretty="format:%H" . > git.version_full
git log -n1 --pretty="format:%ci" . > git.date_full
cut -b1-8 < git.version_full > git.version_short
date +%Y%m%d -f git.date_full > git.date_short
sed 's/@EB_VERSION_FULL@/'"`cat git.version_full`"'/;s/@EB_VERSION_SHORT@/'"`cat git.version_short`"'/;s/@EB_DATE_FULL@/'"`cat git.date_full`"'/;s/@EB_DATE_SHORT@/'"`cat git.date_short`"'/' < $@.in > $@.tmp
if ! test -f $@ || ! diff $@ $@.tmp > /dev/null; then mv $@.tmp $@; fi
rm -f $@.tmp git.version_full git.date_full git.version_short git.date_short
$(ARCHIVE): $(OBJECTS)
rm -f $@
$(TARGET)ar rcs $@ $^
$(TARGET)ranlib $@
etherbone.dll: $(OBJECTS)
$(TARGET)g++ $(CXXFLAGS) -shared -Wl,--out-implib=libetherbone.dll.a -Wl,--output-def,etherbone.def -o $@ $^ $(LIBS)
libetherbone.so: libetherbone.so.1
rm -f $@; ln -s $< $@
libetherbone.so.1: libetherbone.so.1.0
rm -f $@; ln -s $< $@
libetherbone.so.1.0: $(OBJECTS)
$(TARGET)g++ $(CXXFLAGS) -shared -Wl,-soname,libetherbone.so.1 -o $@ $^ $(LIBS)
tools/%: tools/%.c $(LIBRARY)
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
tools/eb-tunnel: tools/eb-tunnel.c $(ARCHIVE)
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
tools/eb-discover: tools/eb-discover.c $(ARCHIVE)
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
test/%: test/%.c $(LIBRARY)
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
test/%: test/%.cpp $(LIBRARY)
$(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
clean:
rm -f $(LIBRARY) $(EXTRA) $(ARCHIVE) $(OBJECTS) $(TOOLS)
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $^
%.o: %.cpp
$(CXX) $(CXXFLAGS) -o $@ -c $^
This diff is collapsed.
// Copyright (C) 2011
// GSI Helmholtzzentrum fr Schwerionenforschung GmbH
//
// Author: Wesley W. Terpstra <w.terpstra@gsi.de>
// converted in Delphi: M.Zweig
// not everything was converted
unit etherbone;
interface
uses
Classes, SysUtils;
// Opaque structural types
type eb_socket = record end;
type eb_socket_t = ^eb_socket;
type eb_device = record end;
type eb_device_t = ^eb_device;
type eb_cycle = record end;
type eb_cycle_t = ^eb_cycle;
// Configurable types */
type eb_address_t = Int64;
type eb_data_t = Int64;
// Control types */
type eb_descriptor_t = Integer;
type eb_network_address_t = PChar;
//Status codes
type eb_status=(
EB_OK=0,
EB_FAIL,
EB_ABORT,
EB_ADDRESS,
EB_OVERFLOW,
EB_BUSY
);
type eb_mode =(
EB_UNDEFINED=-1,
EB_FIFO,
EB_LINEAR
);
type eb_status_t = eb_status;
type eb_mode_t = eb_mode;
//Bitmasks cannot be enums */
type eb_width_t = Word;
const
EB_DATA8 =$1;
EB_DATA16 =$2;
EB_DATA32 =$4;
EB_DATA64 =$8;
EB_DATAX =$f;
// Callback types
type eb_user_data_t = Pointer;
type eb_read_callback_t =procedure (var user: eb_user_data_t;
var status: eb_status_t;
var result:eb_data_t );cdecl;
type b_cycle_callback_t = procedure(var user: eb_user_data_t;
var status: eb_status_t;
var result:eb_data_t );cdecl;
//todo:
{ Handler descriptor */
typedef struct eb_handler {
eb_address_t base;
eb_address_t mask;
eb_user_data_t data;
eb_data_t (*read) (eb_user_data_t, eb_address_t, eb_width_t);
void (*write)(eb_user_data_t, eb_address_t, eb_width_t, eb_data_t);
}{ *eb_handler_t; }
{/****************************************************************************/
/* C99 API */
/****************************************************************************/
/* Open an Etherbone socket for communicating with remote devices.
* The port parameter is optional; 0 lets the operating system choose.
* After opening the socket, poll must be hooked into an event loop.
*
* Return codes:
* OK - successfully open the socket port
* FAIL - operating system forbids access
* BUSY - specified port is in use (only possible if port != 0)
*/}
function eb_socket_open(port:Integer;
flags:Integer;
result:eb_socket_t):eb_status_t;cdecl; external 'etherbone.dll';
{/* Block until the socket is ready to be polled.
* This function is useful if your program has no event loop of its own.
* It returns the time expended while waiting.
*/ }
function eb_socket_block( socket:eb_socket_t;
timeout_us:Integer):Integer;cdecl; external 'etherbone.dll';
{ /* Close the Etherbone socket.
* Any use of the socket after successful close will probably segfault!
*
* Return codes:
* OK - successfully closed the socket and freed memory
* BUSY - there are open devices on this socket
*/ }
function eb_socket_close(socket: eb_socket_t ):eb_status_t;cdecl; external 'etherbone.dll';
{/* Poll the Etherbone socket for activity.
* This function must be called regularly to receive incoming packets.
* Either call poll very often or hook a read listener on its descriptor.
* Callback functions are only executed from within the poll function.
*
* Return codes:
* OK - poll complete; no further packets to process
* FAIL - socket error (probably closed)
*/ }
function eb_socket_poll(socket: eb_socket_t ):eb_status_t;cdecl; external 'etherbone.dll';
{/* Open a remote Etherbone device.
* This resolves the address and performs Etherbone end-point discovery.
* From the mask of proposed bus widths, one will be selected.
* The default port is taken as 0xEBD0.
*
* Return codes:
* OK - the remote etherbone device is ready
* FAIL - the remote address did not identify itself as etherbone conformant
* ADDRESS - the network address could not be parsed
* ABORT - could not negotiate an acceptable data bus width
*/ }
function eb_device_open(socket: eb_socket_t;
ip_port: eb_network_address_t;
proposed_widths: eb_width_t;
result: eb_device_t):eb_status_t;cdecl; external 'etherbone.dll';
{* Close a remote Etherbone device.
*
* Return codes:
* OK - associated memory has been freed
* BUSY - there are outstanding wishbone cycles on this device
*/ }
function eb_device_close(device: eb_device_t ):eb_status_t;cdecl; external 'etherbone.dll';
{* Flush commands queued on the device out the socket.
*/ }
procedure eb_device_flush(socket: eb_device_t );cdecl; external 'etherbone.dll';
{/* Perform a single-read wishbone cycle.
* Semantically equivalent to cycle_open, cycle_read, cycle_close, device_flush.
*
* The given address is read on the remote device.
* The callback cb(user, status, data) is invoked with the result.
* The user parameter is passed through uninspected to the callback.
*
* Status codes:
* OK - the operation completed successfully
* FAIL - the operation failed due to an wishbone ERR_O signal
* ABORT - an earlier operation failed and this operation was thus aborted
*/ }
procedure eb_device_read(device : eb_device_t;
address: eb_address_t;
user : eb_user_data_t;
cb : eb_read_callback_t);cdecl; external 'etherbone.dll';
{/* Perform a single-write wishbone cycle.
* Semantically equivalent to cycle_open, cycle_write, cycle_close, device_flush.
*
* data is written to the given address on the remote device.
*/ }
procedure eb_device_write(device : eb_device_t;
address :eb_address_t;
data :eb_data_t);cdecl; external 'etherbone.dll';
implementation
end.
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: etherbone
Description: Wishbone serial protocol library
Version: 1.0
Libs: -L${libdir} -letherbone
Cflags: -I${includedir}
/** @file bigendian.h
* @brief Conversion of 16/32/64 bit width registers to/from bigendian.
*
* Copyright (C) 2011-2012 GSI Helmholtz Centre for Heavy Ion Research GmbH
*
* Default to using system-provided methods wherever possible.
*
* @author Wesley W. Terpstra <w.terpstra@gsi.de>
*
* @bug None!
*
*******************************************************************************
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*******************************************************************************
*/
#ifndef EB_BIGENDIAN_H
#define EB_BIGENDIAN_H
#if defined(__linux__)
#include <endian.h>
#elif defined(__FreeBSD__) || defined(__NetBSD__)
#include <sys/endian.h>
#elif defined(__OpenBSD__)
#include <sys/endian.h>
#define be16toh(x) betoh16(x)
#define be32toh(x) betoh32(x)
#define be64toh(x) betoh64(x)
#endif
#ifndef htobe64
/* Portable version */
#if defined(__WIN32)
#include <winsock2.h>
#elif defined(__lm32__)
/* bigendian */
#define htons(x) x
#define htonl(x) x
#else
#include <arpa/inet.h>
#endif
#define htobe16(x) htons(x)
#define htobe32(x) htonl(x)
#define be16toh(x) htons(x)
#define be32toh(x) htonl(x)
/* Only provide when needed */
#ifdef EB_NEED_BIGENDIAN_64
static uint64_t htobe64(uint64_t x) {
union {
uint64_t y;
uint32_t z[2];
} u;
u.z[0] = htonl(x >> 32);
u.z[1] = htonl(x);
return u.y;
}
#define be64toh(x) htobe64(x)
#endif
#endif
#endif
/** @file format.h
* @brief Functions for formatting Etherbone packet payload
*
* Copyright (C) 2011-2012 GSI Helmholtz Centre for Heavy Ion Research GmbH
*
* As much as possible format/ desribes only the packet format and not logic.
*
* @author Wesley W. Terpstra <w.terpstra@gsi.de>
*
* @bug None!
*
*******************************************************************************
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
*/
#ifndef EB_FORMAT_H
#define EB_FORMAT_H
#include "../glue/socket.h"
#include "../glue/device.h"
#include "../transport/transport.h"
#define EB_HEADER_PF 0x01
#define EB_HEADER_PR 0x02
#define EB_HEADER_NR 0x04
#define EB_RECORD_BCA 0x80
#define EB_RECORD_RCA 0x40
#define EB_RECORD_RFF 0x20
#define EB_RECORD_CYC 0x08
#define EB_RECORD_WCA 0x04
#define EB_RECORD_WFF 0x02
/* sizeof(eb_max_align_t) is the maximum supported alignment. */
typedef union {
eb_data_t data;
eb_address_t address;
} eb_max_align_t;
EB_PRIVATE int eb_device_slave(eb_socket_t socketp, eb_transport_t transportp, eb_device_t devicep, eb_user_data_t data, eb_descriptor_callback_t ready, int *completed);
EB_PRIVATE eb_status_t eb_device_flush(eb_device_t device, int *completed);
#endif
This diff is collapsed.
This diff is collapsed.
/** @file cplusplus.cpp
* @brief Implement C++ bindings not done well inline.
*
* Copyright (C) 2011-2012 GSI Helmholtz Centre for Heavy Ion Research GmbH
*
* Most of the C++ binding is inlined in etherbone.h.
*
* @author Wesley W. Terpstra <w.terpstra@gsi.de>
*
* @bug None!
*
*******************************************************************************
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
*/
#define ETHERBONE_IMPL
#include "../etherbone.h"
namespace etherbone {
eb_status_t eb_proxy_read_handler(eb_user_data_t data, eb_address_t address, eb_width_t width, eb_data_t* ptr) {
Handler* handler = reinterpret_cast<Handler*>(data);
return handler->read(address, width, ptr);
}
eb_status_t eb_proxy_write_handler(eb_user_data_t data, eb_address_t address, eb_width_t width, eb_data_t value) {
Handler* handler = reinterpret_cast<Handler*>(data);
return handler->write(address, width, value);
}
Handler::~Handler() {
}
eb_status_t Device::sdb_find_by_identity(uint64_t vendor_id, uint32_t device_id, std::vector<struct sdb_device>& output) {
eb_status_t status;
int size = 32; /* initial size */
output.resize(size);
if ((status = eb_sdb_find_by_identity(device, vendor_id, device_id, &output[0], &size)) != EB_OK) {
output.clear();
return status;
}
if (size > (int)output.size()) {
output.resize(size);
/* try again with large enough array */
status = eb_sdb_find_by_identity(device, vendor_id, device_id, &output[0], &size);
}
if (status == EB_OK) {
output.resize(size);
} else {
output.clear();
}
return status;
}
}
/** @file cycle.c
* @brief Implement the Etherbone cycle data structure.
*
* Copyright (C) 2011-2012 GSI Helmholtz Centre for Heavy Ion Research GmbH
*
* The only fishy business is the use of 'dead' to mark cycles which
* run out of memory when enqueueing operations.
*
* @author Wesley W. Terpstra <w.terpstra@gsi.de>
*
* @bug None!
*
*******************************************************************************
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
*/
#define ETHERBONE_IMPL
#include "operation.h"
#include "cycle.h"
#include "device.h"
#include "../memory/memory.h"
static void eb_block_f(eb_user_data_t user, eb_device_t device, eb_operation_t operation, eb_status_t status) {
eb_status_t* ptr = (eb_status_t*)user;
*ptr = status;
}
eb_device_t eb_cycle_device(eb_cycle_t cyclep) {
struct eb_cycle* cycle;
cycle = EB_CYCLE(cyclep);
return cycle->un_link.device;
}
eb_status_t eb_cycle_open(eb_device_t devicep, eb_user_data_t user, eb_callback_t cb, eb_cycle_t* result) {
eb_cycle_t cyclep;
struct eb_cycle* cycle;
struct eb_device* device;
cyclep = eb_new_cycle();
if (cyclep == EB_NULL) {
*result = EB_NULL;
return EB_OOM;
}
device = EB_DEVICE(devicep);
/* Is the device closing? */
if (device->un_link.passive == devicep) {
eb_free_cycle(cyclep);
*result = EB_NULL;
return EB_FAIL;
}
cycle = EB_CYCLE(cyclep);
cycle->user_data = user;
cycle->un_ops.first = EB_NULL;
cycle->un_link.device = devicep;
if (cb) {
cycle->callback = cb;
} else {
cycle->callback = &eb_block_f;
}
++device->unready;
*result = cyclep;
return EB_OK;
}
void eb_cycle_destroy(eb_cycle_t cyclep) {
struct eb_cycle* cycle;
eb_operation_t i, next;
cycle = EB_CYCLE(cyclep);
if (cycle->un_ops.dead != cyclep) {
for (i = cycle->un_ops.first; i != EB_NULL; i = next) {
next = EB_OPERATION(i)->next;
eb_free_operation(i);
}
}
cycle->un_ops.first = EB_NULL;
}
void eb_cycle_abort(eb_cycle_t cyclep) {
struct eb_cycle* cycle;
struct eb_device* device;
cycle = EB_CYCLE(cyclep);
device = EB_DEVICE(cycle->un_link.device);
--device->unready;
eb_cycle_destroy(cyclep);
eb_free_cycle(cyclep);
}
static void eb_raw_cycle_close(eb_cycle_t cyclep) {
struct eb_cycle* cycle;
struct eb_operation* op;
struct eb_device* device;
eb_operation_t prev, i, next;
cycle = EB_CYCLE(cyclep);
device = EB_DEVICE(cycle->un_link.device);
/* Reverse the linked-list so it's FIFO */
if (cycle->un_ops.dead != cyclep) {
prev = EB_NULL;
for (i = cycle->un_ops.first; i != EB_NULL; i = next) {
op = EB_OPERATION(i);
next = op->next;
op->next = prev;
prev = i;
}
cycle->un_ops.first = prev;
}
/* Queue us to the device */
cycle->un_link.next = device->un_link.ready;
device->un_link.ready = cyclep;
/* Remove us from the incomplete cycle counter */
--device->unready;
}
static eb_status_t eb_cycle_block(eb_device_t devicep, eb_cycle_t cyclep) {
struct eb_cycle* cycle;
eb_status_t status;
eb_socket_t socketp;
cycle = EB_CYCLE(cyclep);
if (cycle->callback == &eb_block_f) {
status = 1;
cycle->user_data = &status;
socketp = eb_device_socket(devicep);
while (status > 0) eb_socket_run(socketp, -1);
return status;
} else {
return EB_OK;
}
}
eb_status_t eb_cycle_close_silently(eb_cycle_t cyclep) {
eb_device_t devicep;
devicep = eb_cycle_device(cyclep);
eb_raw_cycle_close(cyclep);
return eb_cycle_block(devicep, cyclep);
}
eb_status_t eb_cycle_close(eb_cycle_t cyclep) {
struct eb_cycle* cycle;
struct eb_operation* op;
eb_operation_t opp;
eb_device_t devicep;
devicep = eb_cycle_device(cyclep);
eb_raw_cycle_close(cyclep);
cycle = EB_CYCLE(cyclep);
opp = cycle->un_ops.first;
if (opp != EB_NULL && cycle->un_ops.dead != cyclep) {
op = EB_OPERATION(opp);
op->flags |= EB_OP_CHECKED;
}
return eb_cycle_block(devicep, cyclep);
}
static struct eb_operation* eb_cycle_doop(eb_cycle_t cyclep) {
eb_operation_t opp;
struct eb_cycle* cycle;
struct eb_operation* op;
static struct eb_operation crap;
opp = eb_new_operation();
cycle = EB_CYCLE(cyclep);
if (opp == EB_NULL) {
/* Record out-of-memory with a self-pointer */
eb_cycle_destroy(cyclep);
cycle->un_ops.dead = cyclep;
return &crap;
}
if (cycle->un_ops.dead == cyclep) {
eb_free_operation(opp);
/* Already ran OOM on this cycle */
return &crap;
}
op = EB_OPERATION(opp);
op->next = cycle->un_ops.first;
cycle->un_ops.first = opp;
return op;
}
void eb_cycle_read(eb_cycle_t cycle, eb_address_t address, eb_format_t format, eb_data_t* data) {
struct eb_operation* op;
op = eb_cycle_doop(cycle);
op->address = address;
op->un_value.read_destination = data;
op->format = format;
if (data) op->flags = EB_OP_READ_PTR;
else op->flags = EB_OP_READ_VAL;
}
void eb_cycle_read_config(eb_cycle_t cycle, eb_address_t address, eb_format_t format, eb_data_t* data) {
struct eb_operation* op;
op = eb_cycle_doop(cycle);
op->address = address;
op->un_value.read_destination = data;
op->format = format;
if (data) op->flags = EB_OP_READ_PTR | EB_OP_CFG_SPACE;
else op->flags = EB_OP_READ_VAL | EB_OP_CFG_SPACE;
}
void eb_cycle_write(eb_cycle_t cycle, eb_address_t address, eb_format_t format, eb_data_t data) {
struct eb_operation* op;
op = eb_cycle_doop(cycle);
op->address = address;
op->un_value.write_value = data;
op->format = format;
op->flags = EB_OP_WRITE;
}
void eb_cycle_write_config(eb_cycle_t cycle, eb_address_t address, eb_format_t format, eb_data_t data) {
struct eb_operation* op;
op = eb_cycle_doop(cycle);
op->address = address;
op->un_value.write_value = data;
op->format = format;
op->flags = EB_OP_WRITE | EB_OP_CFG_SPACE;
}
/** @file cycle.h
* @brief The Etherbone cycle data structure.
*
* Copyright (C) 2011-2012 GSI Helmholtz Centre for Heavy Ion Research GmbH
*
* Record callback information and contain queued operations.
* Cycles are queued on a device once closed.
*
* @author Wesley W. Terpstra <w.terpstra@gsi.de>
*
* @bug None!
*
*******************************************************************************
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
*/
#ifndef EB_CYCLE_H
#define EB_CYCLE_H
#include "../etherbone.h"
struct eb_cycle {
eb_callback_t callback;
eb_user_data_t user_data;
/* if points to cycle, means OOM */
union {
eb_operation_t first;
eb_cycle_t dead;
} un_ops;
union {
eb_cycle_t next;
eb_device_t device;
} un_link;
};
/* Recursively free the operations. Does not free cycle. */
EB_PRIVATE void eb_cycle_destroy(eb_cycle_t cycle);
#endif
This diff is collapsed.
/** @file device.h
* @brief The Etherbone device data structure.
*
* Copyright (C) 2011-2012 GSI Helmholtz Centre for Heavy Ion Research GmbH
*
* Devices are all listed with their associated socket.
* They record a connection to a specific target/source bus.
* Passive devices never have enqueued cycles for sending.
*
* @author Wesley W. Terpstra <w.terpstra@gsi.de>
*
* @bug None!
*
*******************************************************************************
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
*/
#ifndef EB_DEVICE_H
#define EB_DEVICE_H
#include "../etherbone.h"
#include "../transport/transport.h"
struct eb_device {
eb_socket_t socket;
eb_device_t next;
union {
eb_cycle_t ready;
eb_device_t passive; /* points to self if a 'server' link */
} un_link;
uint8_t unready;
uint8_t widths;
eb_link_t link; /* if connection is broken => EB_NULL */
eb_transport_t transport;
};
/* Create a new slave device */
EB_PRIVATE eb_link_t eb_device_new_slave(eb_socket_t socketp, eb_transport_t transportp, eb_link_t linkp);
#endif
/** @file format.c
* @brief Implement string converion methos for integer types
*
* Copyright (C) 2011-2013 GSI Helmholtz Centre for Heavy Ion Research GmbH
*
* @author Wesley W. Terpstra <w.terpstra@gsi.de>
*
* @bug None!
*
*******************************************************************************
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
*/
#define ETHERBONE_IMPL
#include <stdlib.h>
#include "../etherbone.h"
const char* eb_status(eb_status_t code) {
switch (code) {
case EB_SEGFAULT: return "one or more operations failed";
case EB_OK: return "success";
case EB_FAIL: return "system failure";
case EB_ADDRESS: return "invalid address";
case EB_WIDTH: return "impossible bus width";
case EB_OVERFLOW: return "cycle length overflow";
case EB_ENDIAN: return "remote endian required";
case EB_BUSY: return "resource busy";
case EB_TIMEOUT: return "timeout";
case EB_OOM: return "out of memory";
case EB_ABI: return "library incompatible with application";
default: return "unknown Etherbone error code";
}
}
static const char* endian_str[4] = {
/* 0 */ "auto-endian",
/* 1 */ "big-endian",
/* 2 */ "little-endian",
/* 3 */ "invalid-endian"
};
static const char* width_str[16] = {
/* 0 */ "<null>",
/* 1 */ "8",
/* 2 */ "16",
/* 3 */ "8/16",
/* 4 */ "32",
/* 5 */ "8/32",
/* 6 */ "16/32",
/* 7 */ "8/16/32",
/* 8 */ "64",
/* 9 */ "8/64",
/* 10 */ "16/64",
/* 11 */ "8/16/64",
/* 12 */ "32/64",
/* 13 */ "8/32/64",
/* 14 */ "16/32/64",
/* 15 */ "8/16/32/64"
};
const char* eb_width_data(eb_width_t width) {
return width_str[width & EB_DATAX];
}
const char* eb_width_address(eb_width_t width) {
return width_str[(width & EB_ADDRX) >> 4];
}
const char* eb_format_data(eb_format_t format) {
return width_str[format & EB_DATAX];
}
const char* eb_format_endian(eb_format_t format) {
return endian_str[(format & EB_ENDIAN_MASK) >> 4];
}
static int eb_parse_width(const char* str) {
int width, widths;
char* next;
widths = 0;
while (1) {
width = strtol(str, &next, 0);
if (width != 8 && width != 16 && width != 32 && width != 64) break;
widths |= width/8;
if (!*next) return widths;
if (*next != '/' && *next != ',') break;
str = next+1;
}
return -1;
}
int eb_width_parse_data(const char* str, eb_width_t* width) {
int result = eb_parse_width(str);
if (result < 0) return EB_WIDTH;
*width = result | (*width & EB_ADDRX);
return EB_OK;
}
int eb_width_parse_address(const char* str, eb_width_t* width) {
int result = eb_parse_width(str);
if (result < 0) return EB_WIDTH;
*width = (result<<4) | (*width & EB_DATAX);
return EB_OK;
}
This diff is collapsed.
/** @file handler.h
* @brief The Etherbone handler data structure.
*
* Copyright (C) 2011-2012 GSI Helmholtz Centre for Heavy Ion Research GmbH
*
* Handlers have two halves: eb_handler_address and eb_handler_callback.
* This split was made so that every dynamically allocated object is roughly
* the same size, easing the internal memory management implementation.
*
* @author Wesley W. Terpstra <w.terpstra@gsi.de>
*
* @bug None!
*
*******************************************************************************
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
*/
#ifndef EB_HANDLER_H
#define EB_HANDLER_H
#include "../etherbone.h"
typedef EB_POINTER(eb_handler_callback) eb_handler_callback_t;
struct eb_handler_callback {
eb_user_data_t data;
eb_status_t (*read) (eb_user_data_t, eb_address_t, eb_width_t, eb_data_t*);
eb_status_t (*write)(eb_user_data_t, eb_address_t, eb_width_t, eb_data_t);
};
typedef EB_POINTER(eb_handler_address) eb_handler_address_t;
struct eb_handler_address {
const struct sdb_device* device;
eb_handler_callback_t callback;
eb_handler_address_t next;
};
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment