sdfgen 0.19.0__cp311-cp311-musllinux_1_2_x86_64.whl → 0.20.0__cp311-cp311-musllinux_1_2_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
libcsdfgen.so CHANGED
Binary file
libcsdfgen.so.0 CHANGED
Binary file
libcsdfgen.so.0.20.0 ADDED
Binary file
sdfgen/module.py CHANGED
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
  import ctypes
3
3
  import importlib.util
4
4
  from ctypes import (
5
- cast, c_void_p, c_char_p, c_uint8, c_uint16, c_uint32, c_uint64, c_bool, POINTER, byref, pointer
5
+ cast, c_void_p, c_char_p, c_int8, c_uint8, c_uint32, c_uint64, c_bool, POINTER, byref, pointer
6
6
  )
7
7
  from typing import Optional, List, Tuple
8
8
  from enum import IntEnum
@@ -85,14 +85,14 @@ libsdfgen.sdfgen_mr_create.restype = c_void_p
85
85
  libsdfgen.sdfgen_mr_create.argtypes = [c_char_p, c_uint64]
86
86
  libsdfgen.sdfgen_mr_create_physical.restype = c_void_p
87
87
  libsdfgen.sdfgen_mr_create_physical.argtypes = [c_char_p, c_uint64, c_uint64]
88
- libsdfgen.sdfgen_mr_get_paddr.restype = c_bool;
88
+ libsdfgen.sdfgen_mr_get_paddr.restype = c_bool
89
89
  libsdfgen.sdfgen_mr_get_paddr.argtypes = [c_void_p, POINTER(c_uint64)]
90
90
 
91
91
  libsdfgen.sdfgen_mr_destroy.restype = None
92
92
  libsdfgen.sdfgen_mr_destroy.argtypes = [c_void_p]
93
93
 
94
94
  libsdfgen.sdfgen_irq_create.restype = c_void_p
95
- libsdfgen.sdfgen_irq_create.argtypes = [c_uint32]
95
+ libsdfgen.sdfgen_irq_create.argtypes = [c_uint32, POINTER(c_uint32), POINTER(c_uint8)]
96
96
  libsdfgen.sdfgen_irq_destroy.restype = None
97
97
  libsdfgen.sdfgen_irq_destroy.argtypes = [c_void_p]
98
98
 
@@ -108,7 +108,7 @@ libsdfgen.sdfgen_vm_add_map.restype = None
108
108
  libsdfgen.sdfgen_vm_add_map.argtypes = [c_void_p, c_void_p]
109
109
 
110
110
  libsdfgen.sdfgen_vm_vcpu_create.restype = c_void_p
111
- libsdfgen.sdfgen_vm_vcpu_create.argtypes = [c_uint8, c_uint16]
111
+ libsdfgen.sdfgen_vm_vcpu_create.argtypes = [c_uint8, POINTER(c_uint8)]
112
112
  libsdfgen.sdfgen_vm_vcpu_destroy.restype = None
113
113
  libsdfgen.sdfgen_vm_vcpu_destroy.argtypes = [c_void_p]
114
114
 
@@ -117,11 +117,11 @@ libsdfgen.sdfgen_pd_create.argtypes = [c_char_p, c_char_p]
117
117
  libsdfgen.sdfgen_pd_destroy.restype = None
118
118
  libsdfgen.sdfgen_pd_destroy.argtypes = [c_void_p]
119
119
 
120
- libsdfgen.sdfgen_pd_add_child.restype = c_uint8
120
+ libsdfgen.sdfgen_pd_add_child.restype = c_int8
121
121
  libsdfgen.sdfgen_pd_add_child.argtypes = [c_void_p, c_void_p, POINTER(c_uint8)]
122
122
  libsdfgen.sdfgen_pd_add_map.restype = None
123
123
  libsdfgen.sdfgen_pd_add_map.argtypes = [c_void_p, c_void_p]
124
- libsdfgen.sdfgen_pd_add_irq.restype = c_uint8
124
+ libsdfgen.sdfgen_pd_add_irq.restype = c_int8
125
125
  libsdfgen.sdfgen_pd_add_irq.argtypes = [c_void_p, c_void_p]
126
126
 
127
127
  libsdfgen.sdfgen_sddf_timer.restype = c_void_p
@@ -165,7 +165,7 @@ libsdfgen.sdfgen_sddf_blk_serialise_config.restype = c_bool
165
165
  libsdfgen.sdfgen_sddf_blk_serialise_config.argtypes = [c_void_p, c_char_p]
166
166
 
167
167
  libsdfgen.sdfgen_sddf_serial.restype = c_void_p
168
- libsdfgen.sdfgen_sddf_serial.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_void_p]
168
+ libsdfgen.sdfgen_sddf_serial.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_bool]
169
169
  libsdfgen.sdfgen_sddf_serial_destroy.restype = None
170
170
  libsdfgen.sdfgen_sddf_serial_destroy.argtypes = [c_void_p]
171
171
 
@@ -274,6 +274,14 @@ libsdfgen.sdfgen_lionsos_fs_nfs_connect.restype = c_bool
274
274
  libsdfgen.sdfgen_lionsos_fs_nfs_connect.argtypes = [c_void_p]
275
275
  libsdfgen.sdfgen_lionsos_fs_nfs_serialise_config.restype = c_bool
276
276
  libsdfgen.sdfgen_lionsos_fs_nfs_serialise_config.argtypes = [c_void_p, c_char_p]
277
+ libsdfgen.sdfgen_lionsos_fs_nfs_destroy.restype = None
278
+ libsdfgen.sdfgen_lionsos_fs_nfs_destroy.argtypes = [c_void_p]
279
+ libsdfgen.sdfgen_lionsos_fs_vmfs.restype = c_void_p
280
+ libsdfgen.sdfgen_lionsos_fs_vmfs.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_uint32]
281
+ libsdfgen.sdfgen_lionsos_fs_vmfs_connect.restype = c_bool
282
+ libsdfgen.sdfgen_lionsos_fs_vmfs_connect.argtypes = [c_void_p]
283
+ libsdfgen.sdfgen_lionsos_fs_vmfs_serialise_config.restype = c_bool
284
+ libsdfgen.sdfgen_lionsos_fs_vmfs_serialise_config.argtypes = [c_void_p, c_char_p]
277
285
 
278
286
  libsdfgen.sdfgen_sddf_lwip.restype = c_void_p
279
287
  libsdfgen.sdfgen_sddf_lwip.argtypes = [c_void_p, c_void_p, c_void_p]
@@ -282,6 +290,7 @@ libsdfgen.sdfgen_sddf_lwip_connect.argtypes = [c_void_p]
282
290
  libsdfgen.sdfgen_sddf_lwip_serialise_config.restype = c_bool
283
291
  libsdfgen.sdfgen_sddf_lwip_serialise_config.argtypes = [c_void_p, c_char_p]
284
292
 
293
+
285
294
  def ffi_uint8_ptr(n: Optional[int]):
286
295
  """
287
296
  Convert an int value to a uint8_t pointer for FFI.
@@ -293,6 +302,17 @@ def ffi_uint8_ptr(n: Optional[int]):
293
302
  return pointer(c_uint8(n))
294
303
 
295
304
 
305
+ def ffi_uint32_ptr(n: Optional[int]):
306
+ """
307
+ Convert an int value to a uint32_t pointer for FFI.
308
+ If 'n' is None then we return None (which acts as a null pointer)
309
+ """
310
+ if n is None:
311
+ return None
312
+
313
+ return pointer(c_uint32(n))
314
+
315
+
296
316
  def ffi_bool_ptr(val: Optional[bool]):
297
317
  """
298
318
  Convert a bool value to a bool pointer for FFI.
@@ -430,19 +450,23 @@ class SystemDescription:
430
450
  """
431
451
  c_child_id = byref(c_uint8(child_id)) if child_id else None
432
452
 
433
- returned_id = libsdfgen.sdfgen_pd_add_child(self._obj, child_pd._obj, c_child_id)
434
- if returned_id is None:
435
- raise Exception("Could not allocate child PD ID")
453
+ id = libsdfgen.sdfgen_pd_add_child(self._obj, child_pd._obj, c_child_id)
454
+ if id < 0:
455
+ raise Exception(f"failed to add child to PD '{self.name}'")
436
456
 
437
457
  self._child_pds.append(child_pd)
438
458
 
439
- return returned_id
459
+ return id
440
460
 
441
461
  def add_map(self, map: SystemDescription.Map):
442
462
  libsdfgen.sdfgen_pd_add_map(self._obj, map._obj)
443
463
 
444
464
  def add_irq(self, irq: SystemDescription.Irq) -> int:
445
- return libsdfgen.sdfgen_pd_add_irq(self._obj, irq._obj)
465
+ id = libsdfgen.sdfgen_pd_add_irq(self._obj, irq._obj)
466
+ if id < 0:
467
+ raise Exception(f"failed to add IRQ to PD '{self.name}'")
468
+
469
+ return id
446
470
 
447
471
  def set_virtual_machine(self, vm: SystemDescription.VirtualMachine):
448
472
  ret = libsdfgen.sdfgen_pd_set_virtual_machine(self._obj, vm._obj)
@@ -462,9 +486,8 @@ class SystemDescription:
462
486
  _obj: c_void_p
463
487
 
464
488
  class Vcpu:
465
- def __init__(self, *, id: int, cpu: Optional[int] = 0):
466
- # TODO: error checking
467
- self._obj = libsdfgen.sdfgen_vm_vcpu_create(id, cpu)
489
+ def __init__(self, *, id: int, cpu: Optional[int] = None):
490
+ self._obj = libsdfgen.sdfgen_vm_vcpu_create(id, ffi_uint8_ptr(cpu))
468
491
 
469
492
  def __init__(self, name: str, vcpus: List[Vcpu], priority: Optional[int] = None):
470
493
  vcpus_tuple: Tuple[c_void_p] = tuple([vcpu._obj for vcpu in vcpus])
@@ -472,6 +495,8 @@ class SystemDescription:
472
495
  c_name = c_char_p(name.encode("utf-8"))
473
496
  self._name = name
474
497
  self._obj = libsdfgen.sdfgen_vm_create(c_name, cast(c_vcpus, POINTER(c_void_p)), len(vcpus))
498
+ if self._obj is None:
499
+ raise Exception("failed to create VM")
475
500
  if priority is not None:
476
501
  libsdfgen.sdfgen_vm_set_priority(self._obj, priority)
477
502
 
@@ -514,6 +539,8 @@ class SystemDescription:
514
539
  cached: bool = True,
515
540
  ) -> None:
516
541
  self._obj = libsdfgen.sdfgen_map_create(mr._obj, vaddr, perms._to_c_bindings(), cached)
542
+ if self._obj is None:
543
+ raise Exception("failed to create mapping")
517
544
 
518
545
  class MemoryRegion:
519
546
  _obj: c_void_p
@@ -547,12 +574,19 @@ class SystemDescription:
547
574
  class Irq:
548
575
  _obj: c_void_p
549
576
 
550
- # TODO: handle options
577
+ class Trigger(IntEnum):
578
+ EDGE = 0,
579
+ LEVEL = 1,
580
+
551
581
  def __init__(
552
582
  self,
553
583
  irq: int,
584
+ trigger: Optional[Trigger] = None,
585
+ id: Optional[int] = None,
554
586
  ):
555
- self._obj = libsdfgen.sdfgen_irq_create(irq)
587
+ self._obj = libsdfgen.sdfgen_irq_create(irq, ffi_uint32_ptr(trigger), ffi_uint8_ptr(id))
588
+ if self._obj is None:
589
+ raise Exception("failed to create IRQ")
556
590
 
557
591
  def __del__(self):
558
592
  libsdfgen.sdfgen_irq_destroy(self._obj)
@@ -590,6 +624,8 @@ class SystemDescription:
590
624
  ffi_bool_ptr(notify_b),
591
625
  ffi_uint8_ptr(c_pp),
592
626
  )
627
+ if self._obj is None:
628
+ raise Exception("failed to create channel")
593
629
 
594
630
  @property
595
631
  def pd_a_id(self) -> int:
@@ -660,7 +696,8 @@ class Sddf:
660
696
  driver: SystemDescription.ProtectionDomain,
661
697
  virt_tx: SystemDescription.ProtectionDomain,
662
698
  *,
663
- virt_rx: Optional[SystemDescription.ProtectionDomain] = None
699
+ virt_rx: Optional[SystemDescription.ProtectionDomain] = None,
700
+ enable_color: bool = True
664
701
  ) -> None:
665
702
  if device is None:
666
703
  device_obj = None
@@ -673,8 +710,10 @@ class Sddf:
673
710
  virt_rx_obj = virt_rx._obj
674
711
 
675
712
  self._obj = libsdfgen.sdfgen_sddf_serial(
676
- sdf._obj, device_obj, driver._obj, virt_tx._obj, virt_rx_obj
713
+ sdf._obj, device_obj, driver._obj, virt_tx._obj, virt_rx_obj, c_bool(enable_color)
677
714
  )
715
+ if self._obj is None:
716
+ raise Exception("failed to create serial system")
678
717
 
679
718
  def add_client(self, client: SystemDescription.ProtectionDomain):
680
719
  """Add a new client connection to the serial system."""
@@ -760,6 +799,8 @@ class Sddf:
760
799
  device_obj = device._obj
761
800
 
762
801
  self._obj = libsdfgen.sdfgen_sddf_blk(sdf._obj, device_obj, driver._obj, virt._obj)
802
+ if self._obj is None:
803
+ raise Exception("failed to create blk system")
763
804
 
764
805
  def add_client(self, client: SystemDescription.ProtectionDomain, *, partition: int):
765
806
  ret = libsdfgen.sdfgen_sddf_blk_add_client(self._obj, client._obj, partition)
@@ -978,14 +1019,14 @@ class Vmm:
978
1019
  # Pass through specific IRQs, all regions
979
1020
  c_irqs = cast((c_uint8 * len(irqs))(*irqs), POINTER(c_uint8))
980
1021
  irqs_len = len(irqs)
981
- ret = libsdfgen.sdfgen_vmm_add_passthrough_device_irqs(self._obj, device._obj, c_irqs, irqs_len)
982
- ret = libsdfgen.sdfgen_vmm_add_passthrough_device_regions(self._obj, device._obj, None, 0)
1022
+ assert libsdfgen.sdfgen_vmm_add_passthrough_device_irqs(self._obj, device._obj, c_irqs, irqs_len)
1023
+ assert libsdfgen.sdfgen_vmm_add_passthrough_device_regions(self._obj, device._obj, None, 0)
983
1024
  elif regions is not None:
984
1025
  # Pass through specific regions, all IRQs
985
1026
  c_regions = cast((c_uint8 * len(regions))(*regions), POINTER(c_uint8))
986
1027
  regions_len = len(regions)
987
- ret = libsdfgen.sdfgen_vmm_add_passthrough_device_regions(self._obj, device._obj, c_regions, regions_len)
988
- ret = libsdfgen.sdfgen_vmm_add_passthrough_device_irqs(self._obj, device._obj, None, 0)
1028
+ assert libsdfgen.sdfgen_vmm_add_passthrough_device_regions(self._obj, device._obj, c_regions, regions_len)
1029
+ assert libsdfgen.sdfgen_vmm_add_passthrough_device_irqs(self._obj, device._obj, None, 0)
989
1030
  else:
990
1031
  # unreachable case
991
1032
  raise Exception("internal error")
@@ -1040,8 +1081,15 @@ class LionsOs:
1040
1081
  blk: Sddf.Blk,
1041
1082
  partition: int,
1042
1083
  ):
1084
+ if partition < 0:
1085
+ raise Exception(
1086
+ f"block partition cannot be negative, given partition '{partition}'"
1087
+ )
1088
+
1043
1089
  assert isinstance(blk, Sddf.Blk)
1044
1090
  self._obj = libsdfgen.sdfgen_lionsos_fs_fat(sdf._obj, fs._obj, client._obj, blk._obj, partition)
1091
+ if self._obj is None:
1092
+ raise Exception("failed to create FAT file system")
1045
1093
 
1046
1094
  def connect(self) -> bool:
1047
1095
  return libsdfgen.sdfgen_lionsos_fs_fat_connect(self._obj)
@@ -1093,9 +1141,53 @@ class LionsOs:
1093
1141
  c_export_path
1094
1142
  )
1095
1143
 
1144
+ def __del__(self):
1145
+ libsdfgen.sdfgen_lionsos_fs_nfs_destroy(self._obj)
1146
+
1096
1147
  def connect(self) -> bool:
1097
1148
  return libsdfgen.sdfgen_lionsos_fs_nfs_connect(self._obj)
1098
1149
 
1099
1150
  def serialise_config(self, output_dir: str) -> bool:
1100
1151
  c_output_dir = c_char_p(output_dir.encode("utf-8"))
1101
1152
  return libsdfgen.sdfgen_lionsos_fs_nfs_serialise_config(self._obj, c_output_dir)
1153
+
1154
+ class VmFs:
1155
+ _obj: c_void_p
1156
+
1157
+ def __init__(
1158
+ self,
1159
+ sdf: SystemDescription,
1160
+ fs_vm_sys: Vmm,
1161
+ client: SystemDescription.ProtectionDomain,
1162
+ blk: Sddf.Blk,
1163
+ virtio_device: DeviceTree.Node,
1164
+ partition: int,
1165
+ ):
1166
+ if partition < 0:
1167
+ raise Exception(
1168
+ f"block partition cannot be negative, given partition '{partition}'"
1169
+ )
1170
+
1171
+ assert isinstance(sdf, SystemDescription)
1172
+ assert isinstance(fs_vm_sys, Vmm)
1173
+ assert isinstance(client, SystemDescription.ProtectionDomain)
1174
+ assert isinstance(blk, Sddf.Blk)
1175
+ assert isinstance(virtio_device, DeviceTree.Node)
1176
+
1177
+ self._obj = libsdfgen.sdfgen_lionsos_fs_vmfs(
1178
+ sdf._obj,
1179
+ fs_vm_sys._obj,
1180
+ client._obj,
1181
+ blk._obj,
1182
+ virtio_device._obj,
1183
+ partition
1184
+ )
1185
+ if self._obj is None:
1186
+ raise Exception("failed to create VmFs file system")
1187
+
1188
+ def connect(self) -> bool:
1189
+ return libsdfgen.sdfgen_lionsos_fs_vmfs_connect(self._obj)
1190
+
1191
+ def serialise_config(self, output_dir: str) -> bool:
1192
+ c_output_dir = c_char_p(output_dir.encode("utf-8"))
1193
+ return libsdfgen.sdfgen_lionsos_fs_vmfs_serialise_config(self._obj, c_output_dir)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sdfgen
3
- Version: 0.19.0
3
+ Version: 0.20.0
4
4
  Summary: Automating the creation of Microkit System Description Files (SDF)
5
5
  Home-page: https://github.com/au-ts/microkit_sdf_gen
6
6
  Description-Content-Type: text/markdown
@@ -0,0 +1,11 @@
1
+ libcsdfgen.so,sha256=Wf-86oXH19MWleNmIF4f7cnCo42d54_PKV8DWmrzVVU,4489224
2
+ libcsdfgen.so.0.20.0,sha256=Wf-86oXH19MWleNmIF4f7cnCo42d54_PKV8DWmrzVVU,4489224
3
+ csdfgen.cpython-311-x86_64-linux-musl.so,sha256=Wf-86oXH19MWleNmIF4f7cnCo42d54_PKV8DWmrzVVU,4489224
4
+ libcsdfgen.so.0,sha256=Wf-86oXH19MWleNmIF4f7cnCo42d54_PKV8DWmrzVVU,4489224
5
+ sdfgen/module.py,sha256=BRjpYkhAag_2Ry4hDMNMBHi1-9HJjvBhj57y3dEA6ZE,44091
6
+ sdfgen/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ sdfgen/__init__.py,sha256=_d7GGV8GhadIAEYP8uiJlez0yKtXnHMHdRkRzVMKS3c,143
8
+ sdfgen-0.20.0.dist-info/WHEEL,sha256=-1lvUTC7ROIbUsEGXToEoCN9w6fPmW3brF2b0tYIqSQ,112
9
+ sdfgen-0.20.0.dist-info/RECORD,,
10
+ sdfgen-0.20.0.dist-info/top_level.txt,sha256=M3gUW9vTMij10peQKgv1Qs0jZkdsk_PG0REFxuv6jNY,15
11
+ sdfgen-0.20.0.dist-info/METADATA,sha256=iruA0Ngm1RLGO0XmC2nyXpbECVILDAvsji4aDX4t8QM,4563
libcsdfgen.so.0.19.0 DELETED
Binary file
@@ -1,11 +0,0 @@
1
- libcsdfgen.so,sha256=Oifg46dv7xcbHS9Ohqt_r0u6aM2j5CHOUkbQkdWpW2Q,4214168
2
- libcsdfgen.so.0.19.0,sha256=Oifg46dv7xcbHS9Ohqt_r0u6aM2j5CHOUkbQkdWpW2Q,4214168
3
- libcsdfgen.so.0,sha256=Oifg46dv7xcbHS9Ohqt_r0u6aM2j5CHOUkbQkdWpW2Q,4214168
4
- csdfgen.cpython-311-x86_64-linux-musl.so,sha256=Oifg46dv7xcbHS9Ohqt_r0u6aM2j5CHOUkbQkdWpW2Q,4214168
5
- sdfgen/__init__.py,sha256=_d7GGV8GhadIAEYP8uiJlez0yKtXnHMHdRkRzVMKS3c,143
6
- sdfgen/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- sdfgen/module.py,sha256=lDfOUdrj6Sw-Aw8dxjtNLrsxYa8K1ZNzyuR0rifcVqQ,40387
8
- sdfgen-0.19.0.dist-info/WHEEL,sha256=-1lvUTC7ROIbUsEGXToEoCN9w6fPmW3brF2b0tYIqSQ,112
9
- sdfgen-0.19.0.dist-info/METADATA,sha256=BYvsmL_UXkw0L9zsDoXJvrR5HOBUXIlYu_PjXwu4z-Q,4563
10
- sdfgen-0.19.0.dist-info/top_level.txt,sha256=M3gUW9vTMij10peQKgv1Qs0jZkdsk_PG0REFxuv6jNY,15
11
- sdfgen-0.19.0.dist-info/RECORD,,