204 |
miho |
1 |
unit PP_DATA; |
|
|
2 |
|
|
|
3 |
{===========================================================================} |
|
|
4 |
{ (c) miho / DECROS 2000 } |
|
|
5 |
{===========================================================================} |
|
|
6 |
{ Zde je definice objektu pro ulozeni dat v pameti. } |
|
|
7 |
{===========================================================================} |
|
|
8 |
|
|
|
9 |
interface |
|
|
10 |
|
|
|
11 |
uses PP_DEFS; |
|
|
12 |
|
|
|
13 |
{===========================================================================} |
|
|
14 |
{ Definice typu a konstant pro ulozeni dat ( delka buferu, typ ulozenych } |
|
|
15 |
{ dat. } |
|
|
16 |
{===========================================================================} |
|
|
17 |
|
|
|
18 |
type DataItem_t=record { typ pro ulozeni jednoho datoveho slova } |
|
|
19 |
W : word; { vlastni data } |
|
|
20 |
S : boolean; { true znamena platna data } |
|
|
21 |
end; {record} |
|
|
22 |
|
|
|
23 |
type RangeType_t= |
|
|
24 |
( _INVALID_, { adresa neprislusi zadne oblasti } |
|
|
25 |
_PM_, { adresa spada do pameti programu } |
|
|
26 |
_DM_, { adresa spada do pameti dat } |
|
|
27 |
_CM_, { adresa spada do konfiguracni pameti } |
|
|
28 |
_CFG_ { adresa je adresou zvlastniho konfig slova } |
|
|
29 |
); |
|
|
30 |
|
|
|
31 |
type PicData_t=object |
|
|
32 |
{-- vlastni datove pole --} |
|
|
33 |
_Buf : array[0..DataBufLen-1] of DataItem_t; { zde jsou data } |
|
|
34 |
{-- informace o vybranem procesoru --} |
|
|
35 |
_Proc:ProcInfo_t; |
|
|
36 |
{-- metody --} |
|
|
37 |
|
|
|
38 |
procedure Init(ProcInfo:ProcInfo_t); |
|
|
39 |
{== Zapamatuje si typ procesoru ( jeho prametry ) a smaze datovou oblast ==} |
|
|
40 |
|
|
|
41 |
procedure GetProcInfo(var ProcInfo:ProcInfo_t); |
|
|
42 |
{== Vrati aktualni parametry procesoru ==} |
|
|
43 |
|
|
|
44 |
function TestAdr(Adr:word):RangeType_t; |
|
|
45 |
{== Vrati typ pametoveho prostoru pro zadanou adresu ==} |
|
|
46 |
|
|
|
47 |
function Store(Adr:word;Data:word):boolean; |
|
|
48 |
{== Ulozi data na zadanou adresu. Pri chybne adrese vraci true ==} |
|
|
49 |
|
|
|
50 |
procedure StoreProc(Adr:word;Data:word); |
|
|
51 |
{== Ulozi data na zadanou adresu. ==} |
|
|
52 |
|
|
|
53 |
function GetStat(Adr:word):boolean; |
|
|
54 |
{== Vrati priznak platnosti dat na zadane adrese, true znamena data platna ==} |
|
|
55 |
|
|
|
56 |
function GetData(Adr:word):word; |
|
|
57 |
{== Vrati data ze zadane adresy. Pri chybne adrese vraci same jednotky ==} |
|
|
58 |
|
|
|
59 |
end; {object} |
|
|
60 |
|
|
|
61 |
implementation |
|
|
62 |
|
|
|
63 |
function InRange(What,Start,Finish:word):boolean; |
|
|
64 |
{== Vraci true pokud What spada do rozsahu [Start..Finish] ==} |
|
|
65 |
{ Pomocna funkce } |
|
|
66 |
begin InRange:=(What>=Start) and (What<=Finish) |
|
|
67 |
end; {InRange} |
|
|
68 |
|
|
|
69 |
procedure PicData_t.Init(ProcInfo:ProcInfo_t); |
|
|
70 |
{== Zapamatuje si typ procesoru ( jeho prametry ) a smaze datovou oblast ==} |
|
|
71 |
var i:integer; |
|
|
72 |
begin _Proc:=ProcInfo; |
|
|
73 |
{-- inicializace bufferu --} |
|
|
74 |
for i:=0 to DataBufLen-1 do begin _Buf[i].W:=0; |
|
|
75 |
_Buf[i].S:=false; |
|
|
76 |
end; |
|
|
77 |
{-- inicializace jednotlivych oblasti--} |
|
|
78 |
for i:=_Proc.PM_Base to _Proc.PM_Base+_Proc.PM_Len-1 do |
|
|
79 |
_Buf[i].W:=_Proc.PM_Mask; |
|
|
80 |
for i:=_Proc.DM_Base to _Proc.DM_Base+_Proc.DM_Len-1 do |
|
|
81 |
_Buf[i].W:=_Proc.DM_Mask; |
|
|
82 |
for i:=_Proc.CM_Base to _Proc.CM_Base+_Proc.CM_Len-1 do |
|
|
83 |
_Buf[i].W:=_Proc.CM_Mask; |
|
|
84 |
end; {Init} |
|
|
85 |
|
|
|
86 |
procedure PicData_t.GetProcInfo(var ProcInfo:ProcInfo_t); |
|
|
87 |
{== Vrati aktualni parametry procesoru ==} |
|
|
88 |
begin ProcInfo:=_Proc; |
|
|
89 |
end; {GetProcInfo} |
|
|
90 |
|
|
|
91 |
function PicData_t.TestAdr(Adr:word):RangeType_t; |
|
|
92 |
{== Vrati typ pametoveho prostoru pro zadanou adresu ==} |
|
|
93 |
begin TestAdr:=_INVALID_; { nepasuje do zadneho rozsahu } |
|
|
94 |
with _Proc do |
|
|
95 |
begin if Name='' |
|
|
96 |
then begin exit; { neni dany typ procesoru } |
|
|
97 |
end; |
|
|
98 |
if Adr>DataBufLen |
|
|
99 |
then begin exit; { adresa mimo rozsah bufferu } |
|
|
100 |
end; |
|
|
101 |
if (PM_Len>0) and (Adr>=PM_Base) and (Adr<=PM_Base+PM_Len) |
|
|
102 |
then begin TestAdr:=_PM_; |
|
|
103 |
exit; |
|
|
104 |
end; |
|
|
105 |
if (CM_Len>0) and (Adr>=CM_Base) and (Adr<=CM_Base+CM_Len) |
|
|
106 |
then begin TestAdr:=_CM_; |
|
|
107 |
exit; |
|
|
108 |
end; |
|
|
109 |
if (DM_Len>0) and (Adr>=DM_Base) and (Adr<=DM_Base+DM_Len) |
|
|
110 |
then begin TestAdr:=_DM_; |
|
|
111 |
exit; |
|
|
112 |
end; |
|
|
113 |
if Adr=Cfg_Base |
|
|
114 |
then begin TestAdr:=_CFG_; |
|
|
115 |
exit; |
|
|
116 |
end; |
|
|
117 |
end; |
|
|
118 |
end; {TestAdr} |
|
|
119 |
|
|
|
120 |
function PicData_t.Store(Adr:word;Data:word):boolean; |
|
|
121 |
{== Ulozi data na zadanou adresu. Pri chybne adrese vraci true ==} |
|
|
122 |
begin case TestAdr(Adr) of |
|
|
123 |
_INVALID_ : begin {-- chybna adresa - nic nedelej --} |
|
|
124 |
Store:=true; |
|
|
125 |
exit; |
|
|
126 |
end; |
|
|
127 |
_PM_ : data:=data and _Proc.PM_Mask; { maskuj data } |
|
|
128 |
_DM_ : data:=data and _Proc.DM_Mask; |
|
|
129 |
_CM_ : data:=data and _Proc.CM_Mask; |
|
|
130 |
_CFG_ : data:=data and _Proc.Cfg_Mask; |
|
|
131 |
end; {case} |
|
|
132 |
{-- platna adresa - uloz data --} |
|
|
133 |
Store:=false; |
|
|
134 |
_Buf[Adr].S:=true; { datova polozka platna } |
|
|
135 |
_Buf[Adr].W:=data; { vlastni data } |
|
|
136 |
end; {Store} |
|
|
137 |
|
|
|
138 |
procedure PicData_t.StoreProc(Adr:word;Data:word); |
|
|
139 |
{== Ulozi data na zadanou adresu ==} |
|
|
140 |
begin if Store(Adr, Data) then; |
|
|
141 |
end; {StoreProc} |
|
|
142 |
|
|
|
143 |
function PicData_t.GetStat(Adr:word):boolean; |
|
|
144 |
{== Vrati priznak platnosti dat na zadane adrese, true znamena data platna ==} |
|
|
145 |
begin GetStat:=false; |
|
|
146 |
if TestAdr(Adr)=_INVALID_ then exit; |
|
|
147 |
GetStat:=_Buf[Adr].S; |
|
|
148 |
end; {GetStat} |
|
|
149 |
|
|
|
150 |
function PicData_t.GetData(Adr:word):word; |
|
|
151 |
{== Vrati data ze zadane adresy. Pri chybne adrese vraci same jednotky ==} |
|
|
152 |
begin GetData:=$FFFF; |
|
|
153 |
if TestAdr(Adr)=_INVALID_ then exit; |
|
|
154 |
GetData:=_Buf[Adr].W; |
|
|
155 |
end; {GetData} |
|
|
156 |
|
|
|
157 |
begin |
|
|
158 |
end. |