blog 文章

2020/12/15

test

arm64_test.cpp
  1 
  2 #include "stdlib.h"
  3 #include "stdio.h"
  4 #include "string.h"
  5 #include "unistd.h"
  6 #include "fcntl.h"
  7 #include "pthread.h"
  8 #include "malloc.h"
  9 #include <sys/mman.h> // Needed for mlockall() 
 10 #include "stdint.h"
 11 #include <sched.h>
 12 #include <time.h>
 13 
 14 #define SYSFS_GPIO_EXPORT           "/sys/class/gpio/export"
 15 #define SYSFS_GPIO_RST_PIN_VAL      "136"
 16 #define SYSFS_GPIaO_RST_DIR          "/sys/class/gpio/gpio136/direction"
 17 #define SYSFS_GPIO_RST_DIR_VAL      "OUT"
 18 #define SYSFS_GPIO_RST_VAL          "/sys/class/gpio/gpio136/value"
 19 #define SYSFS_GPIO_RST_VAL_H        "1"
 20 #define SYSFS_GPIO_RST_VAL_L        "0"
 21 
 22 #define NSEC_PER_SEC		1000000000
 23 
 24 unsigned int  raw_read_cntfrq_el0(void)
 25 {
 26     unsigned int cntfrq_el0;
 27 
 28     __asm__ __volatile__("mrs %0, CNTFRQ_EL0\n\t" : "=r" (cntfrq_el0) : : "memory");
 29     return cntfrq_el0;
 30 }
 31 
 32 
 33 static long long armv8_read_CNTPCT_EL0(void)
 34 {
 35     long long val;
 36     asm volatile("mrs %0, CNTVCT_EL0" : "=r" (val));
 37     return val;
 38 } 
 39 
 40 
 41 pthread_t m_thread;
 42 void *MainThread(void *param)
 43 {
 44 	struct timespec t, t_start,t_end;  
 45     long long int tt,t_max=0,loop_count=0,t_execmax=0;
 46     
 47     
 48     int fd = 0, i, size=10*1024*1024;
 49     //int fd = 0, i, size=128*1024;
 50 	char *buf;
 51 
 52 	struct sched_param schedp;
 53 	memset(&schedp, 0, sizeof(schedp));
 54 	schedp.sched_priority = 90;
 55 	sched_setscheduler(0, SCHED_FIFO, &schedp);
 56 
 57     long long t1 = 0, t2 = 0;
 58 	cpu_set_t cpuset;
 59 	int cpu = 2;
 60      
 61 	CPU_ZERO(&cpuset);
 62 	CPU_SET(cpu, &cpuset);
 63 	sched_setaffinity(0, sizeof(cpuset), &cpuset);
 64 	pthread_detach(pthread_self());
 65 
 66 
 67 	buf = (char *) malloc(size);
 68 
 69     clock_gettime(CLOCK_MONOTONIC, &t);
 70     
 71 	while (1)
 72 	{
 73  clock_gettime(CLOCK_MONOTONIC, &t_end);		
 74  loop_count++;
 75  
 76         t1 = armv8_read_CNTPCT_EL0();
 77 
 78         if( loop_count > 5000 ) 
 79         { 
 80             if((tt=(t_end.tv_sec-t.tv_sec)*NSEC_PER_SEC+(t_end.tv_nsec-t.tv_nsec)) > t_max) 
 81                 t_max=tt;
 82         }    
 83         
 84 		for (i = 0; i < size; i = i + 1500)
 85 		{
 86 			buf[i]++;
 87 			//buf[0]++;
 88 		}
 89         t2 = armv8_read_CNTPCT_EL0();
 90             
 91 /* calculate next shot */
 92         t.tv_nsec += 1000000;  // 1000us
 93        
 94         while (t.tv_nsec >= NSEC_PER_SEC) {
 95 			t.tv_nsec -= NSEC_PER_SEC;
 96             t.tv_sec++;
 97             
 98         }
 99         
100         if( (t2-t1) > t_execmax  )
101             t_execmax = t2-t1;
102         
103         if( !(loop_count % 5000) ) 
104         {
105             printf("total:%lldus jitter:%lldus exec:%lldus\n", (t2-t1)/(raw_read_cntfrq_el0()/1000000),t_max/1000,t_execmax/(raw_read_cntfrq_el0()/1000000));
106             t_max=0;
107             t_execmax=0;
108         }
109             
110         clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &t, NULL);
111          
112 	}
113 
114 	return (void*)0;
115 }
116 
117 int main()
118 {
119 	int fd = 0;
120 
121     if (mlockall(MCL_CURRENT | MCL_FUTURE))
122         perror("mlockall failed:");	// Turn off malloc trimming.
123     mallopt (M_TRIM_THRESHOLD, -1);	// Turn off mmap usage.	mallopt (M_MMAP_MAX, 0);
124 
125 
126 	pthread_create(&m_thread, NULL, MainThread, NULL);
127 	pthread_join(m_thread, NULL);
128 
129 	printf("INFO: Radio hard reset pin value open error.\n");
130 	return 0;
131 
132 }
繼續閱讀

2019/12/20

[自助] 立山 - 黑部

2020/05/06 ~ 11
  1. 0506 (3)台灣 - 名古屋,
    住名古屋, Daiwa Roynet Hotel Nagoya Taiko dori Side ダイワロイネットホテル名古屋太閤通口
    0506 (3)台灣 - 名古屋-高山 (2hr 20min), 住高山
  2. 0507 名古屋 - 高山 (JR高山本線, 2hr 20min) - 合掌村 (搭乘濃飛巴士 - 50min) - 高山,
    住高山, Super Hotel Hida Takayama スーパーホテル飛騨高山
  3. 0508 高山 (小京都) - 富山 (90min),
    住富山, APA Hotel Toyama-Ekimae アパホテル 富山駅前
  4. 0509 (6) 立山黑部, 電鐵富山 - 立山, 先到電鐵富山寄行李, 預約立山-美女平的交通工具, 到大町溫泉站, 住「Kurobe Kanko Hotel 黒部観光ホテル」
  5. 0510 大町溫泉站 - 信濃大町 - 松本-名古屋 (2hr),
    住名古屋, Richmond Hotel Nagoya Shinkansenguchi リッチモンドホテル名古屋新幹線口
  6. 0511 名古屋 - 中部機場

ref:



華航
長榮

繼續閱讀

2018/04/03

cfront 轉出來的 c code

hello.C
 1 #include <stream.h>
39 
40 class A
41 {
42   public:        
43     virtual void foo(int a = 0)        
44     {
45       printf("A %d\n", a);        
46     }
47 };
48 
49 class B : public A
50 {
51   public:        
52     virtual void foo(int a = 1)        
53     { printf("B %d\n", a); }
54 };
55 
56 int main(int argc, char *argv[])
57 {
58 A *p = new B();p->foo();    
59 return 0;
60 }
hello..c 為 cfront 轉出的結果。
hello..c
  1 #line 1 "hello.C"
  2 
  3 /* <<AT&T C++ Language System <3.0.3> 05/05/94>> */
  4 char __cfront_version_303_xxxxxxxx;
  5 /* < hello.C > */
  6 
  7 #pragma lib "ape/libap.a"
  8 
  9 #pragma lib "c++/libC.a"
 10 
 11 #line 1 "hello.C"
 12 void *__vec_new (void *, int , int , void *);
 13 
 14 #line 1 "hello.C"
 15 void __vec_delete (void *, int , int , void *, int , int );
 16 typedef int (*__vptp)(void);
 17 struct __mptr {short d; short i; __vptp f; };
 18 
 19 #line 1 "hello.C"
 20 extern struct __mptr* __ptbl_vec__hello_C_[];
 21 
 22 #line 1 "hello.C"
 23 
 24 #line 49 "incl-master/incl-linux32/iostream.h"
 25 typedef long streampos ;
 26 typedef long streamoff ;
 27 struct streambuf;
 28 struct ostream;
 29 struct ios;
 30 union ios_user_union;
 31 enum __Q2_3ios8io_state { goodbit__Q2_3ios8io_state = 0, eofbit__Q2_3ios8io_state = 1, failbit__Q2_3ios8io_state = 2, badbit__Q2_3ios8io_state = 4, hardfail__Q2_3ios8io_state = 128} ;
 32 enum __Q2_3ios9open_mode { in__Q2_3ios9open_mode = 1, out__Q2_3ios9open_mode = 2, ate__Q2_3ios9open_mode = 4, app__Q2_3ios9open_mode = 8, trunc__Q2_3ios9open_mode = 16, nocreate__Q2_3ios9open_mode = 32, noreplace__Q2_3ios9open_mode = 64} ;
 33 enum __Q2_3ios8seek_dir { beg__Q2_3ios8seek_dir = 0, cur__Q2_3ios8seek_dir = 1, end__Q2_3ios8seek_dir = 2} ;
 34 enum __Q2_3ios4__E1 { skipws__Q2_3ios4__E1 = 1, left__Q2_3ios4__E1 = 2, right__Q2_3ios4__E1 = 4, internal__Q2_3ios4__E1 = 8, dec__Q2_3ios4__E1 = 16, oct__Q2_3ios4__E1 = 32, hex__Q2_3ios4__E1 = 64, showbase__Q2_3ios4__E1 = 128, showpoint__Q2_3ios4__E1 = 256, uppercase__Q2_3ios4__E1 = 512, showpos__Q2_3ios4__E1 = 1024, scientific__Q2_3ios4__E1 = 2048, fixed__Q2_3ios4__E1 = 4096, unitbuf__Q2_3ios4__E1 = 8192,
 35 #line 54 "incl-master/incl-linux32/iostream.h"
 36 stdio__Q2_3ios4__E1 = 16384} ;
 37 enum __Q2_3ios4__E2 { skipping__Q2_3ios4__E2 = 512, tied__Q2_3ios4__E2 = 1024} ;
 38 struct ios { /* sizeof ios == 88 */
 39 
 40 #line 153 "incl-master/incl-linux32/iostream.h"
 41 int nuser__3ios ;
 42 
 43 #line 155 "incl-master/incl-linux32/iostream.h"
 44 union ios_user_union *x_user__3ios ;
 45 
 46 #line 162 "incl-master/incl-linux32/iostream.h"
 47 struct streambuf *bp__3ios ;
 48 
 49 #line 168 "incl-master/incl-linux32/iostream.h"
 50 int state__3ios ;
 51 int ispecial__3ios ;
 52 int ospecial__3ios ;
 53 int isfx_special__3ios ;
 54 int osfx_special__3ios ;
 55 int delbuf__3ios ;
 56 struct ostream *x_tie__3ios ;
 57 long x_flags__3ios ;
 58 short x_precision__3ios ;
 59 char x_fill__3ios ;
 60 short x_width__3ios ;
 61 
 62 #line 186 "incl-master/incl-linux32/iostream.h"
 63 int assign_private__3ios ;
 64 
 65 #line 193 "incl-master/incl-linux32/iostream.h"
 66 struct __mptr *__vptr__3ios ;
 67 };
 68 
 69 #line 84 "incl-master/incl-linux32/iostream.h"
 70 extern long basefield__3ios ;
 71 
 72 #line 86 "incl-master/incl-linux32/iostream.h"
 73 extern long adjustfield__3ios ;
 74 
 75 #line 88 "incl-master/incl-linux32/iostream.h"
 76 extern long floatfield__3ios ;
 77 
 78 #line 150 "incl-master/incl-linux32/iostream.h"
 79 extern long nextbit__3ios ;
 80 extern long nextword__3ios ;
 81 
 82 #line 180 "incl-master/incl-linux32/iostream.h"
 83 extern void (*stdioflush__3ios )(void );
 84 
 85 #line 195 "incl-master/incl-linux32/iostream.h"
 86 struct streambuf { /* sizeof streambuf == 80 */
 87 short alloc__9streambuf ;
 88 short x_unbuf__9streambuf ;
 89 char *x_base__9streambuf ;
 90 char *x_pbase__9streambuf ;
 91 char *x_pptr__9streambuf ;
 92 char *x_epptr__9streambuf ;
 93 char *x_gptr__9streambuf ;
 94 char *x_egptr__9streambuf ;
 95 char *x_eback__9streambuf ;
 96 int x_blen__9streambuf ;
 97 
 98 #line 370 "incl-master/incl-linux32/iostream.h"
 99 struct __mptr *__vptr__9streambuf ;
100 };
101 
102 #line 1 "hello.C"
103 extern void __dl__FPv (void *);
104 
105 #line 246 "incl-master/incl-linux32/iostream.h"
106 
107 #line 255 "incl-master/incl-linux32/iostream.h"
108 int doallocate__9streambufFv (struct streambuf *__0this );
109 
110 #line 258 "incl-master/incl-linux32/iostream.h"
111 int underflow__9streambufFv (struct streambuf *__0this );
112 
113 #line 369 "incl-master/incl-linux32/iostream.h"
114 int x_snextc__9streambufFv (struct streambuf *__0this );
115 
116 #line 259 "incl-master/incl-linux32/iostream.h"
117 int pbackfail__9streambufFi (struct streambuf *__0this , int __1c );
118 
119 #line 257 "incl-master/incl-linux32/iostream.h"
120 int overflow__9streambufFi (struct streambuf *__0this , int __1c );
121 
122 #line 24 "incl-master/incl-linux32/string.h"
123 extern void *memcpy (char *, const char *, int );
124 
125 #line 229 "incl-master/incl-linux32/iostream.h"
126 
127 #line 265 "incl-master/incl-linux32/iostream.h"
128 int xsputn__9streambufFPCci (struct streambuf *__0this , const char *__1s , int __1n );
129 
130 #line 234 "incl-master/incl-linux32/iostream.h"
131 
132 #line 266 "incl-master/incl-linux32/iostream.h"
133 int xsgetn__9streambufFPci (struct streambuf *__0this , char *__1s , int __1n );
134 struct istream;
135 
136 #line 372 "incl-master/incl-linux32/iostream.h"
137 struct istream { /* sizeof istream == 112 */
138 
139 #line 493 "incl-master/incl-linux32/iostream.h"
140 int x_gcount__7istream ;
141 
142 #line 503 "incl-master/incl-linux32/iostream.h"
143 struct __mptr *__vptr__7istream ;
144 struct ios *Pios;
145 struct ios Oios;
146 };
147 
148 #line 489 "incl-master/incl-linux32/iostream.h"
149 int do_ipfx__7istreamFi (struct istream *__0this , int __1noskipws );
150 
151 #line 298 "incl-master/incl-linux32/iostream.h"
152 
153 #line 302 "incl-master/incl-linux32/iostream.h"
154 
155 #line 418 "incl-master/incl-linux32/iostream.h"
156 struct istream *rs_complicated__7istreamFRUc (struct istream *__0this , unsigned char *__1c );
157 
158 #line 298 "incl-master/incl-linux32/iostream.h"
159 
160 #line 302 "incl-master/incl-linux32/iostream.h"
161 
162 #line 419 "incl-master/incl-linux32/iostream.h"
163 struct istream *rs_complicated__7istreamFRc (struct istream *__0this , char *__1c );
164 
165 #line 429 "incl-master/incl-linux32/iostream.h"
166 struct istream *get__7istreamFPcic (struct istream *__0this , char *, int __1lim , char __1delim );
167 
168 #line 298 "incl-master/incl-linux32/iostream.h"
169 
170 #line 292 "incl-master/incl-linux32/iostream.h"
171 
172 #line 436 "incl-master/incl-linux32/iostream.h"
173 struct istream *get_complicated__7istreamFRUc (struct istream *__0this , unsigned char *__1c );
174 
175 #line 298 "incl-master/incl-linux32/iostream.h"
176 
177 #line 292 "incl-master/incl-linux32/iostream.h"
178 
179 #line 437 "incl-master/incl-linux32/iostream.h"
180 struct istream *get_complicated__7istreamFRc (struct istream *__0this , char *__1c );
181 
182 #line 377 "incl-master/incl-linux32/iostream.h"
183 
184 #line 292 "incl-master/incl-linux32/iostream.h"
185 
186 #line 163 "incl-master/incl-linux32/iostream.h"
187 
188 #line 377 "incl-master/incl-linux32/iostream.h"
189 
190 #line 281 "incl-master/incl-linux32/iostream.h"
191 
192 #line 480 "incl-master/incl-linux32/iostream.h"
193 struct istream *read__7istreamFPci (struct istream *__0this , char *__1s , int __1n );
194 
195 #line 260 "incl-master/incl-linux32/iostream.h"
196 int sync__9streambufFv (struct streambuf *__0this );
197 
198 #line 505 "incl-master/incl-linux32/iostream.h"
199 struct ostream { /* sizeof ostream == 104 */
200 
201 #line 610 "incl-master/incl-linux32/iostream.h"
202 struct __mptr *__vptr__7ostream ;
203 struct ios *Pios;
204 struct ios Oios;
205 };
206 
207 #line 601 "incl-master/incl-linux32/iostream.h"
208 int do_opfx__7ostreamFv (struct ostream *__0this );
209 void do_osfx__7ostreamFv (struct ostream *__0this );
210 
211 #line 538 "incl-master/incl-linux32/iostream.h"
212 struct ostream *complicated_put__7ostreamFc (struct ostream *__0this , char __1c );
213 
214 #line 324 "incl-master/incl-linux32/iostream.h"
215 
216 #line 163 "incl-master/incl-linux32/iostream.h"
217 
218 #line 568 "incl-master/incl-linux32/iostream.h"
219 struct ostream *ls_complicated__7ostreamFc (struct ostream *__0this , char );
220 
221 #line 324 "incl-master/incl-linux32/iostream.h"
222 
223 #line 163 "incl-master/incl-linux32/iostream.h"
224 
225 #line 569 "incl-master/incl-linux32/iostream.h"
226 struct ostream *ls_complicated__7ostreamFUc (struct ostream *__0this , unsigned char );
227 
228 #line 324 "incl-master/incl-linux32/iostream.h"
229 
230 #line 163 "incl-master/incl-linux32/iostream.h"
231 
232 #line 572 "incl-master/incl-linux32/iostream.h"
233 struct ostream *__ls__7ostreamFi (struct ostream *__0this , int __1a );
234 
235 #line 329 "incl-master/incl-linux32/iostream.h"
236 
237 #line 163 "incl-master/incl-linux32/iostream.h"
238 
239 #line 589 "incl-master/incl-linux32/iostream.h"
240 struct iostream;
241 struct istream_withassign;
242 struct ostream_withassign;
243 struct iostream_withassign;
244 
245 #line 612 "incl-master/incl-linux32/iostream.h"
246 struct iostream { /* sizeof iostream == 128 */
247 
248 #line 493 "incl-master/incl-linux32/iostream.h"
249 int x_gcount__7istream ;
250 
251 #line 503 "incl-master/incl-linux32/iostream.h"
252 struct __mptr *__vptr__7istream ;
253 struct ios *Pios;
254 struct ostream Oostream;
255 };
256 
257 #line 620 "incl-master/incl-linux32/iostream.h"
258 struct istream_withassign { /* sizeof istream_withassign == 112 */
259 
260 #line 493 "incl-master/incl-linux32/iostream.h"
261 int x_gcount__7istream ;
262 
263 #line 503 "incl-master/incl-linux32/iostream.h"
264 struct __mptr *__vptr__7istream ;
265 struct ios *Pios;
266 struct ios Oios;
267 };
268 
269 #line 644 "incl-master/incl-linux32/iostream.h"
270 extern struct istream_withassign cin ;
271 
272 #line 628 "incl-master/incl-linux32/iostream.h"
273 struct ostream_withassign { /* sizeof ostream_withassign == 104 */
274 
275 #line 610 "incl-master/incl-linux32/iostream.h"
276 struct __mptr *__vptr__7ostream ;
277 struct ios *Pios;
278 struct ios Oios;
279 };
280 
281 #line 645 "incl-master/incl-linux32/iostream.h"
282 extern struct ostream_withassign cout ;
283 extern struct ostream_withassign cerr ;
284 extern struct ostream_withassign clog ;
285 struct Iostream_init;
286 
287 #line 657 "incl-master/incl-linux32/iostream.h"
288 struct Iostream_init { /* sizeof Iostream_init == 1 */
289 
290 #line 657 "incl-master/incl-linux32/iostream.h"
291 char __W23__13Iostream_init ;
292 };
293 
294 #line 658 "incl-master/incl-linux32/iostream.h"
295 extern int stdstatus__13Iostream_init ;
296 extern int initcount__13Iostream_init ;
297 
298 #line 663 "incl-master/incl-linux32/iostream.h"
299 void __dt__13Iostream_initFv (struct Iostream_init *__0this , int );
300 
301 #line 662 "incl-master/incl-linux32/iostream.h"
302 struct Iostream_init *__ct__13Iostream_initFv (struct Iostream_init *__0this );
303 
304 #line 664 "incl-master/incl-linux32/iostream.h"
305 static struct Iostream_init iostream_init ;
306 
307 #pragma lib "ape/libap.a"
308 
309 #pragma lib "c++/libC.a"
310 
311 #pragma lib "ape/libap.a"
312 
313 #pragma lib "c++/libC.a"
314 
315 #line 20 "incl-master/incl-linux32/generic.h"
316 typedef int (*GPT )(int , char *);
317 struct smanip_int;
318 
319 #line 112 "incl-master/incl-linux32/iomanip.h"
320 struct smanip_int { /* sizeof smanip_int == 16 */
321 
322 #line 112 "incl-master/incl-linux32/iomanip.h"
323 struct ios *(*fct__10smanip_int )(struct ios *, int );
324 
325 #line 112 "incl-master/incl-linux32/iomanip.h"
326 int arg__10smanip_int ;
327 };
328 
329 #line 1 "hello.C"
330 extern void *__nw__FUl (unsigned long );
331 struct sapply_int;
332 
333 #line 112 "incl-master/incl-linux32/iomanip.h"
334 struct sapply_int { /* sizeof sapply_int == 8 */
335 
336 #line 112 "incl-master/incl-linux32/iomanip.h"
337 struct ios *(*fct__10sapply_int )(struct ios *, int );
338 };
339 
340 #line 112 "incl-master/incl-linux32/iomanip.h"
341 struct imanip_int;
342 struct imanip_int { /* sizeof imanip_int == 16 */
343 
344 #line 112 "incl-master/incl-linux32/iomanip.h"
345 struct istream *(*fct__10imanip_int )(struct istream *, int );
346 
347 #line 112 "incl-master/incl-linux32/iomanip.h"
348 int arg__10imanip_int ;
349 };
350 struct iapply_int;
351 
352 #line 112 "incl-master/incl-linux32/iomanip.h"
353 struct iapply_int { /* sizeof iapply_int == 8 */
354 
355 #line 112 "incl-master/incl-linux32/iomanip.h"
356 struct istream *(*fct__10iapply_int )(struct istream *, int );
357 };
358 
359 #line 112 "incl-master/incl-linux32/iomanip.h"
360 struct omanip_int;
361 struct omanip_int { /* sizeof omanip_int == 16 */
362 
363 #line 112 "incl-master/incl-linux32/iomanip.h"
364 struct ostream *(*fct__10omanip_int )(struct ostream *, int );
365 
366 #line 112 "incl-master/incl-linux32/iomanip.h"
367 int arg__10omanip_int ;
368 };
369 struct oapply_int;
370 
371 #line 112 "incl-master/incl-linux32/iomanip.h"
372 struct oapply_int { /* sizeof oapply_int == 8 */
373 
374 #line 112 "incl-master/incl-linux32/iomanip.h"
375 struct ostream *(*fct__10oapply_int )(struct ostream *, int );
376 };
377 
378 #line 112 "incl-master/incl-linux32/iomanip.h"
379 struct iomanip_int;
380 struct iomanip_int { /* sizeof iomanip_int == 16 */
381 
382 #line 112 "incl-master/incl-linux32/iomanip.h"
383 struct iostream *(*fct__11iomanip_int )(struct iostream *, int );
384 
385 #line 112 "incl-master/incl-linux32/iomanip.h"
386 int arg__11iomanip_int ;
387 };
388 struct ioapply_int;
389 
390 #line 112 "incl-master/incl-linux32/iomanip.h"
391 struct ioapply_int { /* sizeof ioapply_int == 8 */
392 
393 #line 112 "incl-master/incl-linux32/iomanip.h"
394 struct iostream *(*fct__11ioapply_int )(struct iostream *, int );
395 };
396 
397 #line 112 "incl-master/incl-linux32/iomanip.h"
398 struct smanip_long;
399 
400 #line 113 "incl-master/incl-linux32/iomanip.h"
401 struct smanip_long { /* sizeof smanip_long == 16 */
402 
403 #line 113 "incl-master/incl-linux32/iomanip.h"
404 struct ios *(*fct__11smanip_long )(struct ios *, long );
405 
406 #line 113 "incl-master/incl-linux32/iomanip.h"
407 long arg__11smanip_long ;
408 };
409 struct sapply_long;
410 
411 #line 113 "incl-master/incl-linux32/iomanip.h"
412 struct sapply_long { /* sizeof sapply_long == 8 */
413 
414 #line 113 "incl-master/incl-linux32/iomanip.h"
415 struct ios *(*fct__11sapply_long )(struct ios *, long );
416 };
417 
418 #line 113 "incl-master/incl-linux32/iomanip.h"
419 struct imanip_long;
420 struct imanip_long { /* sizeof imanip_long == 16 */
421 
422 #line 113 "incl-master/incl-linux32/iomanip.h"
423 struct istream *(*fct__11imanip_long )(struct istream *, long );
424 
425 #line 113 "incl-master/incl-linux32/iomanip.h"
426 long arg__11imanip_long ;
427 };
428 struct iapply_long;
429 
430 #line 113 "incl-master/incl-linux32/iomanip.h"
431 struct iapply_long { /* sizeof iapply_long == 8 */
432 
433 #line 113 "incl-master/incl-linux32/iomanip.h"
434 struct istream *(*fct__11iapply_long )(struct istream *, long );
435 };
436 
437 #line 113 "incl-master/incl-linux32/iomanip.h"
438 struct omanip_long;
439 struct omanip_long { /* sizeof omanip_long == 16 */
440 
441 #line 113 "incl-master/incl-linux32/iomanip.h"
442 struct ostream *(*fct__11omanip_long )(struct ostream *, long );
443 
444 #line 113 "incl-master/incl-linux32/iomanip.h"
445 long arg__11omanip_long ;
446 };
447 struct oapply_long;
448 
449 #line 113 "incl-master/incl-linux32/iomanip.h"
450 struct oapply_long { /* sizeof oapply_long == 8 */
451 
452 #line 113 "incl-master/incl-linux32/iomanip.h"
453 struct ostream *(*fct__11oapply_long )(struct ostream *, long );
454 };
455 
456 #line 113 "incl-master/incl-linux32/iomanip.h"
457 struct iomanip_long;
458 struct iomanip_long { /* sizeof iomanip_long == 16 */
459 
460 #line 113 "incl-master/incl-linux32/iomanip.h"
461 struct iostream *(*fct__12iomanip_long )(struct iostream *, long );
462 
463 #line 113 "incl-master/incl-linux32/iomanip.h"
464 long arg__12iomanip_long ;
465 };
466 struct ioapply_long;
467 
468 #line 113 "incl-master/incl-linux32/iomanip.h"
469 struct ioapply_long { /* sizeof ioapply_long == 8 */
470 
471 #line 113 "incl-master/incl-linux32/iomanip.h"
472 struct iostream *(*fct__12ioapply_long )(struct iostream *, long );
473 };
474 
475 #line 113 "incl-master/incl-linux32/iomanip.h"
476 
477 #line 10 "incl-master/incl-linux32/stdio.h"
478 typedef char *va_list ;
479 struct _iobuf;
480 
481 #line 118 "incl-master/incl-linux32/stdio.h"
482 extern char *sys_errlist [];
483 extern int sys_nerr ;
484 extern unsigned char *_bufendtab [];
485 struct stdiobuf;
486 
487 #line 22 "incl-master/incl-linux32/stdiostream.h"
488 struct stdiobuf { /* sizeof stdiobuf == 96 */
489 
490 #line 196 "incl-master/incl-linux32/iostream.h"
491 short alloc__9streambuf ;
492 short x_unbuf__9streambuf ;
493 char *x_base__9streambuf ;
494 char *x_pbase__9streambuf ;
495 char *x_pptr__9streambuf ;
496 char *x_epptr__9streambuf ;
497 char *x_gptr__9streambuf ;
498 char *x_egptr__9streambuf ;
499 char *x_eback__9streambuf ;
500 int x_blen__9streambuf ;
501 
502 #line 370 "incl-master/incl-linux32/iostream.h"
503 struct __mptr *__vptr__9streambuf ;
504 
505 #line 36 "incl-master/incl-linux32/stdiostream.h"
506 struct _iobuf *fp__8stdiobuf ;
507 int last_op__8stdiobuf ;
508 char buf__8stdiobuf [2];
509 };
510 struct stdiostream;
511 struct filebuf;
512 
513 #line 21 "incl-master/incl-linux32/fstream.h"
514 struct filebuf { /* sizeof filebuf == 120 */
515 
516 #line 196 "incl-master/incl-linux32/iostream.h"
517 short alloc__9streambuf ;
518 short x_unbuf__9streambuf ;
519 char *x_base__9streambuf ;
520 char *x_pbase__9streambuf ;
521 char *x_pptr__9streambuf ;
522 char *x_epptr__9streambuf ;
523 char *x_gptr__9streambuf ;
524 char *x_egptr__9streambuf ;
525 char *x_eback__9streambuf ;
526 int x_blen__9streambuf ;
527 
528 #line 370 "incl-master/incl-linux32/iostream.h"
529 struct __mptr *__vptr__9streambuf ;
530 
531 #line 45 "incl-master/incl-linux32/fstream.h"
532 int xfd__7filebuf ;
533 int mode__7filebuf ;
534 char opened__7filebuf ;
535 streampos last_seek__7filebuf ;
536 char *in_start__7filebuf ;
537 
538 #line 51 "incl-master/incl-linux32/fstream.h"
539 char lahead__7filebuf [2];
540 };
541 
542 #line 23 "incl-master/incl-linux32/fstream.h"
543 extern int openprot__7filebuf ;
544 struct fstreambase;
545 
546 #line 54 "incl-master/incl-linux32/fstream.h"
547 struct fstreambase { /* sizeof fstreambase == 224 */
548 
549 #line 72 "incl-master/incl-linux32/fstream.h"
550 struct filebuf buf__11fstreambase ;
551 
552 #line 75 "incl-master/incl-linux32/fstream.h"
553 struct __mptr *__vptr__11fstreambase ;
554 struct ios *Pios;
555 struct ios Oios;
556 };
557 struct ifstream;
558 
559 #line 87 "incl-master/incl-linux32/fstream.h"
560 
561 #line 70 "incl-master/incl-linux32/fstream.h"
562 
563 #line 141 "incl-master/incl-linux32/iostream.h"
564 
565 #line 70 "incl-master/incl-linux32/fstream.h"
566 
567 #line 77 "incl-master/incl-linux32/fstream.h"
568 struct ifstream { /* sizeof ifstream == 248 */
569 
570 #line 72 "incl-master/incl-linux32/fstream.h"
571 struct filebuf buf__11fstreambase ;
572 
573 #line 75 "incl-master/incl-linux32/fstream.h"
574 struct __mptr *__vptr__11fstreambase ;
575 struct ios *Pios;
576 struct istream Oistream;
577 };
578 struct ofstream;
579 
580 #line 102 "incl-master/incl-linux32/fstream.h"
581 
582 #line 70 "incl-master/incl-linux32/fstream.h"
583 
584 #line 141 "incl-master/incl-linux32/iostream.h"
585 
586 #line 70 "incl-master/incl-linux32/fstream.h"
587 
588 #line 92 "incl-master/incl-linux32/fstream.h"
589 struct ofstream { /* sizeof ofstream == 240 */
590 
591 #line 72 "incl-master/incl-linux32/fstream.h"
592 struct filebuf buf__11fstreambase ;
593 
594 #line 75 "incl-master/incl-linux32/fstream.h"
595 struct __mptr *__vptr__11fstreambase ;
596 struct ios *Pios;
597 struct ostream Oostream;
598 };
599 struct fstream;
600 
601 #line 117 "incl-master/incl-linux32/fstream.h"
602 
603 #line 70 "incl-master/incl-linux32/fstream.h"
604 
605 #line 141 "incl-master/incl-linux32/iostream.h"
606 
607 #line 70 "incl-master/incl-linux32/fstream.h"
608 
609 #line 53 "incl-master/incl-linux32/stream.h"
610 
611 #line 54 "incl-master/incl-linux32/stream.h"
612 
613 #line 55 "incl-master/incl-linux32/stream.h"
614 
615 #line 56 "incl-master/incl-linux32/stream.h"
616 
617 #line 57 "incl-master/incl-linux32/stream.h"
618 
619 #line 58 "incl-master/incl-linux32/stream.h"
620 
621 #line 59 "incl-master/incl-linux32/stream.h"
622 
623 #line 60 "incl-master/incl-linux32/stream.h"
624 
625 #line 62 "incl-master/incl-linux32/stream.h"
626 typedef int state_value ;
627 struct Hello;
628 
629 #line 571 "incl-master/incl-linux32/iostream.h"
630 struct ostream *__ls__7ostreamFPCc (struct ostream *__0this , const char *);
631 
632 #line 4 "hello.C"
633 struct Hello { /* sizeof Hello == 1 */
634 
635 #line 4 "hello.C"
636 char __W49__5Hello ;
637 };
638 struct A;
639 
640 #line 73 "incl-master/incl-linux32/stdio.h"
641 extern int printf (const char *,...);
642 
643 #line 39 "hello.C"
644 struct A { /* sizeof A == 8 */
645 
646 #line 39 "hello.C"
647 struct __mptr *__vptr__1A ;
648 };
649 struct B;
650 
651 #line 39 "hello.C"
652 struct B { /* sizeof B == 8 */
653 
654 #line 39 "hello.C"
655 struct __mptr *__vptr__1A ;
656 };
657 
658 #line 39 "hello.C"
659 static void foo__1AFi (struct A *__0this , int __2a );
660 
661 #line 41 "hello.C"
662 int main (int __1argc , char **__1argv ){ _main(); 
663 #line 42 "hello.C"
664 { 
665 #line 43 "hello.C"
666 struct A *__1p ;
667 
668 #line 44 "hello.C"
669 struct B *__0__X53 ;
670 
671 #line 44 "hello.C"
672 struct A *__0__X52 ;
673 
674 #line 43 "hello.C"
675 __1p = (struct A *)( (__0__X53 = 0 ), ( ((__0__X53 || (__0__X53 = (struct B *)__nw__FUl ( (unsigned long )(sizeof (struct B)))
676 #line 43 "hello.C"
677 ))?( (__0__X53 = (struct B *)( (__0__X52 = (((struct A *)__0__X53 ))), ( ((__0__X52 || (__0__X52 = (struct A *)__nw__FUl ( (unsigned long
678 #line 43 "hello.C"
679 )(sizeof (struct A))) ))?(__0__X52 -> __vptr__1A = (struct __mptr *) __ptbl_vec__hello_C_[0]):0 ), __0__X52 ) ) ), (__0__X53 -> __vptr__1A = (struct __mptr *) __ptbl_vec__hello_C_[1])) :0 ),
680 #line 43 "hello.C"
681 __0__X53 ) ) ;
682 
683 #line 43 "hello.C"
684 ((*(((void (*)(struct A *__0this , int __2a ))(__1p -> __vptr__1A [1]).f))))( ((struct A *)((((char *)__1p ))+ (__1p -> __vptr__1A [1]).d)), 0 ) ;
685 return 0 ;
686 }
687 } 
688 #line 45 "hello.C"
689 void __sti__hello_C_main_ (void )
690 #line 664 "incl-master/incl-linux32/iostream.h"
691 { __ct__13Iostream_initFv ( & iostream_init ) ;
692 
693 #line 664 "incl-master/incl-linux32/iostream.h"
694 }
695 
696 #line 45 "hello.C"
697 void __std__hello_C_main_ (void )
698 #line 664 "incl-master/incl-linux32/iostream.h"
699 { __dt__13Iostream_initFv ( & iostream_init , 2) ;
700 
701 #line 664 "incl-master/incl-linux32/iostream.h"
702 }
703 static void foo__1BFi (
704 #line 39 "hello.C"
705 struct B *__0this , 
706 #line 39 "hello.C"
707 int __2a );
708 struct __mptr __vtbl__1B__hello_C[] = {0,0,0,
709 0,0,(__vptp)foo__1BFi ,
710 0,0,0};
711 struct __mptr __vtbl__1A__hello_C[] = {0,0,0,
712 0,0,(__vptp)foo__1AFi ,
713 0,0,0};
714 static void foo__1BFi (struct B *__0this , 
715 #line 39 "hello.C"
716 int __2a ){ 
717 #line 39 "hello.C"
718 printf ( (const char *)"B %d\n",
719 #line 39 "hello.C"
720 __2a ) ;
721 
722 #line 39 "hello.C"
723 }
724 
725 #line 39 "hello.C"
726 static void foo__1AFi (struct A *__0this , 
727 #line 39 "hello.C"
728 int __2a ){ 
729 #line 39 "hello.C"
730 printf ( (const char *)"A %d\n",
731 #line 39 "hello.C"
732 __2a ) ;
733 
734 #line 39 "hello.C"
735 }
736 
737 #line 23 "incl-master/incl-linux32/fstream.h"
738 int openprot__7filebuf ;
739 
740 #line 56 "incl-master/incl-linux32/iostream.h"
741 
742 #line 659 "incl-master/incl-linux32/iostream.h"
743 int initcount__13Iostream_init ;
744 
745 #line 658 "incl-master/incl-linux32/iostream.h"
746 int stdstatus__13Iostream_init ;
747 
748 #line 180 "incl-master/incl-linux32/iostream.h"
749 void (*stdioflush__3ios )(void );
750 
751 #line 151 "incl-master/incl-linux32/iostream.h"
752 long nextword__3ios ;
753 
754 #line 150 "incl-master/incl-linux32/iostream.h"
755 long nextbit__3ios ;
756 
757 #line 88 "incl-master/incl-linux32/iostream.h"
758 long floatfield__3ios ;
759 
760 #line 86 "incl-master/incl-linux32/iostream.h"
761 long adjustfield__3ios ;
762 
763 #line 84 "incl-master/incl-linux32/iostream.h"
764 long basefield__3ios ;
765 struct __mptr* __ptbl_vec__hello_C_[] = {
766 __vtbl__1A__hello_C,
767 __vtbl__1B__hello_C,
768 
769 };
770 
771 #line 45 "hello.C"
772 
773 /* the end */
繼續閱讀

2017/09/20

rpi2 jtag

How To JTAG Raspberry Pi 2 Preparing Raspberry PI for JTAG Debugging Here are the GPIO numbers for the current revision:
JTAG pin"ALT4" mode"ALT5" mode
TDIGPIO26GPIO4
TDOGPIO24GPIO5
TMSGPIO27GPIO12
TCKGPIO25GPIO13
RTCKGPIO23GPIO6
TRSTGPIO22N/A
樹莓派 2 gpio pin
JTAG RPi2 GPIO gpio number
VREF* Pin 1 3.3 v
nTRST Pin 15 gpio 22
GND Pin 9 GND
TDI Pin 7 gpio 4
TMS Pin 13 gpio 27
TCK Pin 22 gpio 25
TDO Pin 18 gpio 24
繼續閱讀

2017/06/01

產生一個 elf object file, 讓 gcc link 出 elf 執行檔案

op2.c
1 //#include <stdio.h>
2
3 int main()
4 {
5   printf("1+2 = %d\n", 1+2);
6 }

op2.S 由 simple_compier 產生。

op2.S
 1 .section .rodata
 2 LC1: 
 3     .string "1+2 = %d\n"
 4 .text
 5 .global main
 6 .type main, @function
 7 main:
 8 pushl %ebp
 9 movl %esp, %ebp
10 subl $0, %esp # reserve local variable
11 movl $1, %eax
12 ADD $2, %eax
13 pushl %eax
14 popl %eax
15 pushl %eax
16 pushl $LC1
17 call printf
18 addl $8, %esp
19 leave
20 ret
21 
22 xyz:

奮戰幾天後, op2.o.elf 由 simple_as 將 op2.S 轉成 op2.o

op2.o.elf
 1 ELF Header:
 2   Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
 3   Class:                             ELF32
 4   Data:                              2's complement, little endian
 5   Version:                           1 (current)
 6   OS/ABI:                            UNIX - System V
 7   ABI Version:                       0
 8   Type:                              REL (Relocatable file)
 9   Machine:                           Intel 80386
10   Version:                           0x1
11   Entry point address:               0x0
12   Start of program headers:          0 (bytes into file)
13   Start of section headers:          337 (bytes into file)
14   Flags:                             0x0
15   Size of this header:               52 (bytes)
16   Size of program headers:           0 (bytes)
17   Number of program headers:         0
18   Size of section headers:           40 (bytes)
19   Number of section headers:         9
20   Section header string table index: 5
21 
22 Section Headers:
23   [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
24   [ 0]                   NULL            00000000 000000 000000 00      0   0  0
25   [ 1] .bss              NOBITS          00000000 000034 000000 00  WA  0   0  1
26   [ 2] .data             PROGBITS        00000000 000034 000000 00  WA  0   0  1
27   [ 3] .rel.text         REL             00000000 000034 000010 08   I  7   8  4
28   [ 4] .rodata           PROGBITS        00000000 000044 00000a 00      0   0  0
29   [ 5] .shstrtab         STRTAB          00000000 00004e 00003e 00      0   0  0
30   [ 6] .strtab           STRTAB          00000000 00008c 000015 00      0   0  0
31   [ 7] .symtab           SYMTAB          00000000 0000a1 000090 10      6   7  0
32   [ 8] .text             PROGBITS        00000000 000131 000020 00  AX  0   0  0
33 Key to Flags:
34   W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
35   L (link order), O (extra OS processing required), G (group), T (TLS),
36   C (compressed), x (unknown), o (OS specific), E (exclude),
37   p (processor specific)
38 
39 There are no section groups in this file.
40 
41 There are no program headers in this file.
42 
43 Relocation section '.rel.text' at offset 0x34 contains 2 entries:
44  Offset     Info    Type            Sym.Value  Sym. Name
45 00000012  00000301 R_386_32          00000000   .rodata
46 00000017  00000802 R_386_PC32        00000000   printf
47 
48 The decoding of unwind sections for machine type Intel 80386 is not currently supported.
49 
50 Symbol table '.symtab' contains 9 entries:
51    Num:    Value  Size Type    Bind   Vis      Ndx Name
52      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
53      1: 00000000     0 SECTION LOCAL  DEFAULT    1 
54      2: 00000000     0 SECTION LOCAL  DEFAULT    2 
55      3: 00000000     0 SECTION LOCAL  DEFAULT    4 
56      4: 00000000     0 SECTION LOCAL  DEFAULT    8 
57      5: 00000000     0 NOTYPE  LOCAL  DEFAULT    4 LC1
58      6: 00000000     0 NOTYPE  LOCAL  DEFAULT    8 xyz
59      7: 00000000     0 FUNC    GLOBAL DEFAULT    8 main
60      8: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND printf
61 
62 No version information found in this file.

儘管有些部份是 hard code, 但已經可以讓 gcc link 成 elf 執行檔。 執行後正常輸出
descent@debian64:test_pattern$ ./op2 
1+2 = 3

單純印出 hello world 比較簡單, 所以用 1+2 來測試。真是太爽了。
繼續閱讀

2017/04/08

pascal & gdb

pas_gdb
 1 descent@deb:pascal$ gdb h
 2 GNU gdb (Debian 7.11.1-2) 7.11.1
 3 Copyright (C) 2016 Free Software Foundation, Inc.
 4 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 5 This is free software: you are free to change and redistribute it.
 6 There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
 7 and "show warranty" for details.
 8 This GDB was configured as "x86_64-linux-gnu".
 9 Type "show configuration" for configuration details.
10 For bug reporting instructions, please see:
11 <http://www.gnu.org/software/gdb/bugs/>.
12 Find the GDB manual and other documentation resources online at:
13 <http://www.gnu.org/software/gdb/documentation/>.
14 For help, type "help".
15 Type "apropos word" to search for commands related to "word"...
16 Reading symbols from h...done.
17 (gdb) l
18 1 Program h;
19 2 (*Uses f1, Crt in '/usr/local/lib/fpc/3.1.1/units/i386-linux/rtl-console/crt.ppu';*)
20 3 Uses f1, Crt;
21 4 
22 5   var x, v: integer;
23 6 begin
24 7 
25 8   x := max(5,6);
26 9   v := min(5,6);
27 10   Writeln('hello free pascal, max: ', x);
28 (gdb) l
29 11   Writeln('hello free pascal, min: ', v);
30 12 end.
繼續閱讀