@@ -267,3 +267,65 @@ void device_truedualboot_after_load_volume_table() {
267
267
v -> blk_device = PATH_USERDATA_NODE_BACKUP ;
268
268
}
269
269
}
270
+
271
+ static int set_bootmode (char * bootmode ) {
272
+ // open misc-partition
273
+ FILE * misc = fopen ("/dev/block/platform/msm_sdcc.1/by-name/misc" , "wb" );
274
+ if (misc == NULL ) {
275
+ printf ("Error opening misc partition.\n" );
276
+ return -1 ;
277
+ }
278
+
279
+ // write bootmode
280
+ fseek (misc , 0x1000 , SEEK_SET );
281
+ if (fputs (bootmode , misc )< 0 ) {
282
+ printf ("Error writing bootmode to misc partition.\n" );
283
+ return -1 ;
284
+ }
285
+
286
+ // close
287
+ fclose (misc );
288
+ return 0 ;
289
+ }
290
+
291
+ static int get_bootmode (char * bootmode ) {
292
+ // open misc-partition
293
+ FILE * misc = fopen ("/dev/block/platform/msm_sdcc.1/by-name/misc" , "rb" );
294
+ if (misc == NULL ) {
295
+ printf ("Error opening misc partition.\n" );
296
+ return -1 ;
297
+ }
298
+
299
+ // read bootmode
300
+ fseek (misc , 0x1000 , SEEK_SET );
301
+ if (fgets (bootmode , 13 , misc )== NULL ) {
302
+ printf ("Error reading bootmode from misc partition.\n" );
303
+ return -1 ;
304
+ }
305
+
306
+ // close
307
+ fclose (misc );
308
+ return 0 ;
309
+ }
310
+
311
+ void device_choose_bootmode (void ) {
312
+ int sys = dualboot_select_system ("Set bootmode:" );
313
+ if (sys == GO_BACK ) return ;
314
+
315
+ if (sys == SYSTEM1 )
316
+ set_bootmode ("boot-system0" );
317
+ else if (sys == SYSTEM2 )
318
+ set_bootmode ("boot-system1" );
319
+ }
320
+
321
+ int device_get_bootmode (char * bootmode_name ) {
322
+ char * sysnum = 0 ;
323
+
324
+ char bootmode [13 ];
325
+ get_bootmode (& bootmode );
326
+ if (strcmp (bootmode , "boot-system1" )== 0 )
327
+ sysnum = 1 ;
328
+
329
+ sprintf (bootmode_name , "active system: %d" , sysnum + 1 );
330
+ return 0 ;
331
+ }
0 commit comments