Skip to content

Commit

Permalink
update osek code generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Chalandi committed Oct 3, 2024
1 parent cd3c665 commit ebf4794
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 31 deletions.
53 changes: 31 additions & 22 deletions Code/OSEK/Generator/Gen/osGenCfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
// Generator : OilGenTool
//
// Generation Time : 01.10.2024 05:18:06
// Generation Time : 03.10.2024 22:30:35
//
// Description : Auto-generated OS Configuration file please do not modify it manually !!!
//
Expand All @@ -26,20 +26,20 @@
//=============================================================================
/*
OS:
╒════════╤═════════════════════════════════╕
│ Name │ Properties │
╞════════╪═════════════════════════════════╡
MyOSEK │ OsMulticore = TRUE
│ │ OsStartupHook = TRUE │
│ │ OsErrorHook = TRUE │
│ │ OsShutdownHook = TRUE │
│ │ OsPreTaskHook = TRUE │
│ │ OsPostTaskHook = TRUE │
│ │ OsStackCheck = TRUE │
│ │ OsCpuFrequency = 16.000000 │
│ │ OsMaxVectorEntries = 113 │
│ │ OsTickTime = 1000 │
╘════════╧═════════════════════════════════╛
╒══════════╤═════════════════════════════════╕
│ Name │ Properties │
╞══════════╪═════════════════════════════════╡
SysconOS │ OsMulticore = None
│ OsStartupHook = TRUE │
│ OsErrorHook = TRUE │
│ OsShutdownHook = TRUE │
│ OsPreTaskHook = TRUE │
│ OsPostTaskHook = TRUE │
│ OsStackCheck = TRUE │
│ OsCpuFrequency = 16.000000 │
│ OsMaxVectorEntries = 113 │
│ OsTickTime = 1000 │
╘══════════╧═════════════════════════════════╛
Tasks:
╒═══════════════╤════════╤════════════╤════════════╤══════════════╤═════════════╤══════════════╤════════════════════╕
Expand Down Expand Up @@ -140,11 +140,15 @@
╒═════════╤════════════╤══════════╤════════╤═══════════╕
│ Name │ Category │ Vector │ Prio │ Nesting │
╞═════════╪════════════╪══════════╪════════╪═══════════╡
│ ISR_000 │ 2 │ 0 │ 0 │ FALSE │
│ ISR_000 │ 2 │ 0 │ 7 │ FALSE │
├─────────┼────────────┼──────────┼────────┼───────────┤
│ ISR_001 │ 2 │ 1 │ 0 │ FALSE │
│ ISR_001 │ 2 │ 1 │ 6 │ FALSE │
├─────────┼────────────┼──────────┼────────┼───────────┤
│ ISR_010 │ 1 │ 10 │ 12 │ FALSE │
├─────────┼────────────┼──────────┼────────┼───────────┤
│ ISR_011 │ 1 │ 11 │ 16 │ FALSE │
╘═════════╧════════════╧══════════╧════════╧═══════════╛
Total number of used interrupts: 2
Total number of used interrupts: 4
Total number of CPU interrupts : 113
*/

Expand Down Expand Up @@ -193,8 +197,8 @@ OS_CONFIG_BEGIN
// Interrupts Configuration
//=============================================================================
OS_INTERRUPT_BEGIN
OS_INTERRUPT_CAT2_DEF(ISR_000, 0, NOT_NESTED) /* Interrupt vector 0 */
OS_INTERRUPT_CAT2_DEF(ISR_001, 0, NOT_NESTED) /* Interrupt vector 1 */
OS_INTERRUPT_CAT2_DEF(ISR_000, 7, NOT_NESTED) /* Interrupt vector 0 */
OS_INTERRUPT_CAT2_DEF(ISR_001, 6, NOT_NESTED) /* Interrupt vector 1 */
OS_INTERRUPT_CAT2_DEF(Undefined, 0, NOT_NESTED) /* Interrupt vector 2 */
OS_INTERRUPT_CAT2_DEF(Undefined, 0, NOT_NESTED) /* Interrupt vector 3 */
OS_INTERRUPT_CAT2_DEF(Undefined, 0, NOT_NESTED) /* Interrupt vector 4 */
Expand All @@ -203,8 +207,8 @@ OS_CONFIG_BEGIN
OS_INTERRUPT_CAT2_DEF(Undefined, 0, NOT_NESTED) /* Interrupt vector 7 */
OS_INTERRUPT_CAT2_DEF(Undefined, 0, NOT_NESTED) /* Interrupt vector 8 */
OS_INTERRUPT_CAT2_DEF(Undefined, 0, NOT_NESTED) /* Interrupt vector 9 */
OS_INTERRUPT_CAT2_DEF(Undefined, 0, NOT_NESTED) /* Interrupt vector 10 */
OS_INTERRUPT_CAT2_DEF(Undefined, 0, NOT_NESTED) /* Interrupt vector 11 */
OS_INTERRUPT_CAT1_DEF(ISR_010, 12, NOT_NESTED) /* Interrupt vector 10 */
OS_INTERRUPT_CAT1_DEF(ISR_011, 16, NOT_NESTED) /* Interrupt vector 11 */
OS_INTERRUPT_CAT2_DEF(Undefined, 0, NOT_NESTED) /* Interrupt vector 12 */
OS_INTERRUPT_CAT2_DEF(Undefined, 0, NOT_NESTED) /* Interrupt vector 13 */
OS_INTERRUPT_CAT2_DEF(Undefined, 0, NOT_NESTED) /* Interrupt vector 14 */
Expand Down Expand Up @@ -325,4 +329,9 @@ OS_CONFIG_BEGIN
#define OsMaxVectorEntries() 113
#define OsTickTime() 1000

//=============================================================================
// Interrupt Mask Configuration
//=============================================================================
#define OS_INT_CAT1_LOWEST_PRIO_LEVEL 12

OS_CONFIG_END
12 changes: 7 additions & 5 deletions Code/OSEK/Generator/Gen/osek.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ <h1 style="color:black;">OSEK OS OBJECTS SUMMARY</h1>
<p style="font-size: 24px;">OS Objects:</p>
<table>
<thead>
<tr><th>Name </th><th>Properties </th></tr>
<tr><th>Name </th><th>Properties </th></tr>
</thead>
<tbody>
<tr><td>MyOSEK</td><td>OsMulticore = TRUE
<tr><td>SysconOS</td><td>OsMulticore = None
OsStartupHook = TRUE
OsErrorHook = TRUE
OsShutdownHook = TRUE
Expand Down Expand Up @@ -150,11 +150,13 @@ <h1 style="color:black;">OSEK OS OBJECTS SUMMARY</h1>
<tr><th>Name </th><th style="text-align: right;"> Category</th><th style="text-align: right;"> Vector</th><th style="text-align: right;"> Prio</th><th>Nesting </th></tr>
</thead>
<tbody>
<tr><td>ISR_000</td><td style="text-align: right;"> 2</td><td style="text-align: right;"> 0</td><td style="text-align: right;"> 0</td><td>FALSE </td></tr>
<tr><td>ISR_001</td><td style="text-align: right;"> 2</td><td style="text-align: right;"> 1</td><td style="text-align: right;"> 0</td><td>FALSE </td></tr>
<tr><td>ISR_000</td><td style="text-align: right;"> 2</td><td style="text-align: right;"> 0</td><td style="text-align: right;"> 7</td><td>FALSE </td></tr>
<tr><td>ISR_001</td><td style="text-align: right;"> 2</td><td style="text-align: right;"> 1</td><td style="text-align: right;"> 6</td><td>FALSE </td></tr>
<tr><td>ISR_010</td><td style="text-align: right;"> 1</td><td style="text-align: right;"> 10</td><td style="text-align: right;"> 12</td><td>FALSE </td></tr>
<tr><td>ISR_011</td><td style="text-align: right;"> 1</td><td style="text-align: right;"> 11</td><td style="text-align: right;"> 16</td><td>FALSE </td></tr>
</tbody>
</table>
<b> Total number of used interrupts: 2 and Total number of CPU interrupts : 113 </b>
<b> Total number of used interrupts: 4 and Total number of CPU interrupts : 113 </b>
</body>
</html>

19 changes: 19 additions & 0 deletions Code/OSEK/Generator/MyOilGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,25 @@ class Color:
# Add "RES_SCHEDULER" on top of PrioritiesList
PrioritiesList.append([OilResources.ResourcesList[OilResources.ResourcesTotalNumber - 1][0], OilResources.ResourcesList[OilResources.ResourcesTotalNumber - 1][1]])

##################################################################################################
# Calculate interrupt cat1 prio mask
##################################################################################################
IntCat1LowPrio = 0xffffffff
IntCat2HighPrio = 0
for IntIdx in range(OilInterrupts.InterruptsTotalNumber):
IntCatType = OilInterrupts.InterruptsList[IntIdx][1]
Intprio = OilInterrupts.InterruptsList[IntIdx][3]
if(IntCatType == '1' and int(Intprio) < IntCat1LowPrio):
IntCat1LowPrio = int(Intprio)
elif(IntCatType == '2' and int(Intprio) > IntCat2HighPrio):
IntCat2HighPrio = int(Intprio)
if(IntCat1LowPrio < IntCat2HighPrio):
print("Error: The lowest cat1 prio is lower than highest cat2 prio !!!")
print(f" IntCat1LowPrio = {IntCat1LowPrio}, IntCat2HighPrio = {IntCat2HighPrio}")
quit()
else:
OilInterrupts.InterruptCat1LowestPrio = IntCat1LowPrio

# Code Generation
if (args.gen_folder != None):
OilCodeGen.OsConfigCodeGeneration(args,
Expand Down
8 changes: 6 additions & 2 deletions Code/OSEK/Generator/OilCodeGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def OsConfigCodeGeneration(args, OilOs,
int_nest = "NOT_NESTED" if OilInterrupts.InterruptsList[VectorDataIdx][4] == "FALSE" else "NESTED"
OsGenCfgHeaderFile.write(f" OS_INTERRUPT_CAT{int_cat}_DEF({int_name}, {int_prio}, {int_nest}) /* Interrupt vector {vector} */\n")
else:
OsGenCfgHeaderFile.write(f" OS_INTERRUPT_CAT{int_cat}_DEF(Undefined, {int_prio}, {int_nest}) /* Interrupt vector {vector} */\n")
OsGenCfgHeaderFile.write(f" OS_INTERRUPT_CAT2_DEF(Undefined, 0, NOT_NESTED) /* Interrupt vector {vector} */\n")

OsGenCfgHeaderFile.write(" OS_INTERRUPT_END\n")
OsGenCfgHeaderFile.write("\n")
Expand All @@ -188,6 +188,10 @@ def OsConfigCodeGeneration(args, OilOs,
OsGenCfgHeaderFile.write(f" #define OsMaxVectorEntries() {OilOs.OsMaxVectorEntries }\n")
OsGenCfgHeaderFile.write(f" #define OsTickTime() {OilOs.OsTickTime }\n")
OsGenCfgHeaderFile.write("\n")

OsGenCfgHeaderFile.write(" //=============================================================================\n")
OsGenCfgHeaderFile.write(" // Interrupt Mask Configuration\n")
OsGenCfgHeaderFile.write(" //=============================================================================\n")
OsGenCfgHeaderFile.write(f" #define OS_INT_CAT1_LOWEST_PRIO_LEVEL {OilInterrupts.InterruptCat1LowestPrio}\n")
OsGenCfgHeaderFile.write("\n")
OsGenCfgHeaderFile.write("OS_CONFIG_END\n")
OsGenCfgHeaderFile.close()
5 changes: 3 additions & 2 deletions Code/OSEK/Generator/OilInterrupts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from tabulate import tabulate

# Globals
InterruptsTotalNumber = 0
InterruptsList = []
InterruptsTotalNumber = 0
InterruptCat1LowestPrio = 0
InterruptsList = []

def OilInterruptsParser(args, Oilfile):

Expand Down
16 changes: 16 additions & 0 deletions Code/OSEK/Generator/myOilFile.oil
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,22 @@ CPU RP2350 {
ISR ISR_001 {
CATEGORY = 2;
VectorAddress = 1;
Nesting = FALSE;
Priority = 6;
};

ISR ISR_010 {
CATEGORY = 1;
VectorAddress = 10;
Nesting = FALSE;
Priority = 12;
};

ISR ISR_011 {
CATEGORY = 1;
VectorAddress = 11;
Nesting = FALSE;
Priority = 16;
};

};

0 comments on commit ebf4794

Please sign in to comment.