entry.S 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712
  1. /*
  2. * Contains the system-call and fault low-level handling routines.
  3. * This also contains the timer-interrupt handler, as well as all
  4. * interrupts and faults that can result in a task-switch.
  5. *
  6. * Copyright 2005-2009 Analog Devices Inc.
  7. *
  8. * Licensed under the GPL-2 or later.
  9. */
  10. /* NOTE: This code handles signal-recognition, which happens every time
  11. * after a timer-interrupt and after each system call.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/linkage.h>
  15. #include <linux/unistd.h>
  16. #include <asm/blackfin.h>
  17. #include <asm/errno.h>
  18. #include <asm/fixed_code.h>
  19. #include <asm/thread_info.h> /* TIF_NEED_RESCHED */
  20. #include <asm/asm-offsets.h>
  21. #include <asm/trace.h>
  22. #include <asm/traps.h>
  23. #include <asm/context.S>
  24. #ifdef CONFIG_EXCPT_IRQ_SYSC_L1
  25. .section .l1.text
  26. #else
  27. .text
  28. #endif
  29. /* Slightly simplified and streamlined entry point for CPLB misses.
  30. * This one does not lower the level to IRQ5, and thus can be used to
  31. * patch up CPLB misses on the kernel stack.
  32. */
  33. #if ANOMALY_05000261
  34. #define _ex_dviol _ex_workaround_261
  35. #define _ex_dmiss _ex_workaround_261
  36. #define _ex_dmult _ex_workaround_261
  37. ENTRY(_ex_workaround_261)
  38. /*
  39. * Work around an anomaly: if we see a new DCPLB fault, return
  40. * without doing anything. Then, if we get the same fault again,
  41. * handle it.
  42. */
  43. P4 = R7; /* Store EXCAUSE */
  44. GET_PDA(p5, r7);
  45. r7 = [p5 + PDA_LFRETX];
  46. r6 = retx;
  47. [p5 + PDA_LFRETX] = r6;
  48. cc = r6 == r7;
  49. if !cc jump _bfin_return_from_exception;
  50. /* fall through */
  51. R7 = P4;
  52. R6 = VEC_CPLB_M; /* Data CPLB Miss */
  53. cc = R6 == R7;
  54. if cc jump _ex_dcplb_miss (BP);
  55. #ifdef CONFIG_MPU
  56. R6 = VEC_CPLB_VL; /* Data CPLB Violation */
  57. cc = R6 == R7;
  58. if cc jump _ex_dcplb_viol (BP);
  59. #endif
  60. /* Handle Data CPLB Protection Violation
  61. * and Data CPLB Multiple Hits - Linux Trap Zero
  62. */
  63. jump _ex_trap_c;
  64. ENDPROC(_ex_workaround_261)
  65. #else
  66. #ifdef CONFIG_MPU
  67. #define _ex_dviol _ex_dcplb_viol
  68. #else
  69. #define _ex_dviol _ex_trap_c
  70. #endif
  71. #define _ex_dmiss _ex_dcplb_miss
  72. #define _ex_dmult _ex_trap_c
  73. #endif
  74. ENTRY(_ex_dcplb_viol)
  75. ENTRY(_ex_dcplb_miss)
  76. ENTRY(_ex_icplb_miss)
  77. (R7:6,P5:4) = [sp++];
  78. /* We leave the previously pushed ASTAT on the stack. */
  79. SAVE_CONTEXT_CPLB
  80. /* We must load R1 here, _before_ DEBUG_HWTRACE_SAVE, since that
  81. * will change the stack pointer. */
  82. R0 = SEQSTAT;
  83. R1 = SP;
  84. DEBUG_HWTRACE_SAVE(p5, r7)
  85. sp += -12;
  86. call _cplb_hdr;
  87. sp += 12;
  88. CC = R0 == 0;
  89. IF !CC JUMP _handle_bad_cplb;
  90. #ifdef CONFIG_DEBUG_DOUBLEFAULT
  91. /* While we were processing this, did we double fault? */
  92. r7 = SEQSTAT; /* reason code is in bit 5:0 */
  93. r6.l = lo(SEQSTAT_EXCAUSE);
  94. r6.h = hi(SEQSTAT_EXCAUSE);
  95. r7 = r7 & r6;
  96. r6 = 0x25;
  97. CC = R7 == R6;
  98. if CC JUMP _double_fault;
  99. #endif
  100. DEBUG_HWTRACE_RESTORE(p5, r7)
  101. RESTORE_CONTEXT_CPLB
  102. ASTAT = [SP++];
  103. SP = EX_SCRATCH_REG;
  104. rtx;
  105. ENDPROC(_ex_icplb_miss)
  106. ENTRY(_ex_syscall)
  107. raise 15; /* invoked by TRAP #0, for sys call */
  108. jump.s _bfin_return_from_exception;
  109. ENDPROC(_ex_syscall)
  110. ENTRY(_ex_single_step)
  111. /* If we just returned from an interrupt, the single step event is
  112. for the RTI instruction. */
  113. r7 = retx;
  114. r6 = reti;
  115. cc = r7 == r6;
  116. if cc jump _bfin_return_from_exception;
  117. #ifdef CONFIG_KGDB
  118. /* Don't do single step in hardware exception handler */
  119. p5.l = lo(IPEND);
  120. p5.h = hi(IPEND);
  121. r6 = [p5];
  122. cc = bittst(r6, 4);
  123. if cc jump _bfin_return_from_exception;
  124. cc = bittst(r6, 5);
  125. if cc jump _bfin_return_from_exception;
  126. /* skip single step if current interrupt priority is higher than
  127. * that of the first instruction, from which gdb starts single step */
  128. r6 >>= 6;
  129. r7 = 10;
  130. .Lfind_priority_start:
  131. cc = bittst(r6, 0);
  132. if cc jump .Lfind_priority_done;
  133. r6 >>= 1;
  134. r7 += -1;
  135. cc = r7 == 0;
  136. if cc jump .Lfind_priority_done;
  137. jump.s .Lfind_priority_start;
  138. .Lfind_priority_done:
  139. p4.l = _kgdb_single_step;
  140. p4.h = _kgdb_single_step;
  141. r6 = [p4];
  142. cc = r6 == 0;
  143. if cc jump .Ldo_single_step;
  144. r6 += -1;
  145. cc = r6 < r7;
  146. if cc jump 1f;
  147. .Ldo_single_step:
  148. #else
  149. /* If we were in user mode, do the single step normally. */
  150. p5.l = lo(IPEND);
  151. p5.h = hi(IPEND);
  152. r6 = [p5];
  153. r7 = 0xffe0 (z);
  154. r7 = r7 & r6;
  155. cc = r7 == 0;
  156. if !cc jump 1f;
  157. #endif
  158. #ifdef CONFIG_EXACT_HWERR
  159. /* Read the ILAT, and to check to see if the process we are
  160. * single stepping caused a previous hardware error
  161. * If so, do not single step, (which lowers to IRQ5, and makes
  162. * us miss the error).
  163. */
  164. p5.l = lo(ILAT);
  165. p5.h = hi(ILAT);
  166. r7 = [p5];
  167. cc = bittst(r7, EVT_IVHW_P);
  168. if cc jump 1f;
  169. #endif
  170. /* Single stepping only a single instruction, so clear the trace
  171. * bit here. */
  172. r7 = syscfg;
  173. bitclr (r7, SYSCFG_SSSTEP_P);
  174. syscfg = R7;
  175. jump _ex_trap_c;
  176. 1:
  177. /*
  178. * We were in an interrupt handler. By convention, all of them save
  179. * SYSCFG with their first instruction, so by checking whether our
  180. * RETX points at the entry point, we can determine whether to allow
  181. * a single step, or whether to clear SYSCFG.
  182. *
  183. * First, find out the interrupt level and the event vector for it.
  184. */
  185. p5.l = lo(EVT0);
  186. p5.h = hi(EVT0);
  187. p5 += -4;
  188. 2:
  189. r7 = rot r7 by -1;
  190. p5 += 4;
  191. if !cc jump 2b;
  192. /* What we actually do is test for the _second_ instruction in the
  193. * IRQ handler. That way, if there are insns following the restore
  194. * of SYSCFG after leaving the handler, we will not turn off SYSCFG
  195. * for them. */
  196. r7 = [p5];
  197. r7 += 2;
  198. r6 = RETX;
  199. cc = R7 == R6;
  200. if !cc jump _bfin_return_from_exception;
  201. r7 = syscfg;
  202. bitclr (r7, SYSCFG_SSSTEP_P); /* Turn off single step */
  203. syscfg = R7;
  204. /* Fall through to _bfin_return_from_exception. */
  205. ENDPROC(_ex_single_step)
  206. ENTRY(_bfin_return_from_exception)
  207. #if ANOMALY_05000257
  208. R7=LC0;
  209. LC0=R7;
  210. R7=LC1;
  211. LC1=R7;
  212. #endif
  213. #ifdef CONFIG_DEBUG_DOUBLEFAULT
  214. /* While we were processing the current exception,
  215. * did we cause another, and double fault?
  216. */
  217. r7 = SEQSTAT; /* reason code is in bit 5:0 */
  218. r6.l = lo(SEQSTAT_EXCAUSE);
  219. r6.h = hi(SEQSTAT_EXCAUSE);
  220. r7 = r7 & r6;
  221. r6 = VEC_UNCOV;
  222. CC = R7 == R6;
  223. if CC JUMP _double_fault;
  224. #endif
  225. (R7:6,P5:4) = [sp++];
  226. ASTAT = [sp++];
  227. sp = EX_SCRATCH_REG;
  228. rtx;
  229. ENDPROC(_bfin_return_from_exception)
  230. ENTRY(_handle_bad_cplb)
  231. DEBUG_HWTRACE_RESTORE(p5, r7)
  232. /* To get here, we just tried and failed to change a CPLB
  233. * so, handle things in trap_c (C code), by lowering to
  234. * IRQ5, just like we normally do. Since this is not a
  235. * "normal" return path, we have a do a lot of stuff to
  236. * the stack to get ready so, we can fall through - we
  237. * need to make a CPLB exception look like a normal exception
  238. */
  239. RESTORE_CONTEXT_CPLB
  240. /* ASTAT is still on the stack, where it is needed. */
  241. [--sp] = (R7:6,P5:4);
  242. ENTRY(_ex_replaceable)
  243. nop;
  244. ENTRY(_ex_trap_c)
  245. /* The only thing that has been saved in this context is
  246. * (R7:6,P5:4), ASTAT & SP - don't use anything else
  247. */
  248. GET_PDA(p5, r6);
  249. /* Make sure we are not in a double fault */
  250. p4.l = lo(IPEND);
  251. p4.h = hi(IPEND);
  252. r7 = [p4];
  253. CC = BITTST (r7, 5);
  254. if CC jump _double_fault;
  255. [p5 + PDA_EXIPEND] = r7;
  256. /* Call C code (trap_c) to handle the exception, which most
  257. * likely involves sending a signal to the current process.
  258. * To avoid double faults, lower our priority to IRQ5 first.
  259. */
  260. r7.h = _exception_to_level5;
  261. r7.l = _exception_to_level5;
  262. p4.l = lo(EVT5);
  263. p4.h = hi(EVT5);
  264. [p4] = r7;
  265. csync;
  266. /*
  267. * Save these registers, as they are only valid in exception context
  268. * (where we are now - as soon as we defer to IRQ5, they can change)
  269. * DCPLB_STATUS and ICPLB_STATUS are also only valid in EVT3,
  270. * but they are not very interesting, so don't save them
  271. */
  272. p4.l = lo(DCPLB_FAULT_ADDR);
  273. p4.h = hi(DCPLB_FAULT_ADDR);
  274. r7 = [p4];
  275. [p5 + PDA_DCPLB] = r7;
  276. p4.l = lo(ICPLB_FAULT_ADDR);
  277. p4.h = hi(ICPLB_FAULT_ADDR);
  278. r6 = [p4];
  279. [p5 + PDA_ICPLB] = r6;
  280. r6 = retx;
  281. [p5 + PDA_RETX] = r6;
  282. r6 = SEQSTAT;
  283. [p5 + PDA_SEQSTAT] = r6;
  284. /* Save the state of single stepping */
  285. r6 = SYSCFG;
  286. [p5 + PDA_SYSCFG] = r6;
  287. /* Clear it while we handle the exception in IRQ5 mode */
  288. BITCLR(r6, SYSCFG_SSSTEP_P);
  289. SYSCFG = r6;
  290. /* Save the current IMASK, since we change in order to jump to level 5 */
  291. cli r6;
  292. [p5 + PDA_EXIMASK] = r6;
  293. p4.l = lo(SAFE_USER_INSTRUCTION);
  294. p4.h = hi(SAFE_USER_INSTRUCTION);
  295. retx = p4;
  296. /* Disable all interrupts, but make sure level 5 is enabled so
  297. * we can switch to that level.
  298. */
  299. r6 = 0x3f;
  300. sti r6;
  301. /* In case interrupts are disabled IPEND[4] (global interrupt disable bit)
  302. * clear it (re-enabling interrupts again) by the special sequence of pushing
  303. * RETI onto the stack. This way we can lower ourselves to IVG5 even if the
  304. * exception was taken after the interrupt handler was called but before it
  305. * got a chance to enable global interrupts itself.
  306. */
  307. [--sp] = reti;
  308. sp += 4;
  309. raise 5;
  310. jump.s _bfin_return_from_exception;
  311. ENDPROC(_ex_trap_c)
  312. /* We just realized we got an exception, while we were processing a different
  313. * exception. This is a unrecoverable event, so crash.
  314. * Note: this cannot be ENTRY() as we jump here with "if cc jump" ...
  315. */
  316. ENTRY(_double_fault)
  317. /* Turn caches & protection off, to ensure we don't get any more
  318. * double exceptions
  319. */
  320. P4.L = LO(IMEM_CONTROL);
  321. P4.H = HI(IMEM_CONTROL);
  322. R5 = [P4]; /* Control Register*/
  323. BITCLR(R5,ENICPLB_P);
  324. CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
  325. [P4] = R5;
  326. SSYNC;
  327. P4.L = LO(DMEM_CONTROL);
  328. P4.H = HI(DMEM_CONTROL);
  329. R5 = [P4];
  330. BITCLR(R5,ENDCPLB_P);
  331. CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
  332. [P4] = R5;
  333. SSYNC;
  334. /* Fix up the stack */
  335. (R7:6,P5:4) = [sp++];
  336. ASTAT = [sp++];
  337. SP = EX_SCRATCH_REG;
  338. /* We should be out of the exception stack, and back down into
  339. * kernel or user space stack
  340. */
  341. SAVE_ALL_SYS
  342. /* The dumping functions expect the return address in the RETI
  343. * slot. */
  344. r6 = retx;
  345. [sp + PT_PC] = r6;
  346. r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
  347. SP += -12;
  348. pseudo_long_call _double_fault_c, p5;
  349. SP += 12;
  350. .L_double_fault_panic:
  351. JUMP .L_double_fault_panic
  352. ENDPROC(_double_fault)
  353. ENTRY(_exception_to_level5)
  354. SAVE_ALL_SYS
  355. GET_PDA(p5, r7); /* Fetch current PDA */
  356. r6 = [p5 + PDA_RETX];
  357. [sp + PT_PC] = r6;
  358. r6 = [p5 + PDA_SYSCFG];
  359. [sp + PT_SYSCFG] = r6;
  360. r6 = [p5 + PDA_SEQSTAT]; /* Read back seqstat */
  361. [sp + PT_SEQSTAT] = r6;
  362. /* Restore the hardware error vector. */
  363. r7.h = _evt_ivhw;
  364. r7.l = _evt_ivhw;
  365. p4.l = lo(EVT5);
  366. p4.h = hi(EVT5);
  367. [p4] = r7;
  368. csync;
  369. #ifdef CONFIG_DEBUG_DOUBLEFAULT
  370. /* Now that we have the hardware error vector programmed properly
  371. * we can re-enable interrupts (IPEND[4]), so if the _trap_c causes
  372. * another hardware error, we can catch it (self-nesting).
  373. */
  374. [--sp] = reti;
  375. sp += 4;
  376. #endif
  377. r7 = [p5 + PDA_EXIPEND] /* Read the IPEND from the Exception state */
  378. [sp + PT_IPEND] = r7; /* Store IPEND onto the stack */
  379. r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
  380. SP += -12;
  381. pseudo_long_call _trap_c, p4;
  382. SP += 12;
  383. /* If interrupts were off during the exception (IPEND[4] = 1), turn them off
  384. * before we return.
  385. */
  386. CC = BITTST(r7, EVT_IRPTEN_P)
  387. if !CC jump 1f;
  388. /* this will load a random value into the reti register - but that is OK,
  389. * since we do restore it to the correct value in the 'RESTORE_ALL_SYS' macro
  390. */
  391. sp += -4;
  392. reti = [sp++];
  393. 1:
  394. /* restore the interrupt mask (IMASK) */
  395. r6 = [p5 + PDA_EXIMASK];
  396. sti r6;
  397. call _ret_from_exception;
  398. RESTORE_ALL_SYS
  399. rti;
  400. ENDPROC(_exception_to_level5)
  401. ENTRY(_trap) /* Exception: 4th entry into system event table(supervisor mode)*/
  402. /* Since the kernel stack can be anywhere, it's not guaranteed to be
  403. * covered by a CPLB. Switch to an exception stack; use RETN as a
  404. * scratch register (for want of a better option).
  405. */
  406. EX_SCRATCH_REG = sp;
  407. GET_PDA_SAFE(sp);
  408. sp = [sp + PDA_EXSTACK];
  409. /* Try to deal with syscalls quickly. */
  410. [--sp] = ASTAT;
  411. [--sp] = (R7:6,P5:4);
  412. ANOMALY_283_315_WORKAROUND(p5, r7)
  413. #ifdef CONFIG_EXACT_HWERR
  414. /* Make sure all pending read/writes complete. This will ensure any
  415. * accesses which could cause hardware errors completes, and signal
  416. * the the hardware before we do something silly, like crash the
  417. * kernel. We don't need to work around anomaly 05000312, since
  418. * we are already atomic
  419. */
  420. ssync;
  421. #endif
  422. #ifdef CONFIG_DEBUG_DOUBLEFAULT
  423. /*
  424. * Save these registers, as they are only valid in exception context
  425. * (where we are now - as soon as we defer to IRQ5, they can change)
  426. * DCPLB_STATUS and ICPLB_STATUS are also only valid in EVT3,
  427. * but they are not very interesting, so don't save them
  428. */
  429. GET_PDA(p5, r7);
  430. p4.l = lo(DCPLB_FAULT_ADDR);
  431. p4.h = hi(DCPLB_FAULT_ADDR);
  432. r7 = [p4];
  433. [p5 + PDA_DF_DCPLB] = r7;
  434. p4.l = lo(ICPLB_FAULT_ADDR);
  435. p4.h = hi(ICPLB_FAULT_ADDR);
  436. r7 = [p4];
  437. [p5 + PDA_DF_ICPLB] = r7;
  438. r7 = retx;
  439. [p5 + PDA_DF_RETX] = r7;
  440. r7 = SEQSTAT; /* reason code is in bit 5:0 */
  441. [p5 + PDA_DF_SEQSTAT] = r7;
  442. #else
  443. r7 = SEQSTAT; /* reason code is in bit 5:0 */
  444. #endif
  445. r6.l = lo(SEQSTAT_EXCAUSE);
  446. r6.h = hi(SEQSTAT_EXCAUSE);
  447. r7 = r7 & r6;
  448. p5.h = _ex_table;
  449. p5.l = _ex_table;
  450. p4 = r7;
  451. p5 = p5 + (p4 << 2);
  452. p4 = [p5];
  453. jump (p4);
  454. .Lbadsys:
  455. r7 = -ENOSYS; /* signextending enough */
  456. [sp + PT_R0] = r7; /* return value from system call */
  457. jump .Lsyscall_really_exit;
  458. ENDPROC(_trap)
  459. ENTRY(_system_call)
  460. /* Store IPEND */
  461. p2.l = lo(IPEND);
  462. p2.h = hi(IPEND);
  463. csync;
  464. r0 = [p2];
  465. [sp + PT_IPEND] = r0;
  466. /* Store RETS for now */
  467. r0 = rets;
  468. [sp + PT_RESERVED] = r0;
  469. /* Set the stack for the current process */
  470. r7 = sp;
  471. r6.l = lo(ALIGN_PAGE_MASK);
  472. r6.h = hi(ALIGN_PAGE_MASK);
  473. r7 = r7 & r6; /* thread_info */
  474. p2 = r7;
  475. p2 = [p2];
  476. [p2+(TASK_THREAD+THREAD_KSP)] = sp;
  477. #ifdef CONFIG_IPIPE
  478. r0 = sp;
  479. SP += -12;
  480. pseudo_long_call ___ipipe_syscall_root, p0;
  481. SP += 12;
  482. cc = r0 == 1;
  483. if cc jump .Lsyscall_really_exit;
  484. cc = r0 == -1;
  485. if cc jump .Lresume_userspace;
  486. r3 = [sp + PT_R3];
  487. r4 = [sp + PT_R4];
  488. p0 = [sp + PT_ORIG_P0];
  489. #endif /* CONFIG_IPIPE */
  490. /* are we tracing syscalls?*/
  491. r7 = sp;
  492. r6.l = lo(ALIGN_PAGE_MASK);
  493. r6.h = hi(ALIGN_PAGE_MASK);
  494. r7 = r7 & r6;
  495. p2 = r7;
  496. r7 = [p2+TI_FLAGS];
  497. CC = BITTST(r7,TIF_SYSCALL_TRACE);
  498. if CC JUMP _sys_trace;
  499. CC = BITTST(r7,TIF_SINGLESTEP);
  500. if CC JUMP _sys_trace;
  501. /* Make sure the system call # is valid */
  502. p4 = __NR_syscall;
  503. /* System call number is passed in P0 */
  504. cc = p4 <= p0;
  505. if cc jump .Lbadsys;
  506. /* Execute the appropriate system call */
  507. p4 = p0;
  508. p5.l = _sys_call_table;
  509. p5.h = _sys_call_table;
  510. p5 = p5 + (p4 << 2);
  511. r0 = [sp + PT_R0];
  512. r1 = [sp + PT_R1];
  513. r2 = [sp + PT_R2];
  514. p5 = [p5];
  515. [--sp] = r5;
  516. [--sp] = r4;
  517. [--sp] = r3;
  518. SP += -12;
  519. call (p5);
  520. SP += 24;
  521. [sp + PT_R0] = r0;
  522. .Lresume_userspace:
  523. r7 = sp;
  524. r4.l = lo(ALIGN_PAGE_MASK);
  525. r4.h = hi(ALIGN_PAGE_MASK);
  526. r7 = r7 & r4; /* thread_info->flags */
  527. p5 = r7;
  528. .Lresume_userspace_1:
  529. /* Disable interrupts. */
  530. [--sp] = reti;
  531. reti = [sp++];
  532. r7 = [p5 + TI_FLAGS];
  533. r4.l = lo(_TIF_WORK_MASK);
  534. r4.h = hi(_TIF_WORK_MASK);
  535. r7 = r7 & r4;
  536. .Lsyscall_resched:
  537. #ifdef CONFIG_IPIPE
  538. cc = BITTST(r7, TIF_IRQ_SYNC);
  539. if !cc jump .Lsyscall_no_irqsync;
  540. /*
  541. * Clear IPEND[4] manually to undo what resume_userspace_1 just did;
  542. * we need this so that high priority domain interrupts may still
  543. * preempt the current domain while the pipeline log is being played
  544. * back.
  545. */
  546. [--sp] = reti;
  547. SP += 4; /* don't merge with next insn to keep the pattern obvious */
  548. SP += -12;
  549. pseudo_long_call ___ipipe_sync_root, p4;
  550. SP += 12;
  551. jump .Lresume_userspace_1;
  552. .Lsyscall_no_irqsync:
  553. #endif
  554. cc = BITTST(r7, TIF_NEED_RESCHED);
  555. if !cc jump .Lsyscall_sigpending;
  556. /* Reenable interrupts. */
  557. [--sp] = reti;
  558. sp += 4;
  559. SP += -12;
  560. pseudo_long_call _schedule, p4;
  561. SP += 12;
  562. jump .Lresume_userspace_1;
  563. .Lsyscall_sigpending:
  564. cc = BITTST(r7, TIF_SIGPENDING);
  565. if cc jump .Lsyscall_do_signals;
  566. cc = BITTST(r7, TIF_NOTIFY_RESUME);
  567. if !cc jump .Lsyscall_really_exit;
  568. .Lsyscall_do_signals:
  569. /* Reenable interrupts. */
  570. [--sp] = reti;
  571. sp += 4;
  572. r0 = sp;
  573. SP += -12;
  574. pseudo_long_call _do_notify_resume, p5;
  575. SP += 12;
  576. .Lsyscall_really_exit:
  577. r5 = [sp + PT_RESERVED];
  578. rets = r5;
  579. rts;
  580. ENDPROC(_system_call)
  581. /* Do not mark as ENTRY() to avoid error in assembler ...
  582. * this symbol need not be global anyways, so ...
  583. */
  584. _sys_trace:
  585. r0 = sp;
  586. pseudo_long_call _syscall_trace_enter, p5;
  587. /* Make sure the system call # is valid */
  588. p4 = [SP + PT_P0];
  589. p3 = __NR_syscall;
  590. cc = p3 <= p4;
  591. r0 = -ENOSYS;
  592. if cc jump .Lsys_trace_badsys;
  593. /* Execute the appropriate system call */
  594. p5.l = _sys_call_table;
  595. p5.h = _sys_call_table;
  596. p5 = p5 + (p4 << 2);
  597. r0 = [sp + PT_R0];
  598. r1 = [sp + PT_R1];
  599. r2 = [sp + PT_R2];
  600. r3 = [sp + PT_R3];
  601. r4 = [sp + PT_R4];
  602. r5 = [sp + PT_R5];
  603. p5 = [p5];
  604. [--sp] = r5;
  605. [--sp] = r4;
  606. [--sp] = r3;
  607. SP += -12;
  608. call (p5);
  609. SP += 24;
  610. .Lsys_trace_badsys:
  611. [sp + PT_R0] = r0;
  612. r0 = sp;
  613. pseudo_long_call _syscall_trace_leave, p5;
  614. jump .Lresume_userspace;
  615. ENDPROC(_sys_trace)
  616. ENTRY(_resume)
  617. /*
  618. * Beware - when entering resume, prev (the current task) is
  619. * in r0, next (the new task) is in r1.
  620. */
  621. p0 = r0;
  622. p1 = r1;
  623. [--sp] = rets;
  624. [--sp] = fp;
  625. [--sp] = (r7:4, p5:3);
  626. /* save usp */
  627. p2 = usp;
  628. [p0+(TASK_THREAD+THREAD_USP)] = p2;
  629. /* save current kernel stack pointer */
  630. [p0+(TASK_THREAD+THREAD_KSP)] = sp;
  631. /* save program counter */
  632. r1.l = _new_old_task;
  633. r1.h = _new_old_task;
  634. [p0+(TASK_THREAD+THREAD_PC)] = r1;
  635. /* restore the kernel stack pointer */
  636. sp = [p1+(TASK_THREAD+THREAD_KSP)];
  637. /* restore user stack pointer */
  638. p0 = [p1+(TASK_THREAD+THREAD_USP)];
  639. usp = p0;
  640. /* restore pc */
  641. p0 = [p1+(TASK_THREAD+THREAD_PC)];
  642. jump (p0);
  643. /*
  644. * Following code actually lands up in a new (old) task.
  645. */
  646. _new_old_task:
  647. (r7:4, p5:3) = [sp++];
  648. fp = [sp++];
  649. rets = [sp++];
  650. /*
  651. * When we come out of resume, r0 carries "old" task, because we are
  652. * in "new" task.
  653. */
  654. rts;
  655. ENDPROC(_resume)
  656. ENTRY(_ret_from_exception)
  657. #ifdef CONFIG_IPIPE
  658. p2.l = _ipipe_percpu_domain;
  659. p2.h = _ipipe_percpu_domain;
  660. r0.l = _ipipe_root;
  661. r0.h = _ipipe_root;
  662. r2 = [p2];
  663. cc = r0 == r2;
  664. if !cc jump 4f; /* not on behalf of the root domain, get out */
  665. #endif /* CONFIG_IPIPE */
  666. p2.l = lo(IPEND);
  667. p2.h = hi(IPEND);
  668. csync;
  669. r0 = [p2];
  670. [sp + PT_IPEND] = r0;
  671. 1:
  672. r2 = LO(~0x37) (Z);
  673. r0 = r2 & r0;
  674. cc = r0 == 0;
  675. if !cc jump 4f; /* if not return to user mode, get out */
  676. /* Make sure any pending system call or deferred exception
  677. * return in ILAT for this process to get executed, otherwise
  678. * in case context switch happens, system call of
  679. * first process (i.e in ILAT) will be carried
  680. * forward to the switched process
  681. */
  682. p2.l = lo(ILAT);
  683. p2.h = hi(ILAT);
  684. r0 = [p2];
  685. r1 = (EVT_IVG14 | EVT_IVG15) (z);
  686. r0 = r0 & r1;
  687. cc = r0 == 0;
  688. if !cc jump 5f;
  689. /* Set the stack for the current process */
  690. r7 = sp;
  691. r4.l = lo(ALIGN_PAGE_MASK);
  692. r4.h = hi(ALIGN_PAGE_MASK);
  693. r7 = r7 & r4; /* thread_info->flags */
  694. p5 = r7;
  695. r7 = [p5 + TI_FLAGS];
  696. r4.l = lo(_TIF_WORK_MASK);
  697. r4.h = hi(_TIF_WORK_MASK);
  698. r7 = r7 & r4;
  699. cc = r7 == 0;
  700. if cc jump 4f;
  701. p0.l = lo(EVT15);
  702. p0.h = hi(EVT15);
  703. p1.l = _schedule_and_signal;
  704. p1.h = _schedule_and_signal;
  705. [p0] = p1;
  706. csync;
  707. raise 15; /* raise evt15 to do signal or reschedule */
  708. 4:
  709. r0 = syscfg;
  710. bitclr(r0, SYSCFG_SSSTEP_P); /* Turn off single step */
  711. syscfg = r0;
  712. 5:
  713. rts;
  714. ENDPROC(_ret_from_exception)
  715. #if defined(CONFIG_PREEMPT)
  716. ENTRY(_up_to_irq14)
  717. #if ANOMALY_05000281 || ANOMALY_05000461
  718. r0.l = lo(SAFE_USER_INSTRUCTION);
  719. r0.h = hi(SAFE_USER_INSTRUCTION);
  720. reti = r0;
  721. #endif
  722. #ifdef CONFIG_DEBUG_HWERR
  723. /* enable irq14 & hwerr interrupt, until we transition to _evt_evt14 */
  724. r0 = (EVT_IVG14 | EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
  725. #else
  726. /* Only enable irq14 interrupt, until we transition to _evt_evt14 */
  727. r0 = (EVT_IVG14 | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
  728. #endif
  729. sti r0;
  730. p0.l = lo(EVT14);
  731. p0.h = hi(EVT14);
  732. p1.l = _evt_up_evt14;
  733. p1.h = _evt_up_evt14;
  734. [p0] = p1;
  735. csync;
  736. raise 14;
  737. 1:
  738. jump 1b;
  739. ENDPROC(_up_to_irq14)
  740. ENTRY(_evt_up_evt14)
  741. #ifdef CONFIG_DEBUG_HWERR
  742. r0 = (EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
  743. sti r0;
  744. #else
  745. cli r0;
  746. #endif
  747. #ifdef CONFIG_TRACE_IRQFLAGS
  748. [--sp] = rets;
  749. sp += -12;
  750. call _trace_hardirqs_off;
  751. sp += 12;
  752. rets = [sp++];
  753. #endif
  754. [--sp] = RETI;
  755. SP += 4;
  756. /* restore normal evt14 */
  757. p0.l = lo(EVT14);
  758. p0.h = hi(EVT14);
  759. p1.l = _evt_evt14;
  760. p1.h = _evt_evt14;
  761. [p0] = p1;
  762. csync;
  763. rts;
  764. ENDPROC(_evt_up_evt14)
  765. #endif
  766. #ifdef CONFIG_IPIPE
  767. _resume_kernel_from_int:
  768. r1 = LO(~0x8000) (Z);
  769. r1 = r0 & r1;
  770. r0 = 1;
  771. r0 = r1 - r0;
  772. r2 = r1 & r0;
  773. cc = r2 == 0;
  774. /* Sync the root stage only from the outer interrupt level. */
  775. if !cc jump .Lnosync;
  776. r0.l = ___ipipe_sync_root;
  777. r0.h = ___ipipe_sync_root;
  778. [--sp] = reti;
  779. [--sp] = rets;
  780. [--sp] = ( r7:4, p5:3 );
  781. SP += -12;
  782. call ___ipipe_call_irqtail
  783. SP += 12;
  784. ( r7:4, p5:3 ) = [sp++];
  785. rets = [sp++];
  786. reti = [sp++];
  787. .Lnosync:
  788. rts
  789. #elif defined(CONFIG_PREEMPT)
  790. _resume_kernel_from_int:
  791. /* check preempt_count */
  792. r7 = sp;
  793. r4.l = lo(ALIGN_PAGE_MASK);
  794. r4.h = hi(ALIGN_PAGE_MASK);
  795. r7 = r7 & r4;
  796. p5 = r7;
  797. r7 = [p5 + TI_PREEMPT];
  798. cc = r7 == 0x0;
  799. if !cc jump .Lreturn_to_kernel;
  800. .Lneed_schedule:
  801. r7 = [p5 + TI_FLAGS];
  802. r4.l = lo(_TIF_WORK_MASK);
  803. r4.h = hi(_TIF_WORK_MASK);
  804. r7 = r7 & r4;
  805. cc = BITTST(r7, TIF_NEED_RESCHED);
  806. if !cc jump .Lreturn_to_kernel;
  807. /*
  808. * let schedule done at level 15, otherwise sheduled process will run
  809. * at high level and block low level interrupt
  810. */
  811. r6 = reti; /* save reti */
  812. r5.l = .Lkernel_schedule;
  813. r5.h = .Lkernel_schedule;
  814. reti = r5;
  815. rti;
  816. .Lkernel_schedule:
  817. [--sp] = rets;
  818. sp += -12;
  819. pseudo_long_call _preempt_schedule_irq, p4;
  820. sp += 12;
  821. rets = [sp++];
  822. [--sp] = rets;
  823. sp += -12;
  824. /* up to irq14 so that reti after restore_all can return to irq15(kernel) */
  825. pseudo_long_call _up_to_irq14, p4;
  826. sp += 12;
  827. rets = [sp++];
  828. reti = r6; /* restore reti so that origin process can return to interrupted point */
  829. jump .Lneed_schedule;
  830. #else
  831. #define _resume_kernel_from_int .Lreturn_to_kernel
  832. #endif
  833. ENTRY(_return_from_int)
  834. /* If someone else already raised IRQ 15, do nothing. */
  835. csync;
  836. p2.l = lo(ILAT);
  837. p2.h = hi(ILAT);
  838. r0 = [p2];
  839. cc = bittst (r0, EVT_IVG15_P);
  840. if cc jump .Lreturn_to_kernel;
  841. /* if not return to user mode, get out */
  842. p2.l = lo(IPEND);
  843. p2.h = hi(IPEND);
  844. r0 = [p2];
  845. r1 = 0x17(Z);
  846. r2 = ~r1;
  847. r2.h = 0;
  848. r0 = r2 & r0;
  849. r1 = 1;
  850. r1 = r0 - r1;
  851. r2 = r0 & r1;
  852. cc = r2 == 0;
  853. if !cc jump _resume_kernel_from_int;
  854. /* Lower the interrupt level to 15. */
  855. p0.l = lo(EVT15);
  856. p0.h = hi(EVT15);
  857. p1.l = _schedule_and_signal_from_int;
  858. p1.h = _schedule_and_signal_from_int;
  859. [p0] = p1;
  860. csync;
  861. #if ANOMALY_05000281 || ANOMALY_05000461
  862. r0.l = lo(SAFE_USER_INSTRUCTION);
  863. r0.h = hi(SAFE_USER_INSTRUCTION);
  864. reti = r0;
  865. #endif
  866. r0 = 0x801f (z);
  867. STI r0;
  868. raise 15; /* raise evt15 to do signal or reschedule */
  869. rti;
  870. .Lreturn_to_kernel:
  871. rts;
  872. ENDPROC(_return_from_int)
  873. ENTRY(_lower_to_irq14)
  874. #if ANOMALY_05000281 || ANOMALY_05000461
  875. r0.l = lo(SAFE_USER_INSTRUCTION);
  876. r0.h = hi(SAFE_USER_INSTRUCTION);
  877. reti = r0;
  878. #endif
  879. #ifdef CONFIG_DEBUG_HWERR
  880. /* enable irq14 & hwerr interrupt, until we transition to _evt_evt14 */
  881. r0 = (EVT_IVG14 | EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
  882. #else
  883. /* Only enable irq14 interrupt, until we transition to _evt_evt14 */
  884. r0 = (EVT_IVG14 | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
  885. #endif
  886. sti r0;
  887. raise 14;
  888. rti;
  889. ENDPROC(_lower_to_irq14)
  890. ENTRY(_evt_evt14)
  891. #ifdef CONFIG_DEBUG_HWERR
  892. r0 = (EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
  893. sti r0;
  894. #else
  895. cli r0;
  896. #endif
  897. #ifdef CONFIG_TRACE_IRQFLAGS
  898. [--sp] = rets;
  899. sp += -12;
  900. call _trace_hardirqs_off;
  901. sp += 12;
  902. rets = [sp++];
  903. #endif
  904. [--sp] = RETI;
  905. SP += 4;
  906. rts;
  907. ENDPROC(_evt_evt14)
  908. ENTRY(_schedule_and_signal_from_int)
  909. /* To end up here, vector 15 was changed - so we have to change it
  910. * back.
  911. */
  912. p0.l = lo(EVT15);
  913. p0.h = hi(EVT15);
  914. p1.l = _evt_system_call;
  915. p1.h = _evt_system_call;
  916. [p0] = p1;
  917. csync;
  918. /* Set orig_p0 to -1 to indicate this isn't the end of a syscall. */
  919. r0 = -1 (x);
  920. [sp + PT_ORIG_P0] = r0;
  921. p1 = rets;
  922. [sp + PT_RESERVED] = p1;
  923. #ifdef CONFIG_TRACE_IRQFLAGS
  924. /* trace_hardirqs_on() checks if all irqs are disabled. But here IRQ 15
  925. * is turned on, so disable all irqs. */
  926. cli r0;
  927. sp += -12;
  928. call _trace_hardirqs_on;
  929. sp += 12;
  930. #endif
  931. #ifdef CONFIG_SMP
  932. GET_PDA(p0, r0); /* Fetch current PDA (can't migrate to other CPU here) */
  933. r0 = [p0 + PDA_IRQFLAGS];
  934. #else
  935. p0.l = _bfin_irq_flags;
  936. p0.h = _bfin_irq_flags;
  937. r0 = [p0];
  938. #endif
  939. sti r0;
  940. /* finish the userspace "atomic" functions for it */
  941. r1.l = lo(FIXED_CODE_END);
  942. r1.h = hi(FIXED_CODE_END);
  943. r2 = [sp + PT_PC];
  944. cc = r1 <= r2;
  945. if cc jump .Lresume_userspace (bp);
  946. r0 = sp;
  947. sp += -12;
  948. pseudo_long_call _finish_atomic_sections, p5;
  949. sp += 12;
  950. jump.s .Lresume_userspace;
  951. ENDPROC(_schedule_and_signal_from_int)
  952. ENTRY(_schedule_and_signal)
  953. SAVE_CONTEXT_SYSCALL
  954. /* To end up here, vector 15 was changed - so we have to change it
  955. * back.
  956. */
  957. p0.l = lo(EVT15);
  958. p0.h = hi(EVT15);
  959. p1.l = _evt_system_call;
  960. p1.h = _evt_system_call;
  961. [p0] = p1;
  962. csync;
  963. p0.l = 1f;
  964. p0.h = 1f;
  965. [sp + PT_RESERVED] = P0;
  966. call .Lresume_userspace;
  967. 1:
  968. RESTORE_CONTEXT
  969. rti;
  970. ENDPROC(_schedule_and_signal)
  971. /* We handle this 100% in exception space - to reduce overhead
  972. * Only potiential problem is if the software buffer gets swapped out of the
  973. * CPLB table - then double fault. - so we don't let this happen in other places
  974. */
  975. #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
  976. ENTRY(_ex_trace_buff_full)
  977. [--sp] = P3;
  978. [--sp] = P2;
  979. [--sp] = LC0;
  980. [--sp] = LT0;
  981. [--sp] = LB0;
  982. P5.L = _trace_buff_offset;
  983. P5.H = _trace_buff_offset;
  984. P3 = [P5]; /* trace_buff_offset */
  985. P5.L = lo(TBUFSTAT);
  986. P5.H = hi(TBUFSTAT);
  987. R7 = [P5];
  988. R7 <<= 1; /* double, since we need to read twice */
  989. LC0 = R7;
  990. R7 <<= 2; /* need to shift over again,
  991. * to get the number of bytes */
  992. P5.L = lo(TBUF);
  993. P5.H = hi(TBUF);
  994. R6 = ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN)*1024) - 1;
  995. P2 = R7;
  996. P3 = P3 + P2;
  997. R7 = P3;
  998. R7 = R7 & R6;
  999. P3 = R7;
  1000. P2.L = _trace_buff_offset;
  1001. P2.H = _trace_buff_offset;
  1002. [P2] = P3;
  1003. P2.L = _software_trace_buff;
  1004. P2.H = _software_trace_buff;
  1005. LSETUP (.Lstart, .Lend) LC0;
  1006. .Lstart:
  1007. R7 = [P5]; /* read TBUF */
  1008. P4 = P3 + P2;
  1009. [P4] = R7;
  1010. P3 += -4;
  1011. R7 = P3;
  1012. R7 = R7 & R6;
  1013. .Lend:
  1014. P3 = R7;
  1015. LB0 = [sp++];
  1016. LT0 = [sp++];
  1017. LC0 = [sp++];
  1018. P2 = [sp++];
  1019. P3 = [sp++];
  1020. jump _bfin_return_from_exception;
  1021. ENDPROC(_ex_trace_buff_full)
  1022. #if CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN == 4
  1023. .data
  1024. #else
  1025. .section .l1.data.B
  1026. #endif /* CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN */
  1027. ENTRY(_trace_buff_offset)
  1028. .long 0;
  1029. ALIGN
  1030. ENTRY(_software_trace_buff)
  1031. .rept ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN)*256);
  1032. .long 0
  1033. .endr
  1034. #endif /* CONFIG_DEBUG_BFIN_HWTRACE_EXPAND */
  1035. #ifdef CONFIG_EARLY_PRINTK
  1036. __INIT
  1037. ENTRY(_early_trap)
  1038. SAVE_ALL_SYS
  1039. trace_buffer_stop(p0,r0);
  1040. ANOMALY_283_315_WORKAROUND(p4, r5)
  1041. /* Turn caches off, to ensure we don't get double exceptions */
  1042. P4.L = LO(IMEM_CONTROL);
  1043. P4.H = HI(IMEM_CONTROL);
  1044. R5 = [P4]; /* Control Register*/
  1045. BITCLR(R5,ENICPLB_P);
  1046. CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
  1047. [P4] = R5;
  1048. SSYNC;
  1049. P4.L = LO(DMEM_CONTROL);
  1050. P4.H = HI(DMEM_CONTROL);
  1051. R5 = [P4];
  1052. BITCLR(R5,ENDCPLB_P);
  1053. CSYNC; /* Disabling of CPLBs should be proceeded by a CSYNC */
  1054. [P4] = R5;
  1055. SSYNC;
  1056. r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
  1057. r1 = RETX;
  1058. SP += -12;
  1059. call _early_trap_c;
  1060. SP += 12;
  1061. ENDPROC(_early_trap)
  1062. __FINIT
  1063. #endif /* CONFIG_EARLY_PRINTK */
  1064. /*
  1065. * Put these in the kernel data section - that should always be covered by
  1066. * a CPLB. This is needed to ensure we don't get double fault conditions
  1067. */
  1068. #ifdef CONFIG_SYSCALL_TAB_L1
  1069. .section .l1.data
  1070. #else
  1071. .data
  1072. #endif
  1073. ENTRY(_ex_table)
  1074. /* entry for each EXCAUSE[5:0]
  1075. * This table must be in sync with the table in ./kernel/traps.c
  1076. * EXCPT instruction can provide 4 bits of EXCAUSE, allowing 16 to be user defined
  1077. */
  1078. .long _ex_syscall /* 0x00 - User Defined - Linux Syscall */
  1079. .long _ex_trap_c /* 0x01 - User Defined - Software breakpoint */
  1080. #ifdef CONFIG_KGDB
  1081. .long _ex_trap_c /* 0x02 - User Defined - KGDB initial connection
  1082. and break signal trap */
  1083. #else
  1084. .long _ex_replaceable /* 0x02 - User Defined */
  1085. #endif
  1086. .long _ex_trap_c /* 0x03 - User Defined - userspace stack overflow */
  1087. .long _ex_trap_c /* 0x04 - User Defined - dump trace buffer */
  1088. .long _ex_replaceable /* 0x05 - User Defined */
  1089. .long _ex_replaceable /* 0x06 - User Defined */
  1090. .long _ex_replaceable /* 0x07 - User Defined */
  1091. .long _ex_replaceable /* 0x08 - User Defined */
  1092. .long _ex_replaceable /* 0x09 - User Defined */
  1093. .long _ex_replaceable /* 0x0A - User Defined */
  1094. .long _ex_replaceable /* 0x0B - User Defined */
  1095. .long _ex_replaceable /* 0x0C - User Defined */
  1096. .long _ex_replaceable /* 0x0D - User Defined */
  1097. .long _ex_replaceable /* 0x0E - User Defined */
  1098. .long _ex_replaceable /* 0x0F - User Defined */
  1099. .long _ex_single_step /* 0x10 - HW Single step */
  1100. #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
  1101. .long _ex_trace_buff_full /* 0x11 - Trace Buffer Full */
  1102. #else
  1103. .long _ex_trap_c /* 0x11 - Trace Buffer Full */
  1104. #endif
  1105. .long _ex_trap_c /* 0x12 - Reserved */
  1106. .long _ex_trap_c /* 0x13 - Reserved */
  1107. .long _ex_trap_c /* 0x14 - Reserved */
  1108. .long _ex_trap_c /* 0x15 - Reserved */
  1109. .long _ex_trap_c /* 0x16 - Reserved */
  1110. .long _ex_trap_c /* 0x17 - Reserved */
  1111. .long _ex_trap_c /* 0x18 - Reserved */
  1112. .long _ex_trap_c /* 0x19 - Reserved */
  1113. .long _ex_trap_c /* 0x1A - Reserved */
  1114. .long _ex_trap_c /* 0x1B - Reserved */
  1115. .long _ex_trap_c /* 0x1C - Reserved */
  1116. .long _ex_trap_c /* 0x1D - Reserved */
  1117. .long _ex_trap_c /* 0x1E - Reserved */
  1118. .long _ex_trap_c /* 0x1F - Reserved */
  1119. .long _ex_trap_c /* 0x20 - Reserved */
  1120. .long _ex_trap_c /* 0x21 - Undefined Instruction */
  1121. .long _ex_trap_c /* 0x22 - Illegal Instruction Combination */
  1122. .long _ex_dviol /* 0x23 - Data CPLB Protection Violation */
  1123. .long _ex_trap_c /* 0x24 - Data access misaligned */
  1124. .long _ex_trap_c /* 0x25 - Unrecoverable Event */
  1125. .long _ex_dmiss /* 0x26 - Data CPLB Miss */
  1126. .long _ex_dmult /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero */
  1127. .long _ex_trap_c /* 0x28 - Emulation Watchpoint */
  1128. .long _ex_trap_c /* 0x29 - Instruction fetch access error (535 only) */
  1129. .long _ex_trap_c /* 0x2A - Instruction fetch misaligned */
  1130. .long _ex_trap_c /* 0x2B - Instruction CPLB protection Violation */
  1131. .long _ex_icplb_miss /* 0x2C - Instruction CPLB miss */
  1132. .long _ex_trap_c /* 0x2D - Instruction CPLB Multiple Hits */
  1133. .long _ex_trap_c /* 0x2E - Illegal use of Supervisor Resource */
  1134. .long _ex_trap_c /* 0x2E - Illegal use of Supervisor Resource */
  1135. .long _ex_trap_c /* 0x2F - Reserved */
  1136. .long _ex_trap_c /* 0x30 - Reserved */
  1137. .long _ex_trap_c /* 0x31 - Reserved */
  1138. .long _ex_trap_c /* 0x32 - Reserved */
  1139. .long _ex_trap_c /* 0x33 - Reserved */
  1140. .long _ex_trap_c /* 0x34 - Reserved */
  1141. .long _ex_trap_c /* 0x35 - Reserved */
  1142. .long _ex_trap_c /* 0x36 - Reserved */
  1143. .long _ex_trap_c /* 0x37 - Reserved */
  1144. .long _ex_trap_c /* 0x38 - Reserved */
  1145. .long _ex_trap_c /* 0x39 - Reserved */
  1146. .long _ex_trap_c /* 0x3A - Reserved */
  1147. .long _ex_trap_c /* 0x3B - Reserved */
  1148. .long _ex_trap_c /* 0x3C - Reserved */
  1149. .long _ex_trap_c /* 0x3D - Reserved */
  1150. .long _ex_trap_c /* 0x3E - Reserved */
  1151. .long _ex_trap_c /* 0x3F - Reserved */
  1152. END(_ex_table)
  1153. ENTRY(_sys_call_table)
  1154. .long _sys_restart_syscall /* 0 */
  1155. .long _sys_exit
  1156. .long _sys_ni_syscall /* fork */
  1157. .long _sys_read
  1158. .long _sys_write
  1159. .long _sys_open /* 5 */
  1160. .long _sys_close
  1161. .long _sys_ni_syscall /* old waitpid */
  1162. .long _sys_creat
  1163. .long _sys_link
  1164. .long _sys_unlink /* 10 */
  1165. .long _sys_execve
  1166. .long _sys_chdir
  1167. .long _sys_time
  1168. .long _sys_mknod
  1169. .long _sys_chmod /* 15 */
  1170. .long _sys_chown /* chown16 */
  1171. .long _sys_ni_syscall /* old break syscall holder */
  1172. .long _sys_ni_syscall /* old stat */
  1173. .long _sys_lseek
  1174. .long _sys_getpid /* 20 */
  1175. .long _sys_mount
  1176. .long _sys_ni_syscall /* old umount */
  1177. .long _sys_setuid
  1178. .long _sys_getuid
  1179. .long _sys_stime /* 25 */
  1180. .long _sys_ptrace
  1181. .long _sys_alarm
  1182. .long _sys_ni_syscall /* old fstat */
  1183. .long _sys_pause
  1184. .long _sys_ni_syscall /* old utime */ /* 30 */
  1185. .long _sys_ni_syscall /* old stty syscall holder */
  1186. .long _sys_ni_syscall /* old gtty syscall holder */
  1187. .long _sys_access
  1188. .long _sys_nice
  1189. .long _sys_ni_syscall /* 35 */ /* old ftime syscall holder */
  1190. .long _sys_sync
  1191. .long _sys_kill
  1192. .long _sys_rename
  1193. .long _sys_mkdir
  1194. .long _sys_rmdir /* 40 */
  1195. .long _sys_dup
  1196. .long _sys_pipe
  1197. .long _sys_times
  1198. .long _sys_ni_syscall /* old prof syscall holder */
  1199. .long _sys_brk /* 45 */
  1200. .long _sys_setgid
  1201. .long _sys_getgid
  1202. .long _sys_ni_syscall /* old sys_signal */
  1203. .long _sys_geteuid /* geteuid16 */
  1204. .long _sys_getegid /* getegid16 */ /* 50 */
  1205. .long _sys_acct
  1206. .long _sys_umount /* recycled never used phys() */
  1207. .long _sys_ni_syscall /* old lock syscall holder */
  1208. .long _sys_ioctl
  1209. .long _sys_fcntl /* 55 */
  1210. .long _sys_ni_syscall /* old mpx syscall holder */
  1211. .long _sys_setpgid
  1212. .long _sys_ni_syscall /* old ulimit syscall holder */
  1213. .long _sys_ni_syscall /* old old uname */
  1214. .long _sys_umask /* 60 */
  1215. .long _sys_chroot
  1216. .long _sys_ustat
  1217. .long _sys_dup2
  1218. .long _sys_getppid
  1219. .long _sys_getpgrp /* 65 */
  1220. .long _sys_setsid
  1221. .long _sys_ni_syscall /* old sys_sigaction */
  1222. .long _sys_sgetmask
  1223. .long _sys_ssetmask
  1224. .long _sys_setreuid /* setreuid16 */ /* 70 */
  1225. .long _sys_setregid /* setregid16 */
  1226. .long _sys_ni_syscall /* old sys_sigsuspend */
  1227. .long _sys_ni_syscall /* old sys_sigpending */
  1228. .long _sys_sethostname
  1229. .long _sys_setrlimit /* 75 */
  1230. .long _sys_ni_syscall /* old getrlimit */
  1231. .long _sys_getrusage
  1232. .long _sys_gettimeofday
  1233. .long _sys_settimeofday
  1234. .long _sys_getgroups /* getgroups16 */ /* 80 */
  1235. .long _sys_setgroups /* setgroups16 */
  1236. .long _sys_ni_syscall /* old_select */
  1237. .long _sys_symlink
  1238. .long _sys_ni_syscall /* old lstat */
  1239. .long _sys_readlink /* 85 */
  1240. .long _sys_uselib
  1241. .long _sys_ni_syscall /* sys_swapon */
  1242. .long _sys_reboot
  1243. .long _sys_ni_syscall /* old_readdir */
  1244. .long _sys_ni_syscall /* sys_mmap */ /* 90 */
  1245. .long _sys_munmap
  1246. .long _sys_truncate
  1247. .long _sys_ftruncate
  1248. .long _sys_fchmod
  1249. .long _sys_fchown /* fchown16 */ /* 95 */
  1250. .long _sys_getpriority
  1251. .long _sys_setpriority
  1252. .long _sys_ni_syscall /* old profil syscall holder */
  1253. .long _sys_statfs
  1254. .long _sys_fstatfs /* 100 */
  1255. .long _sys_ni_syscall
  1256. .long _sys_ni_syscall /* old sys_socketcall */
  1257. .long _sys_syslog
  1258. .long _sys_setitimer
  1259. .long _sys_getitimer /* 105 */
  1260. .long _sys_newstat
  1261. .long _sys_newlstat
  1262. .long _sys_newfstat
  1263. .long _sys_ni_syscall /* old uname */
  1264. .long _sys_ni_syscall /* iopl for i386 */ /* 110 */
  1265. .long _sys_vhangup
  1266. .long _sys_ni_syscall /* obsolete idle() syscall */
  1267. .long _sys_ni_syscall /* vm86old for i386 */
  1268. .long _sys_wait4
  1269. .long _sys_ni_syscall /* 115 */ /* sys_swapoff */
  1270. .long _sys_sysinfo
  1271. .long _sys_ni_syscall /* old sys_ipc */
  1272. .long _sys_fsync
  1273. .long _sys_ni_syscall /* old sys_sigreturn */
  1274. .long _bfin_clone /* 120 */
  1275. .long _sys_setdomainname
  1276. .long _sys_newuname
  1277. .long _sys_ni_syscall /* old sys_modify_ldt */
  1278. .long _sys_adjtimex
  1279. .long _sys_mprotect /* 125 */
  1280. .long _sys_ni_syscall /* old sys_sigprocmask */
  1281. .long _sys_ni_syscall /* old "creat_module" */
  1282. .long _sys_init_module
  1283. .long _sys_delete_module
  1284. .long _sys_ni_syscall /* 130: old "get_kernel_syms" */
  1285. .long _sys_quotactl
  1286. .long _sys_getpgid
  1287. .long _sys_fchdir
  1288. .long _sys_bdflush
  1289. .long _sys_ni_syscall /* 135 */ /* sys_sysfs */
  1290. .long _sys_personality
  1291. .long _sys_ni_syscall /* for afs_syscall */
  1292. .long _sys_setfsuid /* setfsuid16 */
  1293. .long _sys_setfsgid /* setfsgid16 */
  1294. .long _sys_llseek /* 140 */
  1295. .long _sys_getdents
  1296. .long _sys_ni_syscall /* sys_select */
  1297. .long _sys_flock
  1298. .long _sys_msync
  1299. .long _sys_readv /* 145 */
  1300. .long _sys_writev
  1301. .long _sys_getsid
  1302. .long _sys_fdatasync
  1303. .long _sys_sysctl
  1304. .long _sys_mlock /* 150 */
  1305. .long _sys_munlock
  1306. .long _sys_mlockall
  1307. .long _sys_munlockall
  1308. .long _sys_sched_setparam
  1309. .long _sys_sched_getparam /* 155 */
  1310. .long _sys_sched_setscheduler
  1311. .long _sys_sched_getscheduler
  1312. .long _sys_sched_yield
  1313. .long _sys_sched_get_priority_max
  1314. .long _sys_sched_get_priority_min /* 160 */
  1315. .long _sys_sched_rr_get_interval
  1316. .long _sys_nanosleep
  1317. .long _sys_mremap
  1318. .long _sys_setresuid /* setresuid16 */
  1319. .long _sys_getresuid /* getresuid16 */ /* 165 */
  1320. .long _sys_ni_syscall /* for vm86 */
  1321. .long _sys_ni_syscall /* old "query_module" */
  1322. .long _sys_ni_syscall /* sys_poll */
  1323. .long _sys_ni_syscall /* old nfsservctl */
  1324. .long _sys_setresgid /* setresgid16 */ /* 170 */
  1325. .long _sys_getresgid /* getresgid16 */
  1326. .long _sys_prctl
  1327. .long _sys_rt_sigreturn
  1328. .long _sys_rt_sigaction
  1329. .long _sys_rt_sigprocmask /* 175 */
  1330. .long _sys_rt_sigpending
  1331. .long _sys_rt_sigtimedwait
  1332. .long _sys_rt_sigqueueinfo
  1333. .long _sys_rt_sigsuspend
  1334. .long _sys_pread64 /* 180 */
  1335. .long _sys_pwrite64
  1336. .long _sys_lchown /* lchown16 */
  1337. .long _sys_getcwd
  1338. .long _sys_capget
  1339. .long _sys_capset /* 185 */
  1340. .long _sys_sigaltstack
  1341. .long _sys_sendfile
  1342. .long _sys_ni_syscall /* streams1 */
  1343. .long _sys_ni_syscall /* streams2 */
  1344. .long _sys_vfork /* 190 */
  1345. .long _sys_getrlimit
  1346. .long _sys_mmap_pgoff
  1347. .long _sys_truncate64
  1348. .long _sys_ftruncate64
  1349. .long _sys_stat64 /* 195 */
  1350. .long _sys_lstat64
  1351. .long _sys_fstat64
  1352. .long _sys_chown
  1353. .long _sys_getuid
  1354. .long _sys_getgid /* 200 */
  1355. .long _sys_geteuid
  1356. .long _sys_getegid
  1357. .long _sys_setreuid
  1358. .long _sys_setregid
  1359. .long _sys_getgroups /* 205 */
  1360. .long _sys_setgroups
  1361. .long _sys_fchown
  1362. .long _sys_setresuid
  1363. .long _sys_getresuid
  1364. .long _sys_setresgid /* 210 */
  1365. .long _sys_getresgid
  1366. .long _sys_lchown
  1367. .long _sys_setuid
  1368. .long _sys_setgid
  1369. .long _sys_setfsuid /* 215 */
  1370. .long _sys_setfsgid
  1371. .long _sys_pivot_root
  1372. .long _sys_mincore
  1373. .long _sys_madvise
  1374. .long _sys_getdents64 /* 220 */
  1375. .long _sys_fcntl64
  1376. .long _sys_ni_syscall /* reserved for TUX */
  1377. .long _sys_ni_syscall
  1378. .long _sys_gettid
  1379. .long _sys_readahead /* 225 */
  1380. .long _sys_setxattr
  1381. .long _sys_lsetxattr
  1382. .long _sys_fsetxattr
  1383. .long _sys_getxattr
  1384. .long _sys_lgetxattr /* 230 */
  1385. .long _sys_fgetxattr
  1386. .long _sys_listxattr
  1387. .long _sys_llistxattr
  1388. .long _sys_flistxattr
  1389. .long _sys_removexattr /* 235 */
  1390. .long _sys_lremovexattr
  1391. .long _sys_fremovexattr
  1392. .long _sys_tkill
  1393. .long _sys_sendfile64
  1394. .long _sys_futex /* 240 */
  1395. .long _sys_sched_setaffinity
  1396. .long _sys_sched_getaffinity
  1397. .long _sys_ni_syscall /* sys_set_thread_area */
  1398. .long _sys_ni_syscall /* sys_get_thread_area */
  1399. .long _sys_io_setup /* 245 */
  1400. .long _sys_io_destroy
  1401. .long _sys_io_getevents
  1402. .long _sys_io_submit
  1403. .long _sys_io_cancel
  1404. .long _sys_ni_syscall /* 250 */ /* sys_alloc_hugepages */
  1405. .long _sys_ni_syscall /* sys_freec_hugepages */
  1406. .long _sys_exit_group
  1407. .long _sys_lookup_dcookie
  1408. .long _sys_bfin_spinlock
  1409. .long _sys_epoll_create /* 255 */
  1410. .long _sys_epoll_ctl
  1411. .long _sys_epoll_wait
  1412. .long _sys_ni_syscall /* remap_file_pages */
  1413. .long _sys_set_tid_address
  1414. .long _sys_timer_create /* 260 */
  1415. .long _sys_timer_settime
  1416. .long _sys_timer_gettime
  1417. .long _sys_timer_getoverrun
  1418. .long _sys_timer_delete
  1419. .long _sys_clock_settime /* 265 */
  1420. .long _sys_clock_gettime
  1421. .long _sys_clock_getres
  1422. .long _sys_clock_nanosleep
  1423. .long _sys_statfs64
  1424. .long _sys_fstatfs64 /* 270 */
  1425. .long _sys_tgkill
  1426. .long _sys_utimes
  1427. .long _sys_fadvise64_64
  1428. .long _sys_ni_syscall /* vserver */
  1429. .long _sys_mbind /* 275 */
  1430. .long _sys_ni_syscall /* get_mempolicy */
  1431. .long _sys_ni_syscall /* set_mempolicy */
  1432. .long _sys_mq_open
  1433. .long _sys_mq_unlink
  1434. .long _sys_mq_timedsend /* 280 */
  1435. .long _sys_mq_timedreceive
  1436. .long _sys_mq_notify
  1437. .long _sys_mq_getsetattr
  1438. .long _sys_ni_syscall /* kexec_load */
  1439. .long _sys_waitid /* 285 */
  1440. .long _sys_add_key
  1441. .long _sys_request_key
  1442. .long _sys_keyctl
  1443. .long _sys_ioprio_set
  1444. .long _sys_ioprio_get /* 290 */
  1445. .long _sys_inotify_init
  1446. .long _sys_inotify_add_watch
  1447. .long _sys_inotify_rm_watch
  1448. .long _sys_ni_syscall /* migrate_pages */
  1449. .long _sys_openat /* 295 */
  1450. .long _sys_mkdirat
  1451. .long _sys_mknodat
  1452. .long _sys_fchownat
  1453. .long _sys_futimesat
  1454. .long _sys_fstatat64 /* 300 */
  1455. .long _sys_unlinkat
  1456. .long _sys_renameat
  1457. .long _sys_linkat
  1458. .long _sys_symlinkat
  1459. .long _sys_readlinkat /* 305 */
  1460. .long _sys_fchmodat
  1461. .long _sys_faccessat
  1462. .long _sys_pselect6
  1463. .long _sys_ppoll
  1464. .long _sys_unshare /* 310 */
  1465. .long _sys_sram_alloc
  1466. .long _sys_sram_free
  1467. .long _sys_dma_memcpy
  1468. .long _sys_accept
  1469. .long _sys_bind /* 315 */
  1470. .long _sys_connect
  1471. .long _sys_getpeername
  1472. .long _sys_getsockname
  1473. .long _sys_getsockopt
  1474. .long _sys_listen /* 320 */
  1475. .long _sys_recv
  1476. .long _sys_recvfrom
  1477. .long _sys_recvmsg
  1478. .long _sys_send
  1479. .long _sys_sendmsg /* 325 */
  1480. .long _sys_sendto
  1481. .long _sys_setsockopt
  1482. .long _sys_shutdown
  1483. .long _sys_socket
  1484. .long _sys_socketpair /* 330 */
  1485. .long _sys_semctl
  1486. .long _sys_semget
  1487. .long _sys_semop
  1488. .long _sys_msgctl
  1489. .long _sys_msgget /* 335 */
  1490. .long _sys_msgrcv
  1491. .long _sys_msgsnd
  1492. .long _sys_shmat
  1493. .long _sys_shmctl
  1494. .long _sys_shmdt /* 340 */
  1495. .long _sys_shmget
  1496. .long _sys_splice
  1497. .long _sys_sync_file_range
  1498. .long _sys_tee
  1499. .long _sys_vmsplice /* 345 */
  1500. .long _sys_epoll_pwait
  1501. .long _sys_utimensat
  1502. .long _sys_signalfd
  1503. .long _sys_timerfd_create
  1504. .long _sys_eventfd /* 350 */
  1505. .long _sys_pread64
  1506. .long _sys_pwrite64
  1507. .long _sys_fadvise64
  1508. .long _sys_set_robust_list
  1509. .long _sys_get_robust_list /* 355 */
  1510. .long _sys_fallocate
  1511. .long _sys_semtimedop
  1512. .long _sys_timerfd_settime
  1513. .long _sys_timerfd_gettime
  1514. .long _sys_signalfd4 /* 360 */
  1515. .long _sys_eventfd2
  1516. .long _sys_epoll_create1
  1517. .long _sys_dup3
  1518. .long _sys_pipe2
  1519. .long _sys_inotify_init1 /* 365 */
  1520. .long _sys_preadv
  1521. .long _sys_pwritev
  1522. .long _sys_rt_tgsigqueueinfo
  1523. .long _sys_perf_event_open
  1524. .long _sys_recvmmsg /* 370 */
  1525. .long _sys_fanotify_init
  1526. .long _sys_fanotify_mark
  1527. .long _sys_prlimit64
  1528. .long _sys_cacheflush
  1529. .long _sys_name_to_handle_at /* 375 */
  1530. .long _sys_open_by_handle_at
  1531. .long _sys_clock_adjtime
  1532. .long _sys_syncfs
  1533. .long _sys_setns
  1534. .long _sys_sendmmsg /* 380 */
  1535. .long _sys_process_vm_readv
  1536. .long _sys_process_vm_writev
  1537. .long _sys_kcmp
  1538. .long _sys_finit_module
  1539. .long _sys_sched_setattr /* 385 */
  1540. .long _sys_sched_getattr
  1541. .long _sys_renameat2
  1542. .long _sys_seccomp
  1543. .long _sys_getrandom
  1544. .long _sys_memfd_create /* 390 */
  1545. .long _sys_bpf
  1546. .long _sys_execveat
  1547. .rept NR_syscalls-(.-_sys_call_table)/4
  1548. .long _sys_ni_syscall
  1549. .endr
  1550. END(_sys_call_table)