summaryrefslogtreecommitdiff
path: root/utils/ibassoboot/jni/ibassodualboot.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/ibassoboot/jni/ibassodualboot.c')
-rw-r--r--utils/ibassoboot/jni/ibassodualboot.c771
1 files changed, 771 insertions, 0 deletions
diff --git a/utils/ibassoboot/jni/ibassodualboot.c b/utils/ibassoboot/jni/ibassodualboot.c
new file mode 100644
index 0000000000..0458ff1b71
--- /dev/null
+++ b/utils/ibassoboot/jni/ibassodualboot.c
@@ -0,0 +1,771 @@
1/***************************************************************************
2 * __________ __ ___
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2014 by Ilia Sergachev: Initial Rockbox port to iBasso DX50
10 * Copyright (C) 2014 by Mario Basister: iBasso DX90 port
11 * Copyright (C) 2014 by Simon Rothen: Initial Rockbox repository submission, additional features
12 * Copyright (C) 2014 by Udo Schläpfer: Code clean up, additional features
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23
24
25#include <dirent.h>
26#include <fcntl.h>
27#include <pthread.h>
28#include <stdbool.h>
29#include <stdlib.h>
30#include <unistd.h>
31#include <linux/fb.h>
32#include <linux/input.h>
33#include <sys/mman.h>
34#include <sys/poll.h>
35#include <sys/reboot.h>
36#include <sys/socket.h>
37#include <sys/un.h>
38#include <sys/wait.h>
39
40#include "qdbmp.h"
41
42
43/*- Android logcat ------------------------------------------------------------------------------*/
44
45
46#ifdef DEBUG
47#include <android/log.h>
48
49
50static const char log_tag[] = "Rockbox Boot";
51
52
53void debugf(const char *fmt, ...)
54{
55 va_list ap;
56 va_start(ap, fmt);
57 __android_log_vprint(ANDROID_LOG_DEBUG, log_tag, fmt, ap);
58 va_end(ap);
59}
60
61
62void ldebugf(const char* file, int line, const char *fmt, ...)
63{
64 va_list ap;
65 /* 13: 5 literal chars and 8 chars for the line number. */
66 char buf[strlen(file) + strlen(fmt) + 13];
67 snprintf(buf, sizeof(buf), "%s (%d): %s", file, line, fmt);
68 va_start(ap, fmt);
69 __android_log_vprint(ANDROID_LOG_DEBUG, log_tag, buf, ap);
70 va_end(ap);
71}
72
73
74void debug_trace(const char* function)
75{
76 static const char trace_tag[] = "TRACE: ";
77 char msg[strlen(trace_tag) + strlen(function) + 1];
78 snprintf(msg, sizeof(msg), "%s%s", trace_tag, function);
79 __android_log_write(ANDROID_LOG_DEBUG, log_tag, msg);
80}
81
82
83#define DEBUGF debugf
84#define TRACE debug_trace(__func__)
85#else
86#define DEBUGF(...)
87#define TRACE
88#endif /* DEBUG */
89
90
91/*- Vold monitor --------------------------------------------------------------------------------*/
92
93
94/*
95 Without this socket iBasso Vold will not start.
96 iBasso Vold uses this to send status messages about storage devices.
97*/
98static const char VOLD_MONITOR_SOCKET_NAME[] = "UNIX_domain";
99static int _vold_monitor_socket_fd = -1;
100
101
102static void vold_monitor_open_socket(void)
103{
104 TRACE;
105
106 unlink(VOLD_MONITOR_SOCKET_NAME);
107
108 _vold_monitor_socket_fd = socket(AF_UNIX, SOCK_STREAM, 0);
109
110 if(_vold_monitor_socket_fd < 0)
111 {
112 _vold_monitor_socket_fd = -1;
113 return;
114 }
115
116 struct sockaddr_un addr;
117 memset(&addr, 0, sizeof(addr));
118 addr.sun_family = AF_UNIX;
119 strncpy(addr.sun_path, VOLD_MONITOR_SOCKET_NAME, sizeof(addr.sun_path) - 1);
120
121 if(bind(_vold_monitor_socket_fd, (struct sockaddr*) &addr, sizeof(addr)) < 0)
122 {
123 close(_vold_monitor_socket_fd);
124 unlink(VOLD_MONITOR_SOCKET_NAME);
125 _vold_monitor_socket_fd = -1;
126 return;
127 }
128
129 if(listen(_vold_monitor_socket_fd, 1) < 0)
130 {
131 close(_vold_monitor_socket_fd);
132 unlink(VOLD_MONITOR_SOCKET_NAME);
133 _vold_monitor_socket_fd = -1;
134 return;
135 }
136}
137
138
139/*
140 bionic does not have pthread_cancel.
141 0: Vold monitor thread stopped/ending.
142 1: Vold monitor thread started/running.
143*/
144static volatile sig_atomic_t _vold_monitor_active = 0;
145
146
147/* true: sdcard not mounted. */
148static bool _sdcard_not_mounted = true;
149
150
151/* Mutex for sdcard mounted flag. */
152static pthread_mutex_t _sdcard_mount_mtx = PTHREAD_MUTEX_INITIALIZER;
153
154
155/* Signal condition for sdcard mounted flag. */
156static pthread_cond_t _sdcard_mount_cond = PTHREAD_COND_INITIALIZER;
157
158
159static void* vold_monitor_run(void* nothing)
160{
161 _vold_monitor_active = 1;
162
163 (void) nothing;
164
165 DEBUGF("DEBUG %s: Thread start.", __func__);
166
167 vold_monitor_open_socket();
168 if(_vold_monitor_socket_fd < 0)
169 {
170 DEBUGF("ERROR %s: Thread end: No socket.", __func__);
171
172 _vold_monitor_active = 0;
173 return 0;
174 }
175
176 struct pollfd fds[1];
177 fds[0].fd = _vold_monitor_socket_fd;
178 fds[0].events = POLLIN;
179
180 while(_vold_monitor_active == 1)
181 {
182 poll(fds, 1, 10);
183 if(! (fds[0].revents & POLLIN))
184 {
185 continue;
186 }
187
188 int socket_fd = accept(_vold_monitor_socket_fd, NULL, NULL);
189
190 if(socket_fd < 0)
191 {
192 DEBUGF("ERROR %s: accept failed.", __func__);
193
194 continue;
195 }
196
197 while(true)
198 {
199 char msg[1024];
200 memset(msg, 0, sizeof(msg));
201 int length = read(socket_fd, msg, sizeof(msg));
202
203 if(length <= 0)
204 {
205 close(socket_fd);
206 break;
207 }
208
209 DEBUGF("DEBUG %s: msg: %s", __func__, msg);
210
211 if(strcmp(msg, "Volume flash /mnt/sdcard state changed from 3 (Checking) to 4 (Mounted)") == 0)
212 {
213 pthread_mutex_lock(&_sdcard_mount_mtx);
214 _sdcard_not_mounted = false;
215 pthread_cond_signal(&_sdcard_mount_cond);
216 pthread_mutex_unlock(&_sdcard_mount_mtx);
217 }
218 }
219 }
220
221 close(_vold_monitor_socket_fd);
222 unlink(VOLD_MONITOR_SOCKET_NAME);
223 _vold_monitor_socket_fd = -1;
224
225 DEBUGF("DEBUG %s: Thread end.", __func__);
226
227 _vold_monitor_active = 0;
228 return 0;
229}
230
231
232/* Vold monitor thread. */
233static pthread_t _vold_monitor_thread;
234
235
236static void vold_monitor_start(void)
237{
238 TRACE;
239
240 if(_vold_monitor_active == 0)
241 {
242 pthread_create(&_vold_monitor_thread, NULL, vold_monitor_run, NULL);
243 }
244}
245
246
247static void vold_monitor_stop(void)
248{
249 TRACE;
250
251 if(_vold_monitor_active == 1)
252 {
253 _vold_monitor_active = 0;
254 int ret = pthread_join(_vold_monitor_thread, NULL);
255 DEBUGF("DEBUG %s: Thread joined: ret: %d.", __func__, ret);
256 }
257}
258
259
260/*- Input handler -------------------------------------------------------------------------------*/
261
262
263/* Input devices monitored with poll API. */
264static struct pollfd* _fds = NULL;
265
266
267/* Number of input devices monitored with poll API. */
268static nfds_t _nfds = 0;
269
270
271/* The names of the devices in _fds. */
272static char** _device_names = NULL;
273
274
275/* Open device device_name and add it to the list of polled devices. */
276static void open_device(const char* device_name)
277{
278 int fd = open(device_name, O_RDONLY);
279 if(fd == -1)
280 {
281 DEBUGF("ERROR %s: open failed on %s.", __func__, device_name);
282 exit(-1);
283 }
284
285 struct pollfd* new_fds = realloc(_fds, sizeof(struct pollfd) * (_nfds + 1));
286 if(new_fds == NULL)
287 {
288 DEBUGF("ERROR %s: realloc for _fds failed.", __func__);
289 exit(-1);
290 }
291
292 _fds = new_fds;
293 _fds[_nfds].fd = fd;
294 _fds[_nfds].events = POLLIN;
295
296 char** new_device_names = realloc(_device_names, sizeof(char*) * (_nfds + 1));
297 if(new_device_names == NULL)
298 {
299 DEBUGF("ERROR %s: realloc for _device_names failed.", __func__);
300 exit(-1);
301 }
302
303 _device_names = new_device_names;
304 _device_names[_nfds] = strdup(device_name);
305 if(_device_names[_nfds] == NULL)
306 {
307 DEBUGF("ERROR %s: strdup failed.", __func__);
308 exit(-1);
309 }
310
311 ++_nfds;
312
313 DEBUGF("DEBUG %s: Opened device %s.", __func__, device_name);
314}
315
316
317static void button_init_device(void)
318{
319 TRACE;
320
321 if((_fds != NULL) || (_nfds != 0) || (_device_names != NULL))
322 {
323 DEBUGF("ERROR %s: Allready initialized.", __func__);
324 return;
325 }
326
327 /* The input device directory. */
328 static const char device_path[] = "/dev/input";
329
330 /* Path delimeter. */
331 static const char delimeter[] = "/";
332
333 /* Open all devices in device_path. */
334 DIR* dir = opendir(device_path);
335 if(dir == NULL)
336 {
337 DEBUGF("ERROR %s: opendir failed: errno: %d.", __func__, errno);
338 exit(errno);
339 }
340
341 char device_name[PATH_MAX];
342 strcpy(device_name, device_path);
343 strcat(device_name, delimeter);
344 char* device_name_idx = device_name + strlen(device_name);
345
346 struct dirent* dir_entry;
347 while((dir_entry = readdir(dir)))
348 {
349 if( ((dir_entry->d_name[0] == '.') && (dir_entry->d_name[1] == '\0'))
350 || ((dir_entry->d_name[0] == '.') && (dir_entry->d_name[1] == '.') && (dir_entry->d_name[2] == '\0')))
351 {
352 continue;
353 }
354
355 strcpy(device_name_idx, dir_entry->d_name);
356
357 /* Open and add device to _fds. */
358 open_device(device_name);
359 }
360
361 closedir(dir);
362
363 /* Sanity check. */
364 if(_nfds < 2)
365 {
366 DEBUGF("ERROR %s: No input devices.", __func__);
367 exit(-1);
368 }
369}
370
371
372#define EVENT_TYPE_BUTTON 1
373
374
375#define EVENT_CODE_BUTTON_PWR_LONG 117
376#define EVENT_CODE_BUTTON_REV 160
377#define EVENT_CODE_BUTTON_NEXT 162
378
379
380#define EVENT_TYPE_TOUCHSCREEN 3
381
382
383#define EVENT_CODE_TOUCHSCREEN_X 53
384
385
386enum user_choice
387{
388 CHOICE_NONE = -1,
389 CHOICE_MANGO,
390 CHOICE_ROCKBOX,
391 CHOICE_POWEROFF
392};
393
394
395static int get_user_choice(void)
396{
397 TRACE;
398
399 button_init_device();
400
401 enum user_choice choice = CHOICE_NONE;
402
403 while(choice == CHOICE_NONE)
404 {
405 /* Poll all input devices. */
406 poll(_fds, _nfds, 0);
407
408 nfds_t fds_idx = 0;
409 for( ; fds_idx < _nfds; ++fds_idx)
410 {
411 if(! (_fds[fds_idx].revents & POLLIN))
412 {
413 continue;
414 }
415
416 struct input_event event;
417 if(read(_fds[fds_idx].fd, &event, sizeof(event)) < (int) sizeof(event))
418 {
419 DEBUGF("ERROR %s: Read of input devices failed.", __func__);
420 continue;
421 }
422
423 DEBUGF("DEBUG %s: device: %s, event.type: %d, event.code: %d, event.value: %d", __func__, _device_names[fds_idx], event.type, event.code, event.value);
424
425 if(event.type == EVENT_TYPE_BUTTON)
426 {
427 switch(event.code)
428 {
429 case EVENT_CODE_BUTTON_REV:
430 {
431 choice = CHOICE_MANGO;
432 break;
433 }
434
435 case EVENT_CODE_BUTTON_NEXT:
436 {
437 choice = CHOICE_ROCKBOX;
438 break;
439 }
440
441 case EVENT_CODE_BUTTON_PWR_LONG:
442 {
443 choice = CHOICE_POWEROFF;
444 break;
445 }
446 }
447 }
448 else if((event.type == EVENT_TYPE_TOUCHSCREEN) && (event.code == EVENT_CODE_TOUCHSCREEN_X))
449 {
450 if(event.value < 160)
451 {
452 choice = CHOICE_MANGO;
453 }
454 else
455 {
456 choice = CHOICE_ROCKBOX;
457 }
458 }
459 }
460 }
461
462 if(_fds)
463 {
464 nfds_t fds_idx = 0;
465 for( ; fds_idx < _nfds; ++fds_idx)
466 {
467 close(_fds[fds_idx].fd);
468 }
469 free(_fds);
470 _fds = NULL;
471 }
472
473 if(_device_names)
474 {
475 nfds_t fds_idx = 0;
476 for( ; fds_idx < _nfds; ++fds_idx)
477 {
478 free(_device_names[fds_idx]);
479 }
480 free(_device_names);
481 _device_names = NULL;
482 }
483
484 _nfds = 0;
485
486 return choice;
487}
488
489
490/*
491 Changing bit, when hold switch is toggled.
492 Bit is off when hold switch is engaged.
493*/
494#define HOLD_SWITCH_BIT 16
495
496
497static bool check_for_hold(void)
498{
499 TRACE;
500
501 char hold_state;
502
503 FILE* f = fopen("/sys/class/axppower/holdkey", "r");
504 fscanf(f, "%c", &hold_state);
505 fclose(f);
506
507 return(! (hold_state & HOLD_SWITCH_BIT));
508}
509
510
511/*- Display -------------------------------------------------------------------------------------*/
512
513
514static void draw(const char* file)
515{
516 DEBUGF("DEBUG %s: file: %s.", __func__, file);
517
518 int dev_fd = open("/dev/graphics/fb0", O_RDWR);
519 if(dev_fd == -1)
520 {
521 DEBUGF("ERROR %s: open failed on /dev/graphics/fb0, errno: %d.", __func__, errno);
522 exit(errno);
523 }
524
525 /* Get fixed screen information. */
526 struct fb_fix_screeninfo finfo;
527 if(ioctl(dev_fd, FBIOGET_FSCREENINFO, &finfo) < 0)
528 {
529 DEBUGF("ERROR %s: ioctl FBIOGET_FSCREENINFO failed on /dev/graphics/fb0, errno: %d.", __func__, errno);
530 exit(errno);
531 }
532
533 /* Get the changeable information. */
534 struct fb_var_screeninfo vinfo;
535 if(ioctl(dev_fd, FBIOGET_VSCREENINFO, &vinfo) < 0)
536 {
537 DEBUGF("ERROR %s: ioctl FBIOGET_VSCREENINFO failed on /dev/graphics/fb0, errno: %d.", __func__, errno);
538 exit(errno);
539 }
540
541 DEBUGF("DEBUG %s: bits_per_pixel: %u, width: %u, height: %u.", __func__, vinfo.bits_per_pixel, vinfo.width, vinfo.height);
542
543 size_t screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
544
545 /* ToDo: Is this needed? */
546 vinfo.xres = 320;
547 vinfo.xres_virtual = 320;
548 vinfo.width = 320;
549 vinfo.yres = 240;
550 vinfo.yres_virtual = 240;
551 vinfo.height = 240;
552 vinfo.xoffset = 0;
553 vinfo.yoffset = 0;
554 vinfo.sync = 0;
555 vinfo.vmode = 0;
556 vinfo.pixclock = 104377;
557 vinfo.left_margin = 20;
558 vinfo.right_margin = 50;
559 vinfo.upper_margin = 2;
560 vinfo.lower_margin = 4;
561 vinfo.hsync_len = 10;
562 vinfo.vsync_len = 2;
563 vinfo.red.offset = 11;
564 vinfo.red.length = 5;
565 vinfo.red.msb_right = 0;
566 vinfo.green.offset = 5;
567 vinfo.green.length = 6;
568 vinfo.green.msb_right = 0;
569 vinfo.blue.offset = 0;
570 vinfo.blue.length = 5;
571 vinfo.blue.msb_right = 0;
572 vinfo.transp.offset = 0;
573 vinfo.transp.length = 0;
574 vinfo.transp.msb_right = 0;
575 vinfo.nonstd = 4;
576 if(ioctl(dev_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0)
577 {
578 DEBUGF("ERROR %s: ioctl FBIOPUT_VSCREENINFO failed on /dev/graphics/fb0, errno: %d.", __func__, errno);
579 exit(errno);
580 }
581
582 /* Map the device to memory. */
583 char* dev_fb = (char*) mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, dev_fd, 0);
584 if(dev_fb == MAP_FAILED)
585 {
586 DEBUGF("ERROR %s: mmap failed on /dev/graphics/fb0, errno: %d.", __func__, errno);
587 exit(errno);
588 }
589
590 BMP* bmp = BMP_ReadFile(file);
591 if(BMP_GetError() != BMP_OK )
592 {
593 DEBUGF("ERROR %s: BMP_ReadFile failed on %s: %d.", __func__, file, BMP_GetError());
594 exit(BMP_GetError());
595 }
596
597 int y = 0;
598 for( ; y < 240; ++y)
599 {
600 int x = 0;
601 for( ; x < 320; ++x)
602 {
603 long int position = (x + vinfo.xoffset) * (vinfo.bits_per_pixel / 8 )
604 + (y + vinfo.yoffset) * finfo.line_length;
605 UCHAR r, g, b;
606 BMP_GetPixelRGB(bmp, x, y, &r, &g, &b);
607 unsigned short int pixel = (r >> 3) << 11 | (g >> 2) << 5 | (b >> 3);
608 *((unsigned short int*)(dev_fb + position)) = pixel;
609 }
610 }
611
612 BMP_Free(bmp);
613 munmap(dev_fb, screensize);
614 close(dev_fd);
615}
616
617
618/*-----------------------------------------------------------------------------------------------*/
619
620
621static const char ROCKBOX_BIN[] = "/mnt/sdcard/.rockbox/rockbox";
622static const char OF_PLAYER_BIN[] = "/system/bin/MangoPlayer_original";
623static const char PLAYER_FILE[] = "/data/chosen_player";
624
625
626int main(int argc, char **argv)
627{
628 TRACE;
629
630 /*
631 Create the iBasso Vold socket and monitor it.
632 Do this early to not block Vold.
633 */
634 vold_monitor_start();
635
636 int last_chosen_player = CHOICE_NONE;
637
638 FILE* f = fopen(PLAYER_FILE, "r");
639 if(f != NULL)
640 {
641 fscanf(f, "%d", &last_chosen_player);
642 fclose(f);
643 }
644
645 DEBUGF("DEBUG %s: Current player choice: %d.", __func__, last_chosen_player);
646
647 if(check_for_hold() || (last_chosen_player == CHOICE_NONE))
648 {
649 draw("/system/chooser.bmp");
650
651 enum user_choice choice = get_user_choice();
652
653 if(choice == CHOICE_POWEROFF)
654 {
655 reboot(RB_POWER_OFF);
656 while(true)
657 {
658 sleep(1);
659 }
660 }
661
662 if(choice != last_chosen_player)
663 {
664 last_chosen_player = choice;
665
666 f = fopen(PLAYER_FILE, "w");
667 fprintf(f, "%d", last_chosen_player);
668 fclose(f);
669 }
670
671 DEBUGF("DEBUG %s: New player choice: %d.", __func__, last_chosen_player);
672 }
673
674 /* true, Rockbox was started at least once. */
675 bool rockboxStarted = false;
676
677 while(true)
678 {
679 /* Excecute OF MangoPlayer or Rockbox and restart it if it crashes. */
680
681 if(last_chosen_player == CHOICE_ROCKBOX)
682 {
683 if(rockboxStarted)
684 {
685 /*
686 At this point it is assumed, that Rockbox has exited due to a USB connection
687 triggering a remount of the internal storage for mass storage access.
688 Rockbox will eventually restart, when /mnt/sdcard becomes available again.
689 */
690 draw("/system/usb.bmp");
691 }
692
693 pthread_mutex_lock(&_sdcard_mount_mtx);
694 while(_sdcard_not_mounted)
695 {
696 DEBUGF("DEBUG %s: Waiting on /mnt/sdcard/.", __func__);
697
698 pthread_cond_wait(&_sdcard_mount_cond, &_sdcard_mount_mtx);
699
700 DEBUGF("DEBUG %s: /mnt/sdcard/ available.", __func__);
701 }
702 pthread_mutex_unlock(&_sdcard_mount_mtx);
703
704 /* To be able to execute rockbox. */
705 system("mount -o remount,exec /mnt/sdcard");
706
707 /* This symlink is needed mainly to keep themes functional. */
708 system("ln -s /mnt/sdcard/.rockbox /.rockbox");
709
710 if(access(ROCKBOX_BIN, X_OK) != -1)
711 {
712 /* Start Rockbox. */
713
714 /* Rockbox has its own vold monitor. */
715 vold_monitor_stop();
716
717 DEBUGF("DEBUG %s: Excecuting %s.", __func__, ROCKBOX_BIN);
718
719 int ret_code = system(ROCKBOX_BIN);
720 rockboxStarted = true;
721
722 DEBUGF("DEBUG %s: ret_code: %d.", __func__, ret_code);
723
724 if(WIFEXITED(ret_code) && (WEXITSTATUS(ret_code) == 42))
725 {
726 /*
727 Rockbox terminated to prevent a froced shutdown due to a USB connection
728 triggering a remount of the internal storage for mass storage access.
729 */
730 _sdcard_not_mounted = true;
731 }
732 /* else Rockbox crashed ... */
733
734 vold_monitor_start();
735 }
736 else
737 {
738 /* Rockbox executable missing. Show info screen for 30 seconds. */
739 draw("/system/rbmissing.bmp");
740 sleep(30);
741
742 /* Do not block Vold, so stop after sleep. */
743 vold_monitor_stop();
744
745#ifdef DEBUG
746 system("setprop persist.sys.usb.config adb");
747 system("setprop persist.usb.debug 1");
748#endif
749
750 DEBUGF("DEBUG %s: Rockbox missing, excecuting %s.", __func__, OF_PLAYER_BIN);
751
752 /* Start OF MangoPlayer. */
753 int ret_code = system(OF_PLAYER_BIN);
754
755 DEBUGF("DEBUG %s: ret_code: %d.", __func__, ret_code);
756 }
757 }
758 else /* if(last_chosen_player == CHOICE_MANGO) */
759 {
760 vold_monitor_stop();
761
762 DEBUGF("DEBUG %s: Excecuting %s.", __func__, OF_PLAYER_BIN);
763
764 int ret_code = system(OF_PLAYER_BIN);
765
766 DEBUGF("DEBUG %s: ret_code: %d.", __func__, ret_code);
767 }
768 }
769
770 return 0;
771}