File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 ExecLibraryStruct ,
88 StackSwapStruct ,
99 IORequestStruct ,
10+ MinListStruct ,
1011 MsgPortStruct ,
1112 NodeType ,
1213 SignalSemaphoreStruct ,
@@ -652,6 +653,22 @@ def WaitIO(self, ctx):
652653
653654 # ----- Nodes/Lists -----
654655
656+ def NewMinList (self , ctx ):
657+ minlist_addr = ctx .cpu .r_reg (REG_A0 )
658+ minlist = AccessStruct (ctx .mem , MinListStruct , minlist_addr )
659+ head_off = MinListStruct .sdef .find_field_def_by_name ("mlh_Head" ).offset
660+ tail_off = MinListStruct .sdef .find_field_def_by_name ("mlh_Tail" ).offset
661+ tailpred_off = MinListStruct .sdef .find_field_def_by_name (
662+ "mlh_TailPred"
663+ ).offset
664+ head_addr = minlist_addr + head_off
665+ tail_addr = minlist_addr + tail_off
666+ minlist .w_s ("mlh_Head" , tail_addr )
667+ minlist .w_s ("mlh_Tail" , 0 )
668+ minlist .w_s ("mlh_TailPred" , head_addr )
669+ log_exec .info ("NewMinList(0x%06x)" , minlist_addr )
670+ return minlist_addr
671+
655672 def AddTail (self , ctx , list : List , node : Node ):
656673 log_exec .info ("AddTail(%s, %s)" , list , node )
657674 list .add_tail (node )
Original file line number Diff line number Diff line change 11import pytest
22from amitools .vamos .libtypes import List , Node
3- from amitools .vamos .libstructs import NodeType
3+ from amitools .vamos .libstructs import MinListStruct , NodeType
44
55
66def pytask_exec_list_alloc_free_test (vamos_task ):
@@ -23,6 +23,33 @@ def task(ctx, task):
2323 assert exit_codes == [0 ]
2424
2525
26+ def pytask_exec_list_new_min_list_test (vamos_task ):
27+ def task (ctx , task ):
28+ exec_lib = ctx .proxies .get_exec_lib_proxy ()
29+
30+ minlist_mem = ctx .alloc .alloc_struct (MinListStruct )
31+ exec_lib .NewMinList (minlist_mem .addr )
32+
33+ head_off = MinListStruct .sdef .find_field_def_by_name ("mlh_Head" ).offset
34+ tail_off = MinListStruct .sdef .find_field_def_by_name ("mlh_Tail" ).offset
35+ tailpred_off = MinListStruct .sdef .find_field_def_by_name (
36+ "mlh_TailPred"
37+ ).offset
38+
39+ assert ctx .mem .r32 (minlist_mem .addr + head_off ) == minlist_mem .addr + tail_off
40+ assert ctx .mem .r32 (minlist_mem .addr + tail_off ) == 0
41+ assert (
42+ ctx .mem .r32 (minlist_mem .addr + tailpred_off )
43+ == minlist_mem .addr + head_off
44+ )
45+
46+ ctx .alloc .free_struct (minlist_mem )
47+ return 0
48+
49+ exit_codes = vamos_task .run ([task ])
50+ assert exit_codes == [0 ]
51+
52+
2653class ListHelper :
2754 def __init__ (self , alloc ):
2855 self .list = List .alloc (alloc )
You can’t perform that action at this time.
0 commit comments