port__m33_8h_source.tex 2.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. \doxysection{port\+\_\+m33.\+h}
  2. \label{port__m33_8h_source}\index{C:/Users/yoneda/Documents/Pico\_Projects/tinykernel/tinykernel/src/port/m33/port\_m33.h@{C:/Users/yoneda/Documents/Pico\_Projects/tinykernel/tinykernel/src/port/m33/port\_m33.h}}
  3. \textbf{ [詳解]}
  4. \begin{DoxyCode}{0}
  5. \DoxyCodeLine{00001\ \textcolor{preprocessor}{\#pragma\ once}}
  6. \DoxyCodeLine{00002\ }
  7. \DoxyCodeLine{00003\ \textcolor{preprocessor}{\#include\ <stdint.h>}}
  8. \DoxyCodeLine{00004\ }
  9. \DoxyCodeLine{00005\ \textcolor{preprocessor}{\#include\ "{}hardware/structs/scb.h"{}}}
  10. \DoxyCodeLine{00006\ }
  11. \DoxyCodeLine{00007\ \textcolor{preprocessor}{\#ifdef\ \_\_cplusplus}}
  12. \DoxyCodeLine{00008\ \textcolor{keyword}{extern}\ \textcolor{stringliteral}{"{}C"{}}\ \{}
  13. \DoxyCodeLine{00009\ \textcolor{preprocessor}{\#endif}}
  14. \DoxyCodeLine{00010\ }
  15. \DoxyCodeLine{00011\ \textcolor{comment}{//\ One-\/time\ port\ setup:\ FPU\ context\ policy\ +\ SysTick\ +\ PendSV\ priority.\ Called\ from\ tk::start().}}
  16. \DoxyCodeLine{00012\ \textcolor{keywordtype}{void}\ tk\_port\_init(uint32\_t\ ticks\_per\_sec);}
  17. \DoxyCodeLine{00013\ }
  18. \DoxyCodeLine{00014\ \textcolor{comment}{//\ Build\ a\ task's\ initial\ stack\ frame.\ Returns\ the\ SP\ to\ start\ with.}}
  19. \DoxyCodeLine{00015\ uintptr\_t\ tk\_port\_make\_frame(uint8\_t*\ base,\ uint32\_t\ size\_bytes,\ \textcolor{keywordtype}{void}*\ entry\_fn,\ \textcolor{keywordtype}{void}*\ arg);}
  20. \DoxyCodeLine{00016\ }
  21. \DoxyCodeLine{00017\ \textcolor{comment}{//\ Jump\ into\ the\ first\ task\ (r0\ =\ SP\ from\ tk\_port\_make\_frame).\ Never\ returns.}}
  22. \DoxyCodeLine{00018\ \textcolor{keywordtype}{void}\ tk\_port\_start(uintptr\_t\ sp);}
  23. \DoxyCodeLine{00019\ }
  24. \DoxyCodeLine{00020\ \textcolor{comment}{//\ Trigger\ a\ PendSV\ exception\ to\ initiate\ context\ switching.}}
  25. \DoxyCodeLine{00021\ \textcolor{keyword}{static}\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ tk\_port\_trigger\_pendsv(\textcolor{keywordtype}{void})\ \{}
  26. \DoxyCodeLine{00022\ \ \ \ \ scb\_hw-\/>icsr\ =\ 1u\ <<\ 28;\ \ \textcolor{comment}{//\ SCB\_ICSR\_PENDSVSET\_Msk}}
  27. \DoxyCodeLine{00023\ \ \ \ \ \_\_asm\_\_\ \textcolor{keyword}{volatile}(\textcolor{stringliteral}{"{}isb"{}}\ :::\ \textcolor{stringliteral}{"{}memory"{}});}
  28. \DoxyCodeLine{00024\ \}}
  29. \DoxyCodeLine{00025\ }
  30. \DoxyCodeLine{00026\ \textcolor{preprocessor}{\#ifdef\ \_\_cplusplus}}
  31. \DoxyCodeLine{00027\ \}}
  32. \DoxyCodeLine{00028\ \textcolor{preprocessor}{\#endif}}
  33. \end{DoxyCode}