1# Resource 2 3## NAME 4 5resource - Address space rights and accounting 6 7## SYNOPSIS 8 9A resource is an immutable object that is used to validate access to syscalls 10that create objects backed by address space, or permit access to address space. 11These include [vm objects](vm_object.md), [interrupts](interrupts.md), and x86 12ioports. 13 14## DESCRIPTION 15 16Resources are used to gate access to specific regions of address space and are 17required to create VMOs and IRQs, as well as accessing x86 ioports. 18 19A resource object consists of a single resource *kind*, with *base* address and 20*len* parameters that define a range of address space the holder of the resource 21is granted access to. The range covers *base* up to but not including *base* + 22*len*. These objects are immutable after creation. Valid *kind* values are 23**ZX_RSRC_KIND_ROOT**, **ZX_RSRC_KIND_HYPERVISOR**, **ZX_RSRC_KIND_MMIO**, 24**ZX_RSRC_KIND_IOPORT**, **ZX_RSRC_KIND_IRQ**, **ZX_RSRC_KIND_VMEX**, and 25**ZX_RSRC_KIND_SMC**. New resources may be created with a root resource by 26calling [resource_create](../syscalls/resource_create.md). An initial root 27resource is created by the kernel during boot and handed off to the first 28userspace process started by userboot. 29 30Resource allocations can be either *shared* or *exclusive*. A shared resource 31grants the permission to access the given address space, but does not reserve 32that address space exclusively for the owner of the resource. An exclusive 33resource grants access to the region to only the holder of the exclusive 34resource. Exclusive and shared resource ranges may not overlap. 35 36Resources are lifecycle tracked and upon the last handle being closed will be 37freed. In the case of exclusive resources this means the given address range 38will be released back to the allocator for the given *kind* of resource. Objects 39created through a resource do not hold a reference to the resource and thus do 40not keep it alive. 41 42## NOTES 43 44Resources are typically private to the DDK and platform bus drivers. Presently, 45this means ACPI and platform bus hold the root resource respectively and hand 46out more fine-grained resources to other drivers. 47 48## SYSCALLS 49 50[interrupt_create](../syscalls/interrupt_create.md), 51[ioports_request](../syscalls/ioports_request.md), 52[resource_create](../syscalls/resource_create.md), 53[vmo_create_physical](../syscalls/vmo_create_physical.md) 54 55