scsiPhy.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. /**
  2. * SCSI2SD V6 - Copyright (C) 2013 Michael McMaster <michael@codesrc.com>
  3. * ZuluSCSI™ - Copyright (c) 2022-2025 Rabbit Hole Computing™
  4. *
  5. * This file is licensed under the GPL version 3 or any later version.  
  6. * It is derived from scsiPhy.c in SCSI2SD V6.
  7. *
  8. * https://www.gnu.org/licenses/gpl-3.0.html
  9. * ----
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version. 
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. * GNU General Public License for more details. 
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  22. **/
  23. // Implements the low level interface to SCSI bus
  24. // Partially derived from scsiPhy.c from SCSI2SD-V6
  25. #include "scsiPhy.h"
  26. #include "ZuluSCSI_platform.h"
  27. #include "scsi_accel_asm.h"
  28. #include "scsi_accel_dma.h"
  29. #include "scsi_accel_greenpak.h"
  30. #include "scsi_accel_sync.h"
  31. #include "ZuluSCSI_log.h"
  32. #include "ZuluSCSI_log_trace.h"
  33. #include "ZuluSCSI_config.h"
  34. #include "ZuluSCSI_settings.h"
  35. #include <minIni.h>
  36. #include <scsi2sd.h>
  37. extern "C" {
  38. #include <scsi.h>
  39. #include <scsi2sd_time.h>
  40. }
  41. // Acceleration mode in use
  42. static enum {
  43. PHY_MODE_BEST_AVAILABLE = 0,
  44. PHY_MODE_PIO = 1,
  45. PHY_MODE_DMA_TIMER = 2,
  46. PHY_MODE_GREENPAK_PIO = 3,
  47. PHY_MODE_GREENPAK_DMA = 4
  48. } g_scsi_phy_mode;
  49. static const char *g_scsi_phy_mode_names[] = {
  50. "Unknown", "PIO", "DMA_TIMER", "GREENPAK_PIO", "GREENPAK_DMA"
  51. };
  52. // State of polling write request
  53. static struct {
  54. const uint8_t *data;
  55. uint32_t count;
  56. bool use_sync_mode;
  57. } g_scsi_writereq;
  58. static void init_irqs();
  59. /***********************/
  60. /* SCSI status signals */
  61. /***********************/
  62. extern "C" bool scsiStatusATN()
  63. {
  64. return SCSI_IN(ATN);
  65. }
  66. extern "C" bool scsiStatusBSY()
  67. {
  68. return SCSI_IN(BSY);
  69. }
  70. /************************/
  71. /* SCSI selection logic */
  72. /************************/
  73. volatile uint8_t g_scsi_sts_selection;
  74. volatile uint8_t g_scsi_ctrl_bsy;
  75. static void scsi_bsy_deassert_interrupt()
  76. {
  77. if (SCSI_IN(SEL) && !SCSI_IN(BSY))
  78. {
  79. uint8_t sel_bits = SCSI_IN_DATA();
  80. int sel_id = -1;
  81. for (int i = 0; i < S2S_MAX_TARGETS; i++)
  82. {
  83. if (scsiDev.targets[i].targetId <= 7 && scsiDev.targets[i].cfg)
  84. {
  85. if (sel_bits & (1 << scsiDev.targets[i].targetId))
  86. {
  87. sel_id = scsiDev.targets[i].targetId;
  88. break;
  89. }
  90. }
  91. }
  92. if (sel_id >= 0)
  93. {
  94. uint8_t atn_flag = SCSI_IN(ATN) ? SCSI_STS_SELECTION_ATN : 0;
  95. g_scsi_sts_selection = SCSI_STS_SELECTION_SUCCEEDED | atn_flag | sel_id;
  96. }
  97. // selFlag is required for Philips P2000C which releases it after 600ns
  98. // without waiting for BSY.
  99. // Also required for some early Mac Plus roms
  100. scsiDev.selFlag = *SCSI_STS_SELECTED;
  101. }
  102. }
  103. extern "C" bool scsiStatusSEL()
  104. {
  105. if (g_scsi_ctrl_bsy)
  106. {
  107. // We don't have direct register access to BSY bit like SCSI2SD scsi.c expects.
  108. // Instead update the state here.
  109. // Releasing happens with bus release.
  110. g_scsi_ctrl_bsy = 0;
  111. SCSI_OUT(BSY, 1);
  112. }
  113. return SCSI_IN(SEL);
  114. }
  115. /************************/
  116. /* SCSI bus reset logic */
  117. /************************/
  118. static void scsi_rst_assert_interrupt()
  119. {
  120. bool rst1 = SCSI_IN(RST);
  121. delay_ns(500);
  122. bool rst2 = SCSI_IN(RST);
  123. if (rst1 && rst2)
  124. {
  125. dbgmsg("BUS RESET");
  126. scsiDev.resetFlag = 1;
  127. }
  128. }
  129. static void selectPhyMode()
  130. {
  131. int oldmode = g_scsi_phy_mode;
  132. int default_mode = PHY_MODE_BEST_AVAILABLE;
  133. // Read overriding setting from configuration file
  134. int wanted_mode = g_scsi_settings.getSystem()->phyMode;
  135. // Default: software GPIO bitbang, available on all revisions
  136. g_scsi_phy_mode = PHY_MODE_PIO;
  137. // Timer based DMA bitbang, available on V1.1, 2.8 MB/s
  138. #ifdef SCSI_ACCEL_DMA_AVAILABLE
  139. if (wanted_mode == PHY_MODE_BEST_AVAILABLE || wanted_mode == PHY_MODE_DMA_TIMER)
  140. {
  141. g_scsi_phy_mode = PHY_MODE_DMA_TIMER;
  142. }
  143. #endif
  144. // GreenPAK with software write, available on V1.1 with extra chip, 3.5 MB/s
  145. if (wanted_mode == PHY_MODE_BEST_AVAILABLE || wanted_mode == PHY_MODE_GREENPAK_PIO)
  146. {
  147. if (greenpak_is_ready())
  148. {
  149. g_scsi_phy_mode = PHY_MODE_GREENPAK_PIO;
  150. }
  151. }
  152. // GreenPAK with DMA write, available on V1.1 with extra chip
  153. #ifdef SCSI_ACCEL_DMA_AVAILABLE
  154. if (wanted_mode == PHY_MODE_BEST_AVAILABLE || wanted_mode == PHY_MODE_GREENPAK_DMA)
  155. {
  156. if (greenpak_is_ready())
  157. {
  158. g_scsi_phy_mode = PHY_MODE_GREENPAK_DMA;
  159. }
  160. }
  161. #endif
  162. if (g_scsi_phy_mode != oldmode)
  163. {
  164. logmsg("SCSI PHY operating mode: ", g_scsi_phy_mode_names[g_scsi_phy_mode]);
  165. }
  166. }
  167. extern "C" void scsiPhyReset(void)
  168. {
  169. SCSI_RELEASE_OUTPUTS();
  170. scsi_accel_dma_stopWrite();
  171. g_scsi_sts_selection = 0;
  172. g_scsi_ctrl_bsy = 0;
  173. g_scsi_writereq.count = 0;
  174. init_irqs();
  175. #ifdef SCSI_SYNC_MODE_AVAILABLE
  176. scsi_accel_sync_init();
  177. #endif
  178. selectPhyMode();
  179. if (g_scsi_phy_mode == PHY_MODE_DMA_TIMER)
  180. {
  181. scsi_accel_timer_dma_init();
  182. }
  183. else if (g_scsi_phy_mode == PHY_MODE_GREENPAK_DMA)
  184. {
  185. scsi_accel_greenpak_dma_init();
  186. }
  187. }
  188. /************************/
  189. /* SCSI bus phase logic */
  190. /************************/
  191. static SCSI_PHASE g_scsi_phase;
  192. extern "C" void scsiEnterPhase(int phase)
  193. {
  194. int delay = scsiEnterPhaseImmediate(phase);
  195. if (delay > 0)
  196. {
  197. s2s_delay_ns(delay);
  198. }
  199. }
  200. // Change state and return nanosecond delay to wait
  201. extern "C" uint32_t scsiEnterPhaseImmediate(int phase)
  202. {
  203. if (phase != g_scsi_phase)
  204. {
  205. // ANSI INCITS 362-2002 SPI-3 10.7.1:
  206. // Phase changes are not allowed while REQ or ACK is asserted.
  207. while (likely(!scsiDev.resetFlag) && SCSI_IN(ACK)) {}
  208. if (scsiDev.compatMode < COMPAT_SCSI2 && (phase == DATA_IN || phase == DATA_OUT))
  209. {
  210. // Akai S1000/S3000 seems to need extra delay before changing to data phase
  211. // after a command. The code in ZuluSCSI_disk.cpp tries to do this while waiting
  212. // for SD card, to avoid any extra latency.
  213. s2s_delay_ns(400000);
  214. }
  215. int oldphase = g_scsi_phase;
  216. g_scsi_phase = (SCSI_PHASE)phase;
  217. scsiLogPhaseChange(phase);
  218. if (phase < 0)
  219. {
  220. // Other communication on bus or reset state
  221. SCSI_RELEASE_OUTPUTS();
  222. return 0;
  223. }
  224. else
  225. {
  226. SCSI_OUT(MSG, phase & __scsiphase_msg);
  227. SCSI_OUT(CD, phase & __scsiphase_cd);
  228. SCSI_OUT(IO, phase & __scsiphase_io);
  229. int delayNs = 400; // Bus settle delay
  230. if ((oldphase & __scsiphase_io) != (phase & __scsiphase_io))
  231. {
  232. delayNs += 400; // Data release delay
  233. }
  234. if (scsiDev.compatMode < COMPAT_SCSI2)
  235. {
  236. // EMU EMAX needs 100uS ! 10uS is not enough.
  237. delayNs += 100000;
  238. }
  239. return delayNs;
  240. }
  241. }
  242. else
  243. {
  244. return 0;
  245. }
  246. }
  247. // Release all signals
  248. void scsiEnterBusFree(void)
  249. {
  250. g_scsi_phase = BUS_FREE;
  251. g_scsi_sts_selection = 0;
  252. g_scsi_ctrl_bsy = 0;
  253. scsiDev.cdbLen = 0;
  254. SCSI_RELEASE_OUTPUTS();
  255. }
  256. /********************/
  257. /* Transmit to host */
  258. /********************/
  259. #define SCSI_WAIT_ACTIVE(pin) \
  260. if (!SCSI_IN(pin)) { \
  261. if (!SCSI_IN(pin)) { \
  262. while(!SCSI_IN(pin) && !scsiDev.resetFlag); \
  263. } \
  264. }
  265. #define SCSI_WAIT_INACTIVE(pin) \
  266. if (SCSI_IN(pin)) { \
  267. if (SCSI_IN(pin)) { \
  268. while(SCSI_IN(pin) && !scsiDev.resetFlag); \
  269. } \
  270. }
  271. static inline void scsiWriteOneByte(uint8_t value)
  272. {
  273. SCSI_OUT_DATA(value);
  274. delay_100ns(); // DB setup time before REQ
  275. SCSI_OUT(REQ, 1);
  276. SCSI_WAIT_ACTIVE(ACK);
  277. SCSI_RELEASE_DATA_REQ(); // Release data and REQ
  278. SCSI_WAIT_INACTIVE(ACK);
  279. }
  280. extern "C" void scsiWriteByte(uint8_t value)
  281. {
  282. scsiLogDataIn(&value, 1);
  283. scsiWriteOneByte(value);
  284. }
  285. extern "C" void scsiWrite(const uint8_t* data, uint32_t count)
  286. {
  287. scsiStartWrite(data, count);
  288. scsiFinishWrite();
  289. }
  290. extern "C" void scsiStartWrite(const uint8_t* data, uint32_t count)
  291. {
  292. scsiLogDataIn(data, count);
  293. g_scsi_writereq.use_sync_mode = (g_scsi_phase == DATA_IN && scsiDev.target->syncOffset > 0);
  294. if (g_scsi_phy_mode == PHY_MODE_PIO
  295. || g_scsi_phy_mode == PHY_MODE_GREENPAK_PIO
  296. || g_scsi_writereq.use_sync_mode)
  297. {
  298. // Software based bit-banging.
  299. // Write requests are queued and then executed in isWriteFinished() callback.
  300. // This allows better parallelism with SD card transfers.
  301. if (g_scsi_writereq.count)
  302. {
  303. if (data == g_scsi_writereq.data + g_scsi_writereq.count)
  304. {
  305. // Combine with previous one
  306. g_scsi_writereq.count += count;
  307. return;
  308. }
  309. else
  310. {
  311. // Actually execute previous request
  312. scsiFinishWrite();
  313. }
  314. }
  315. g_scsi_writereq.data = data;
  316. g_scsi_writereq.count = count;
  317. }
  318. else if (g_scsi_phy_mode == PHY_MODE_DMA_TIMER || g_scsi_phy_mode == PHY_MODE_GREENPAK_DMA)
  319. {
  320. // Accelerated writes using DMA and timers
  321. scsi_accel_dma_startWrite(data, count, &scsiDev.resetFlag);
  322. }
  323. else
  324. {
  325. logmsg("Unknown SCSI PHY mode: ", (int)g_scsi_phy_mode);
  326. }
  327. }
  328. static void processPollingWrite(uint32_t count)
  329. {
  330. if (count > g_scsi_writereq.count)
  331. count = g_scsi_writereq.count;
  332. const uint8_t *data = g_scsi_writereq.data;
  333. uint32_t count_words = count / 4;
  334. if (g_scsi_writereq.use_sync_mode)
  335. {
  336. // Synchronous mode transfer
  337. scsi_accel_sync_send(data, count, &scsiDev.resetFlag);
  338. }
  339. else if (count_words * 4 == count)
  340. {
  341. if (g_scsi_phy_mode == PHY_MODE_GREENPAK_PIO)
  342. {
  343. // GreenPAK PIO accelerated asynchronous transfer
  344. scsi_accel_greenpak_send((const uint32_t*)data, count_words, &scsiDev.resetFlag);
  345. }
  346. else
  347. {
  348. // Assembler optimized asynchronous transfer
  349. scsi_accel_asm_send((const uint32_t*)data, count_words, &scsiDev.resetFlag);
  350. }
  351. }
  352. else
  353. {
  354. // Use simple loop for unaligned transfers
  355. for (uint32_t i = 0; i < count; i++)
  356. {
  357. if (scsiDev.resetFlag) break;
  358. scsiWriteOneByte(data[i]);
  359. }
  360. }
  361. g_scsi_writereq.count -= count;
  362. if (g_scsi_writereq.count)
  363. {
  364. g_scsi_writereq.data += count;
  365. }
  366. else
  367. {
  368. g_scsi_writereq.data = NULL;
  369. }
  370. }
  371. static bool isPollingWriteFinished(const uint8_t *data)
  372. {
  373. if (g_scsi_writereq.count)
  374. {
  375. if (data == NULL)
  376. {
  377. return false;
  378. }
  379. else if (data >= g_scsi_writereq.data &&
  380. data < g_scsi_writereq.data + g_scsi_writereq.count)
  381. {
  382. return false;
  383. }
  384. }
  385. return true;
  386. }
  387. extern "C" bool scsiIsWriteFinished(const uint8_t *data)
  388. {
  389. // Check if there is still a polling transfer in progress
  390. if (!isPollingWriteFinished(data) && !check_sd_read_done())
  391. {
  392. // Process the transfer piece-by-piece while waiting
  393. // for SD card to react.
  394. int max_count = g_scsi_writereq.count / 8;
  395. // Always transfer whole sectors without pause to avoid problems with some SCSI hosts.
  396. int bytesPerSector = 512;
  397. if (scsiDev.target)
  398. {
  399. bytesPerSector = scsiDev.target->liveCfg.bytesPerSector;
  400. }
  401. if (max_count % bytesPerSector != 0) max_count -= (max_count % bytesPerSector);
  402. if (max_count < bytesPerSector) max_count = bytesPerSector;
  403. // Avoid SysTick interrupt pauses during the transfer
  404. SysTick_Handle_PreEmptively();
  405. processPollingWrite(max_count);
  406. return isPollingWriteFinished(data);
  407. }
  408. if (g_scsi_phy_mode == PHY_MODE_DMA_TIMER || g_scsi_phy_mode == PHY_MODE_GREENPAK_DMA)
  409. {
  410. return scsi_accel_dma_isWriteFinished(data);
  411. }
  412. else
  413. {
  414. return true;
  415. }
  416. }
  417. extern "C" void scsiFinishWrite()
  418. {
  419. if (g_scsi_writereq.count)
  420. {
  421. // Finish previously started polling write request.
  422. processPollingWrite(g_scsi_writereq.count);
  423. }
  424. if (g_scsi_phy_mode == PHY_MODE_DMA_TIMER || g_scsi_phy_mode == PHY_MODE_GREENPAK_DMA)
  425. {
  426. scsi_accel_dma_finishWrite(&scsiDev.resetFlag);
  427. }
  428. }
  429. /*********************/
  430. /* Receive from host */
  431. /*********************/
  432. static inline uint8_t scsiReadOneByte(void)
  433. {
  434. SCSI_OUT(REQ, 1);
  435. SCSI_WAIT_ACTIVE(ACK);
  436. delay_100ns();
  437. uint8_t r = SCSI_IN_DATA();
  438. SCSI_OUT(REQ, 0);
  439. SCSI_WAIT_INACTIVE(ACK);
  440. return r;
  441. }
  442. extern "C" uint8_t scsiReadByte(void)
  443. {
  444. uint8_t r = scsiReadOneByte();
  445. scsiLogDataOut(&r, 1);
  446. return r;
  447. }
  448. extern "C" void scsiRead(uint8_t* data, uint32_t count, int* parityError)
  449. {
  450. *parityError = 0;
  451. uint32_t count_words = count / 4;
  452. bool use_greenpak = (g_scsi_phy_mode == PHY_MODE_GREENPAK_DMA || g_scsi_phy_mode == PHY_MODE_GREENPAK_PIO);
  453. SysTick_Handle_PreEmptively();
  454. if (g_scsi_phase == DATA_OUT && scsiDev.target->syncOffset > 0)
  455. {
  456. // Synchronous data transfer
  457. scsi_accel_sync_recv(data, count, parityError, &scsiDev.resetFlag);
  458. }
  459. else if (count_words * 4 == count && count_words >= 2 && use_greenpak)
  460. {
  461. // GreenPAK accelerated receive can handle a multiple of 4 bytes with minimum of 8 bytes.
  462. scsi_accel_greenpak_recv((uint32_t*)data, count_words, &scsiDev.resetFlag);
  463. }
  464. else if (count_words * 4 == count && count_words >= 1)
  465. {
  466. // Optimized ASM subroutine can handle multiple of 4 bytes with minimum of 4 bytes.
  467. scsi_accel_asm_recv((uint32_t*)data, count_words, &scsiDev.resetFlag);
  468. }
  469. else
  470. {
  471. // Use a simple loop for short and unaligned transfers
  472. for (uint32_t i = 0; i < count; i++)
  473. {
  474. if (scsiDev.resetFlag) break;
  475. data[i] = scsiReadOneByte();
  476. }
  477. }
  478. scsiLogDataOut(data, count);
  479. }
  480. /**********************/
  481. /* Interrupt handlers */
  482. /**********************/
  483. extern "C"
  484. void SCSI_RST_IRQ (void)
  485. {
  486. if (exti_interrupt_flag_get(SCSI_RST_EXTI))
  487. {
  488. exti_interrupt_flag_clear(SCSI_RST_EXTI);
  489. scsi_rst_assert_interrupt();
  490. }
  491. if (exti_interrupt_flag_get(SCSI_BSY_EXTI))
  492. {
  493. exti_interrupt_flag_clear(SCSI_BSY_EXTI);
  494. scsi_bsy_deassert_interrupt();
  495. }
  496. if (exti_interrupt_flag_get(SCSI_SEL_EXTI))
  497. {
  498. // Check BSY line status when SEL goes active.
  499. // This is needed to handle SCSI-1 hosts that use the single initiator mode.
  500. // The host will just assert the SEL directly, without asserting BSY first.
  501. exti_interrupt_flag_clear(SCSI_SEL_EXTI);
  502. scsi_bsy_deassert_interrupt();
  503. }
  504. }
  505. #if SCSI_RST_IRQn != SCSI_BSY_IRQn
  506. extern "C"
  507. void SCSI_BSY_IRQ (void)
  508. {
  509. SCSI_RST_IRQ();
  510. }
  511. #endif
  512. #if (SCSI_SEL_IRQn != SCSI_RST_IRQn) && (SCSI_SEL_IRQn != SCSI_BSY_IRQn)
  513. extern "C"
  514. void SCSI_SEL_IRQ (void)
  515. {
  516. SCSI_RST_IRQ();
  517. }
  518. #endif
  519. static void init_irqs()
  520. {
  521. // Enable SYSCFG clock to set EXTI lines
  522. rcu_periph_clock_enable(RCU_SYSCFG);
  523. // Falling edge of RST pin
  524. gpio_mode_set(SCSI_RST_PORT, GPIO_MODE_INPUT, GPIO_PUPD_NONE, SCSI_RST_PIN);
  525. syscfg_exti_line_config(SCSI_RST_EXTI_SOURCE_PORT, SCSI_RST_EXTI_SOURCE_PIN);
  526. exti_init(SCSI_RST_EXTI, EXTI_INTERRUPT, EXTI_TRIG_FALLING);
  527. NVIC_SetPriority(SCSI_RST_IRQn, 1);
  528. NVIC_EnableIRQ(SCSI_RST_IRQn);
  529. // Rising edge of BSY pin
  530. // \todo unsure if this should be commented out
  531. // gpio_mode_set(SCSI_BSY_PORT, GPIO_MODE_INPUT, GPIO_PUPD_NONE, SCSI_BSY_PIN);
  532. syscfg_exti_line_config(SCSI_BSY_EXTI_SOURCE_PORT, SCSI_BSY_EXTI_SOURCE_PIN);
  533. exti_init(SCSI_BSY_EXTI, EXTI_INTERRUPT, EXTI_TRIG_RISING);
  534. NVIC_SetPriority(SCSI_BSY_IRQn, 1);
  535. NVIC_EnableIRQ(SCSI_BSY_IRQn);
  536. // Falling edge of SEL pin
  537. // \todo unsure if this should be commented out
  538. // gpio_mode_set(SCSI_SEL_PORT, GPIO_MODE_INPUT, GPIO_PUPD_NONE, SCSI_SEL_PIN);
  539. syscfg_exti_line_config(SCSI_SEL_EXTI_SOURCE_PORT, SCSI_SEL_EXTI_SOURCE_PIN);
  540. exti_init(SCSI_SEL_EXTI, EXTI_INTERRUPT, EXTI_TRIG_FALLING);
  541. NVIC_SetPriority(SCSI_SEL_IRQn, 1);
  542. NVIC_EnableIRQ(SCSI_SEL_IRQn);
  543. }