sdfgen 0.17.0__cp39-cp39-macosx_14_0_arm64.whl → 0.18.0__cp39-cp39-macosx_14_0_arm64.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
Binary file
libcsdfgen.0.dylib CHANGED
Binary file
libcsdfgen.dylib CHANGED
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
5
+ cast, c_void_p, c_char_p, c_uint8, c_uint16, 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
@@ -60,7 +60,15 @@ libsdfgen.sdfgen_render.restype = c_char_p
60
60
  libsdfgen.sdfgen_render.argtypes = [c_void_p]
61
61
 
62
62
  libsdfgen.sdfgen_channel_create.restype = c_void_p
63
- libsdfgen.sdfgen_channel_create.argtypes = [c_void_p, c_void_p]
63
+ libsdfgen.sdfgen_channel_create.argtypes = [
64
+ c_void_p,
65
+ c_void_p,
66
+ POINTER(c_uint8),
67
+ POINTER(c_uint8),
68
+ POINTER(c_bool),
69
+ POINTER(c_bool),
70
+ POINTER(c_uint8),
71
+ ]
64
72
  libsdfgen.sdfgen_channel_destroy.restype = None
65
73
  libsdfgen.sdfgen_channel_destroy.argtypes = [c_void_p]
66
74
  libsdfgen.sdfgen_channel_get_pd_a_id.restype = c_uint8
@@ -77,6 +85,9 @@ libsdfgen.sdfgen_mr_create.restype = c_void_p
77
85
  libsdfgen.sdfgen_mr_create.argtypes = [c_char_p, c_uint64]
78
86
  libsdfgen.sdfgen_mr_create_physical.restype = c_void_p
79
87
  libsdfgen.sdfgen_mr_create_physical.argtypes = [c_char_p, c_uint64, c_uint64]
88
+ libsdfgen.sdfgen_mr_get_paddr.restype = c_bool;
89
+ libsdfgen.sdfgen_mr_get_paddr.argtypes = [c_void_p, POINTER(c_uint64)]
90
+
80
91
  libsdfgen.sdfgen_mr_destroy.restype = None
81
92
  libsdfgen.sdfgen_mr_destroy.argtypes = [c_void_p]
82
93
 
@@ -90,6 +101,9 @@ libsdfgen.sdfgen_vm_create.argtypes = [c_char_p, POINTER(c_void_p), c_uint32]
90
101
  libsdfgen.sdfgen_vm_destroy.restype = None
91
102
  libsdfgen.sdfgen_vm_destroy.argtypes = [c_void_p]
92
103
 
104
+ libsdfgen.sdfgen_vm_set_priority.restype = None
105
+ libsdfgen.sdfgen_vm_set_priority.argtypes = [c_void_p, c_uint8]
106
+
93
107
  libsdfgen.sdfgen_vm_add_map.restype = None
94
108
  libsdfgen.sdfgen_vm_add_map.argtypes = [c_void_p, c_void_p]
95
109
 
@@ -209,12 +223,20 @@ libsdfgen.sdfgen_vmm.argtypes = [
209
223
  libsdfgen.sdfgen_vmm_add_passthrough_device.restype = c_bool
210
224
  libsdfgen.sdfgen_vmm_add_passthrough_device.argtypes = [
211
225
  c_void_p,
212
- c_char_p,
226
+ c_void_p,
227
+ ]
228
+ libsdfgen.sdfgen_vmm_add_passthrough_device_regions.restype = c_bool
229
+ libsdfgen.sdfgen_vmm_add_passthrough_device_regions.argtypes = [
230
+ c_void_p,
213
231
  c_void_p,
214
232
  POINTER(c_uint8),
215
233
  c_uint8,
234
+ ]
235
+ libsdfgen.sdfgen_vmm_add_passthrough_device_irqs.argtypes = [
236
+ c_void_p,
237
+ c_void_p,
216
238
  POINTER(c_uint8),
217
- c_uint8
239
+ c_uint8,
218
240
  ]
219
241
  libsdfgen.sdfgen_vmm_add_passthrough_irq.restype = c_bool
220
242
  libsdfgen.sdfgen_vmm_add_passthrough_irq.argtypes = [c_void_p, c_void_p]
@@ -260,6 +282,27 @@ libsdfgen.sdfgen_sddf_lwip_connect.argtypes = [c_void_p]
260
282
  libsdfgen.sdfgen_sddf_lwip_serialise_config.restype = c_bool
261
283
  libsdfgen.sdfgen_sddf_lwip_serialise_config.argtypes = [c_void_p, c_char_p]
262
284
 
285
+ def ffi_uint8_ptr(n: Optional[int]):
286
+ """
287
+ Convert an int value to a uint8_t pointer for FFI.
288
+ If 'n' is None then we return None (which acts as a null pointer)
289
+ """
290
+ if n is None:
291
+ return None
292
+
293
+ return pointer(c_uint8(n))
294
+
295
+
296
+ def ffi_bool_ptr(val: Optional[bool]):
297
+ """
298
+ Convert a bool value to a bool pointer for FFI.
299
+ If 'val' is None then we return None (which acts as a null pointer)
300
+ """
301
+ if val is None:
302
+ return None
303
+
304
+ return pointer(c_bool(val))
305
+
263
306
 
264
307
  class DeviceTree:
265
308
  """
@@ -423,12 +466,14 @@ class SystemDescription:
423
466
  # TODO: error checking
424
467
  self._obj = libsdfgen.sdfgen_vm_vcpu_create(id, cpu)
425
468
 
426
- def __init__(self, name: str, vcpus: List[Vcpu]):
469
+ def __init__(self, name: str, vcpus: List[Vcpu], priority: Optional[int] = None):
427
470
  vcpus_tuple: Tuple[c_void_p] = tuple([vcpu._obj for vcpu in vcpus])
428
471
  c_vcpus = (c_void_p * len(vcpus))(*vcpus_tuple)
429
472
  c_name = c_char_p(name.encode("utf-8"))
430
473
  self._name = name
431
474
  self._obj = libsdfgen.sdfgen_vm_create(c_name, cast(c_vcpus, POINTER(c_void_p)), len(vcpus))
475
+ if priority is not None:
476
+ libsdfgen.sdfgen_vm_set_priority(self._obj, priority)
432
477
 
433
478
  @property
434
479
  def name(self) -> str:
@@ -487,6 +532,15 @@ class SystemDescription:
487
532
  else:
488
533
  self._obj = libsdfgen.sdfgen_mr_create(c_name, size)
489
534
 
535
+ @property
536
+ def paddr(self):
537
+ paddr = c_uint64(0)
538
+ has_paddr = libsdfgen.sdfgen_mr_get_paddr(self._obj, pointer(paddr))
539
+ if has_paddr:
540
+ return paddr
541
+ else:
542
+ return None
543
+
490
544
  def __del__(self):
491
545
  libsdfgen.sdfgen_mr_destroy(self._obj)
492
546
 
@@ -506,18 +560,36 @@ class SystemDescription:
506
560
  class Channel:
507
561
  _obj: c_void_p
508
562
 
509
- # TODO: handle options
510
563
  def __init__(
511
564
  self,
512
565
  a: SystemDescription.ProtectionDomain,
513
566
  b: SystemDescription.ProtectionDomain,
514
567
  *,
515
- pp_a=False,
516
- pp_b=False,
517
- notify_a=True,
518
- notify_b=True
568
+ a_id: Optional[int] = None,
569
+ b_id: Optional[int] = None,
570
+ pp_a: Optional[bool] = None,
571
+ pp_b: Optional[bool] = None,
572
+ notify_a: Optional[bool] = None,
573
+ notify_b: Optional[bool] = None,
519
574
  ) -> None:
520
- self._obj = libsdfgen.sdfgen_channel_create(a._obj, b._obj)
575
+ c_pp = None
576
+ if pp_a is not None:
577
+ c_pp = 0
578
+ elif pp_b is not None:
579
+ c_pp = 1
580
+
581
+ if pp_a is not None and pp_b is not None:
582
+ raise Exception("attempting to create channel with PP on both ends")
583
+
584
+ self._obj = libsdfgen.sdfgen_channel_create(
585
+ a._obj,
586
+ b._obj,
587
+ ffi_uint8_ptr(a_id),
588
+ ffi_uint8_ptr(b_id),
589
+ ffi_bool_ptr(notify_a),
590
+ ffi_bool_ptr(notify_b),
591
+ ffi_uint8_ptr(c_pp),
592
+ )
521
593
 
522
594
  @property
523
595
  def pd_a_id(self) -> int:
@@ -887,28 +959,36 @@ class Vmm:
887
959
 
888
960
  def add_passthrough_device(
889
961
  self,
890
- name: str,
891
962
  device: DeviceTree.Node,
892
963
  *,
893
964
  regions: Optional[List[int]] = None,
894
965
  irqs: Optional[List[int]] = None
895
966
  ):
896
- c_name = c_char_p(name.encode("utf-8"))
897
- if regions:
898
- c_regions = cast((c_uint8 * len(regions))(*regions), POINTER(c_uint8))
899
- regions_len = len(c_regions)
900
- else:
901
- c_regions = None
902
- regions_len = 0
903
-
904
- if irqs:
967
+ """
968
+ Add pass-through access to a particular device based on its DTB node.
969
+ :param regions: list of indices into the 'reg' field of the device to be mapped in. If None
970
+ then every region passed through.
971
+ :param irqs: list of indices into the 'interrupts' field of the device to be created. If None
972
+ then every IRQ is passed through.
973
+ """
974
+ if regions is None and irqs is None:
975
+ # If the user passed None, that means we need to map everything in
976
+ return libsdfgen.sdfgen_vmm_add_passthrough_device(self._obj, device._obj)
977
+ elif irqs is not None:
978
+ # Pass through specific IRQs, all regions
905
979
  c_irqs = cast((c_uint8 * len(irqs))(*irqs), POINTER(c_uint8))
906
- irqs_len = len(c_irqs)
980
+ 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)
983
+ elif regions is not None:
984
+ # Pass through specific regions, all IRQs
985
+ c_regions = cast((c_uint8 * len(regions))(*regions), POINTER(c_uint8))
986
+ 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)
907
989
  else:
908
- c_irqs = None
909
- irqs_len = 0
910
-
911
- return libsdfgen.sdfgen_vmm_add_passthrough_device(self._obj, c_name, device._obj, c_regions, regions_len, c_irqs, irqs_len)
990
+ # unreachable case
991
+ raise Exception("internal error")
912
992
 
913
993
  def add_passthrough_irq(self, irq: SystemDescription.Irq):
914
994
  return libsdfgen.sdfgen_vmm_add_passthrough_irq(self._obj, irq._obj)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: sdfgen
3
- Version: 0.17.0
3
+ Version: 0.18.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
+ csdfgen.cpython-39-darwin.so,sha256=51jeaoQJZIMspeWLzFOeVz8k5Mrw9Bt9N6Ps-8vjSH8,759816
2
+ libcsdfgen.0.18.0.dylib,sha256=51jeaoQJZIMspeWLzFOeVz8k5Mrw9Bt9N6Ps-8vjSH8,759816
3
+ libcsdfgen.0.dylib,sha256=51jeaoQJZIMspeWLzFOeVz8k5Mrw9Bt9N6Ps-8vjSH8,759816
4
+ libcsdfgen.dylib,sha256=51jeaoQJZIMspeWLzFOeVz8k5Mrw9Bt9N6Ps-8vjSH8,759816
5
+ sdfgen/__init__.py,sha256=_d7GGV8GhadIAEYP8uiJlez0yKtXnHMHdRkRzVMKS3c,143
6
+ sdfgen/module.py,sha256=lDfOUdrj6Sw-Aw8dxjtNLrsxYa8K1ZNzyuR0rifcVqQ,40387
7
+ sdfgen/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ sdfgen-0.18.0.dist-info/METADATA,sha256=-tM82ZmR6CcgqMTq0QyMw5-1QxbNjfDgB_eVRnA81c0,4654
9
+ sdfgen-0.18.0.dist-info/WHEEL,sha256=qunz9sw_Sj_qUmhefgl7DsymeMLSrLPGiTm3YSd2wdo,107
10
+ sdfgen-0.18.0.dist-info/top_level.txt,sha256=M3gUW9vTMij10peQKgv1Qs0jZkdsk_PG0REFxuv6jNY,15
11
+ sdfgen-0.18.0.dist-info/RECORD,,
libcsdfgen.0.17.0.dylib DELETED
Binary file
@@ -1,11 +0,0 @@
1
- csdfgen.cpython-39-darwin.so,sha256=tIosKsFLrP17i6nHsAi1YwUi5zepW-4SoIW-DRVIzCc,759144
2
- libcsdfgen.0.17.0.dylib,sha256=tIosKsFLrP17i6nHsAi1YwUi5zepW-4SoIW-DRVIzCc,759144
3
- libcsdfgen.0.dylib,sha256=tIosKsFLrP17i6nHsAi1YwUi5zepW-4SoIW-DRVIzCc,759144
4
- libcsdfgen.dylib,sha256=tIosKsFLrP17i6nHsAi1YwUi5zepW-4SoIW-DRVIzCc,759144
5
- sdfgen/__init__.py,sha256=_d7GGV8GhadIAEYP8uiJlez0yKtXnHMHdRkRzVMKS3c,143
6
- sdfgen/module.py,sha256=43JZjSFFzMDoYd0r_O26HFVsfFyzgh1r51bkbzkVA20,37296
7
- sdfgen/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- sdfgen-0.17.0.dist-info/METADATA,sha256=pofeKoD0ElzkpumR1NqPDjFJsAjP9WZmmPfhX3QdGeQ,4654
9
- sdfgen-0.17.0.dist-info/WHEEL,sha256=qunz9sw_Sj_qUmhefgl7DsymeMLSrLPGiTm3YSd2wdo,107
10
- sdfgen-0.17.0.dist-info/top_level.txt,sha256=M3gUW9vTMij10peQKgv1Qs0jZkdsk_PG0REFxuv6jNY,15
11
- sdfgen-0.17.0.dist-info/RECORD,,