source: UsbWattMeter/trunk/asp_dcre/kernel/genoffset.tf@ 164

Last change on this file since 164 was 164, checked in by coas-nagasima, 6 years ago

TOPPERS/ECNLサンプルアプリ「USB充電器電力計」を追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/plain
File size: 4.2 KB
Line 
1$ ======================================================================
2$
3$ TOPPERS/ASP Kernel
4$ Toyohashi Open Platform for Embedded Real-Time Systems/
5$ Advanced Standard Profile Kernel
6$
7$ Copyright (C) 2011 by Embedded and Real-Time Systems Laboratory
8$ Graduate School of Information Science, Nagoya Univ., JAPAN
9$
10$ ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
11$ ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
12$ •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
13$ (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
14$ Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
15$ ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
16$ (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
17$ —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
18ƒƒ“ƒgi—˜—p
19$ ŽÒƒ}ƒjƒ…
20ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
21$ ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
22$ (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
23$ —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
24$ ‚ƁD
25$ (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
26ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
27ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
28$ ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
29$ (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
30$ •ñ‚·‚邱‚ƁD
31$ (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
32$ ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
33$ ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
34$ —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
35$ –Ɛӂ·‚邱‚ƁD
36$
37$ –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
38$ ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
39$ ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
40$ ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
41$ ‚̐ӔC‚𕉂í‚È‚¢D
42$
43$ $Id: genoffset.tf 164 2016-03-07 11:33:50Z coas-nagasima $
44$
45$ =====================================================================
46
47$
48$ #defineƒfƒBƒŒƒNƒeƒBƒu‚̐¶¬
49$
50$FUNCTION DEFINE$
51 #define $ARGV[1]$$TAB$$FORMAT("%d", +ARGV[2])$$NL$
52$END$
53
54$
55$ ƒrƒbƒg‚̃T[ƒ`
56$
57$FUNCTION SEARCH_BIT$
58 $_val = ARGV[1]$
59 $FOREACH _val_bit RANGE(0,7)$
60 $IF (_val & 1) != 0$
61 $RESULT = _val_bit$
62 $END$
63 $_val = _val >> 1$
64 $END$
65$END$
66
67$
68$ ƒrƒbƒgƒtƒB[ƒ‹ƒh‚̃IƒtƒZƒbƒg‚ƃrƒbƒgˆÊ’u‚Ì’è‹`‚̐¶¬
69$
70$FUNCTION DEFINE_BIT$
71 $label = ARGV[1]$
72 $struct_size = ARGV[2]$
73 $output_size = ARGV[3]$
74
75 $top = SYMBOL(label)$
76 $IF !LENGTH(top)$
77 $ERROR$$FORMAT("label %1% not found", label)$$END$
78 $ELSE$
79 $val = 0$
80 $FOREACH i RANGE(0,struct_size-1)$
81 $tmp_val = PEEK(top + i, 1)$
82 $IF val == 0 && tmp_val != 0$
83 $val = tmp_val$
84 $offset = i$
85 $END$
86 $END$
87
88 $IF val == 0$
89 $ERROR$$FORMAT("bit not found in %1%", ARGV[1])$$END$
90 $ELSE$
91 $val_bit = SEARCH_BIT(val)$
92 $RESULT = {}$
93 $IF EQ(output_size, "W")$
94 $IF SIL_ENDIAN_BIG$
95 $val_bit = val_bit + 24 - ((offset & 0x03) << 3)$
96 $ELSE$
97 $val_bit = val_bit + ((offset & 0x03) << 3)$
98 $END$
99 $offset = offset & ~0x03$
100 $ELSE$$IF EQ(output_size, "H")$
101 $IF SIL_ENDIAN_BIG$
102 $val_bit = val_bit + 8 - ((offset & 0x01) << 3)$
103 $ELSE$
104 $val_bit = val_bit + ((offset & 0x01) << 3)$
105 $END$
106 $offset = offset & ~0x01$
107 $END$$END$
108 $END$
109
110 #define $label$$TAB$$FORMAT("%d", +offset)$$NL$
111 #define $label$_bit$TAB$$FORMAT("%d", +val_bit)$$NL$
112 #define $label$_mask$TAB$$FORMAT("0x%x", 1 << val_bit)$$NL$
113 $END$
114$END$
115
116$
117$ ƒoƒCƒg”z’u‚̃`ƒFƒbƒN
118$
119$FUNCTION MAGIC_CHECK$
120 $size = ARGV[1]$
121 $check = ARGV[2]$
122
123 $label = FORMAT("MAGIC_%d", +size)$
124 $top = SYMBOL(label)$
125 $IF !LENGTH(top)$
126 $ERROR$$FORMAT("label %1% not found", label)$$END$
127 $ELSE$
128 $FOREACH offset RANGE(1,size)$
129 $IF SIL_ENDIAN_BIG$
130 $val = PEEK(top + offset - 1, 1)$
131 $ELSE$
132 $val = PEEK(top + size - offset, 1)$
133 $END$
134 $IF val != AT(check, offset - 1)$
135 $ERROR$$FORMAT("value check of %1% failed", label)$$END$
136 $END$
137 $END$
138 $END$
139$END$
140
141$MAGIC_CHECK(1, { 0x12 })$
142$MAGIC_CHECK(2, { 0x12, 0x34 })$
143$MAGIC_CHECK(4, { 0x12, 0x34, 0x56, 0x78 })$
144
145$
146$ ƒtƒ@ƒCƒ‹ƒwƒbƒ_‚̐¶¬
147$
148$FILE "offset.h"$
149/* offset.h */$NL$
150$NL$
Note: See TracBrowser for help on using the repository browser.