setup.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. *
  3. * arch/xtensa/platform-iss/setup.c
  4. *
  5. * Platform specific initialization.
  6. *
  7. * Authors: Chris Zankel <chris@zankel.net>
  8. * Joe Taylor <joe@tensilica.com>
  9. *
  10. * Copyright 2001 - 2005 Tensilica Inc.
  11. * Copyright 2017 Cadence Design Systems Inc.
  12. *
  13. * This program is free software; you can redistribute it and/or modify it
  14. * under the terms of the GNU General Public License as published by the
  15. * Free Software Foundation; either version 2 of the License, or (at your
  16. * option) any later version.
  17. *
  18. */
  19. #include <linux/bootmem.h>
  20. #include <linux/stddef.h>
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <linux/errno.h>
  24. #include <linux/reboot.h>
  25. #include <linux/kdev_t.h>
  26. #include <linux/types.h>
  27. #include <linux/major.h>
  28. #include <linux/blkdev.h>
  29. #include <linux/console.h>
  30. #include <linux/delay.h>
  31. #include <linux/stringify.h>
  32. #include <linux/notifier.h>
  33. #include <asm/platform.h>
  34. #include <asm/bootparam.h>
  35. #include <asm/setup.h>
  36. #include <platform/simcall.h>
  37. void __init platform_init(bp_tag_t* bootparam)
  38. {
  39. }
  40. void platform_halt(void)
  41. {
  42. pr_info(" ** Called platform_halt() **\n");
  43. simc_exit(0);
  44. }
  45. void platform_power_off(void)
  46. {
  47. pr_info(" ** Called platform_power_off() **\n");
  48. simc_exit(0);
  49. }
  50. void platform_restart(void)
  51. {
  52. /* Flush and reset the mmu, simulate a processor reset, and
  53. * jump to the reset vector. */
  54. cpu_reset();
  55. /* control never gets here */
  56. }
  57. void platform_heartbeat(void)
  58. {
  59. }
  60. static int
  61. iss_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
  62. {
  63. simc_exit(1);
  64. return NOTIFY_DONE;
  65. }
  66. static struct notifier_block iss_panic_block = {
  67. .notifier_call = iss_panic_event,
  68. };
  69. void __init platform_setup(char **p_cmdline)
  70. {
  71. int argc = simc_argc();
  72. int argv_size = simc_argv_size();
  73. if (argc > 1) {
  74. void **argv = alloc_bootmem(argv_size);
  75. char *cmdline = alloc_bootmem(argv_size);
  76. int i;
  77. cmdline[0] = 0;
  78. simc_argv((void *)argv);
  79. for (i = 1; i < argc; ++i) {
  80. if (i > 1)
  81. strcat(cmdline, " ");
  82. strcat(cmdline, argv[i]);
  83. }
  84. *p_cmdline = cmdline;
  85. }
  86. atomic_notifier_chain_register(&panic_notifier_list, &iss_panic_block);
  87. }