factory.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*This file implements MTK boot mode.*/
  2. #include <sys/types.h>
  3. #include <debug.h>
  4. #include <err.h>
  5. #include <reg.h>
  6. #include <platform/mt_typedefs.h>
  7. #include <platform/boot_mode.h>
  8. #include <platform/mt_reg_base.h>
  9. #include <platform/mtk_key.h>
  10. #include <platform/mt_gpt.h>
  11. #include <target/cust_key.h>
  12. #define MODULE_NAME "[FACTORY]"
  13. BOOL factory_check_key_trigger(void)
  14. {
  15. #if 1
  16. //wait
  17. ulong begin = get_timer(0);
  18. printf("\n%s Check factory boot\n",MODULE_NAME);
  19. printf("%s Wait 50ms for special keys\n",MODULE_NAME);
  20. /* If the boot reason is RESET and volume down is uesd as reset key, than we will NOT enter factory mode. */
  21. //this function is marked because we use volume up to reset phone on ROME
  22. /*
  23. if(mtk_detect_pmic_just_rst())
  24. {
  25. return false;
  26. }
  27. */
  28. while(get_timer(begin)<50)
  29. {
  30. if(mtk_detect_key(MT65XX_FACTORY_KEY))
  31. {
  32. printf("%s Detect key\n",MODULE_NAME);
  33. printf("%s Enable factory mode\n",MODULE_NAME);
  34. g_boot_mode = FACTORY_BOOT;
  35. //video_printf("%s : detect factory mode !\n",MODULE_NAME);
  36. return TRUE;
  37. }
  38. }
  39. #endif
  40. return FALSE;
  41. }
  42. extern BOOT_ARGUMENT *g_boot_arg;
  43. BOOL factory_detection(void)
  44. {
  45. // int forbid_mode = 0;
  46. if(g_boot_arg->sec_limit.magic_num == 0x4C4C4C4C)
  47. {
  48. if(g_boot_arg->sec_limit.forbid_mode == F_FACTORY_MODE)
  49. {
  50. //Forbid to enter factory mode
  51. dprintf(INFO, "%s Forbidden\n",MODULE_NAME);
  52. return FALSE;
  53. }
  54. }
  55. //forbid_mode =
  56. g_boot_arg->boot_mode &= 0x000000FF;
  57. if(factory_check_key_trigger())
  58. {
  59. return TRUE;
  60. }
  61. return FALSE;
  62. }