Commit a0a3bb6a by trkall

Lab 4

parent f6436be7
......@@ -88,7 +88,7 @@ int OS_AddThreads(void(*thread0)(void),
void(*thread3)(void),
void(*thread4)(void),
void(*thread5)(void)){
// **similar to Lab 2. initialize as not blocked, not sleeping****
// **similar to Lab 2. initialize as not blocked, not sleeping****
// initialize TCB circular list
tcbs[0].next = &tcbs[1];
tcbs[1].next = &tcbs[2];
......@@ -119,8 +119,8 @@ int OS_AddThreads(void(*thread0)(void),
SetInitialStack(5);
Stacks[5][STACKSIZE-2] = (int32_t)(thread5);
return 1; // successful
return 1; // successful
}
//******** OS_AddPeriodicEventThread ***************
......
......@@ -100,7 +100,10 @@
<tRSysVw>1</tRSysVw>
<sRunDeb>0</sRunDeb>
<sLrtime>0</sLrtime>
<nTsel>3</nTsel>
<bEvRecOn>1</bEvRecOn>
<bSchkAxf>0</bSchkAxf>
<bTchkAxf>0</bTchkAxf>
<nTsel>-1</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
......@@ -202,6 +205,17 @@
</DebugFlag>
<LintExecutable></LintExecutable>
<LintConfigFile></LintConfigFile>
<bLintAuto>0</bLintAuto>
<bAutoGenD>0</bAutoGenD>
<LntExFlags>0</LntExFlags>
<pMisraName></pMisraName>
<pszMrule></pszMrule>
<pSingCmds></pSingCmds>
<pMultCmds></pMultCmds>
<pMisraNamep></pMisraNamep>
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
</TargetOption>
</Target>
......@@ -216,7 +230,6 @@
<FileNumber>1</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>1</Focus>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\Lab4.c</PathWithFileName>
......@@ -229,7 +242,6 @@
<FileNumber>2</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>1</Focus>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\inc\BSP.c</PathWithFileName>
......@@ -242,7 +254,6 @@
<FileNumber>3</FileNumber>
<FileType>2</FileType>
<tvExp>0</tvExp>
<Focus>1</Focus>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\osasm.s</PathWithFileName>
......@@ -255,7 +266,6 @@
<FileNumber>4</FileNumber>
<FileType>1</FileType>
<tvExp>1</tvExp>
<Focus>1</Focus>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\os.c</PathWithFileName>
......@@ -268,7 +278,6 @@
<FileNumber>5</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>1</Focus>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\inc\Profile.c</PathWithFileName>
......@@ -289,7 +298,6 @@
<FileNumber>6</FileNumber>
<FileType>3</FileType>
<tvExp>0</tvExp>
<Focus>1</Focus>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\texas.o</PathWithFileName>
......
......@@ -10,11 +10,12 @@
<TargetName>Target</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>
<Device>TM4C123GH6PM</Device>
<Vendor>Texas Instruments</Vendor>
<PackID>Keil.TM4C_DFP.1.0.0</PackID>
<PackID>Keil.TM4C_DFP.1.1.0</PackID>
<PackURL>http://www.keil.com/pack/</PackURL>
<Cpu>IROM(0x00000000,0x040000) IRAM(0x20000000,0x008000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec>
......@@ -84,6 +85,8 @@
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopA1X>0</nStopA1X>
<nStopA2X>0</nStopA2X>
</AfterMake>
<SelectedForBatchBuild>0</SelectedForBatchBuild>
<SVCSIdString></SVCSIdString>
......@@ -122,47 +125,6 @@
<HexOffset>0</HexOffset>
<Oh166RecLen>16</Oh166RecLen>
</OPTHX>
<Simulator>
<UseSimulator>0</UseSimulator>
<LoadApplicationAtStartup>1</LoadApplicationAtStartup>
<RunToMain>1</RunToMain>
<RestoreBreakpoints>1</RestoreBreakpoints>
<RestoreWatchpoints>1</RestoreWatchpoints>
<RestoreMemoryDisplay>1</RestoreMemoryDisplay>
<RestoreFunctions>1</RestoreFunctions>
<RestoreToolbox>1</RestoreToolbox>
<LimitSpeedToRealTime>0</LimitSpeedToRealTime>
<RestoreSysVw>1</RestoreSysVw>
</Simulator>
<Target>
<UseTarget>1</UseTarget>
<LoadApplicationAtStartup>1</LoadApplicationAtStartup>
<RunToMain>1</RunToMain>
<RestoreBreakpoints>1</RestoreBreakpoints>
<RestoreWatchpoints>1</RestoreWatchpoints>
<RestoreMemoryDisplay>1</RestoreMemoryDisplay>
<RestoreFunctions>0</RestoreFunctions>
<RestoreToolbox>1</RestoreToolbox>
<RestoreTracepoints>1</RestoreTracepoints>
<RestoreSysVw>1</RestoreSysVw>
</Target>
<RunDebugAfterBuild>0</RunDebugAfterBuild>
<TargetSelection>3</TargetSelection>
<SimDlls>
<CpuDll></CpuDll>
<CpuDllArguments></CpuDllArguments>
<PeripheralDll></PeripheralDll>
<PeripheralDllArguments></PeripheralDllArguments>
<InitializationFile></InitializationFile>
</SimDlls>
<TargetDlls>
<CpuDll></CpuDll>
<CpuDllArguments></CpuDllArguments>
<PeripheralDll></PeripheralDll>
<PeripheralDllArguments></PeripheralDllArguments>
<InitializationFile></InitializationFile>
<Driver>BIN\lmidk-agdi.dll</Driver>
</TargetDlls>
</DebugOption>
<Utilities>
<Flash1>
......@@ -170,7 +132,7 @@
<UseExternalTool>0</UseExternalTool>
<RunIndependent>0</RunIndependent>
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
<Capability>1</Capability>
<Capability>0</Capability>
<DriverSelection>4096</DriverSelection>
</Flash1>
<bUseTDR>1</bUseTDR>
......@@ -221,12 +183,14 @@
<hadXRAM>0</hadXRAM>
<uocXRam>0</uocXRam>
<RvdsVP>1</RvdsVP>
<RvdsMve>0</RvdsMve>
<hadIRAM2>0</hadIRAM2>
<hadIROM2>0</hadIROM2>
<StupSel>8</StupSel>
<useUlib>0</useUlib>
<EndSel>0</EndSel>
<uLtcg>0</uLtcg>
<nSecure>0</nSecure>
<RoSelD>3</RoSelD>
<RwSelD>3</RwSelD>
<CodeSel>0</CodeSel>
......@@ -360,7 +324,15 @@
<uThumb>0</uThumb>
<uSurpInc>0</uSurpInc>
<uC99>1</uC99>
<uGnu>0</uGnu>
<useXO>0</useXO>
<v6Lang>1</v6Lang>
<v6LangP>1</v6LangP>
<vShortEn>1</vShortEn>
<vShortWch>1</vShortWch>
<v6Lto>0</v6Lto>
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
......@@ -378,6 +350,7 @@
<NoWarn>0</NoWarn>
<uSurpInc>0</uSurpInc>
<useXO>0</useXO>
<uClangAs>0</uClangAs>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
......
/*
* Auto generated Run-Time-Environment Component Configuration File
* Auto generated Run-Time-Environment Configuration File
* *** Do not modify ! ***
*
* Project: 'Lab4'
......@@ -11,4 +11,11 @@
#define RTE_COMPONENTS_H
/*
* Define the Device Header File:
*/
#define CMSIS_device_header "TM4C123.h"
#endif /* RTE_COMPONENTS_H */
......@@ -20,12 +20,32 @@
SysTick_Handler ; 1) Saves R0-R3,R12,LR,PC,PSR
CPSID I ; 2) Prevent interrupt during switch
;YOU IMPLEMENT THIS (same as Lab 3)
PUSH {R4-R11} ; 3) Save remaining regs r4-11
LDR R0, =RunPt ; 4) R0=pointer to RunPt, old thread
LDR R1, [R0] ; R1 = RunPt
STR SP, [R1] ; 5) Save SP into TCB
PUSH {R0,LR}
BL Scheduler
POP {R0,LR}
LDR R1, [R0] ; 6) R1 = RunPt, new thread
LDR SP, [R1] ; 7) new thread SP; SP = RunPt->sp;
POP {R4-R11} ; 8) restore regs r4-11
CPSIE I ; 9) tasks run with interrupts enabled
BX LR ; 10) restore R0-R3,R12,LR,PC,PSR
StartOS
;YOU IMPLEMENT THIS (same as Lab 3)
LDR R0, =RunPt ; Load addr of RunPt into R0
LDR R1, [R0] ; Load value of RunPt into R1
LDR SP, [R1] ; Load thread's SP from TCB into CPU SP
POP {R4-R11} ; Pop R4 - R11 from new SP (SP now points to R0 location)
POP {R0-R3} ; Pop R0 - R3 from SP (SP now points to R12 location)
POP {R12} ; Pop R12 (SP now points to LR (R14))
ADD SP, SP, #4 ; Skip LR by incrementing SP (SP now points to PC)
; - LR is invalid since this is the initial run
POP {LR} ; Pop PC (R15) into LR (SP now points to PSR)
; - PC should have already been initialized to start of tasks function
; - Popping directly into LR means that task will run when we BX LR
ADD SP, SP, #4 ; Skip PSR by incr. SP (SP now points to bottom of tasks stack)
CPSIE I ; Enable interrupts at processor level
BX LR ; start first thread
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment