1 // Copyright 2016 The Fuchsia Authors
2 //
3 // Use of this source code is governed by a MIT-style
4 // license that can be found in the LICENSE file or at
5 // https://opensource.org/licenses/MIT
6 
7 #include <object/virtual_interrupt_dispatcher.h>
8 
9 #include <kernel/auto_lock.h>
10 #include <dev/interrupt.h>
11 #include <zircon/rights.h>
12 #include <fbl/alloc_checker.h>
13 #include <fbl/auto_lock.h>
14 #include <fbl/mutex.h>
15 #include <platform.h>
16 
Create(fbl::RefPtr<Dispatcher> * dispatcher,zx_rights_t * rights,uint32_t options)17 zx_status_t VirtualInterruptDispatcher::Create(fbl::RefPtr<Dispatcher>* dispatcher,
18                                                zx_rights_t* rights,
19                                                uint32_t options) {
20 
21     if (options != ZX_INTERRUPT_VIRTUAL)
22         return ZX_ERR_INVALID_ARGS;
23 
24     // Attempt to construct the dispatcher.
25     fbl::AllocChecker ac;
26     VirtualInterruptDispatcher* disp = new (&ac) VirtualInterruptDispatcher();
27     if (!ac.check())
28         return ZX_ERR_NO_MEMORY;
29 
30     // Hold a ref while we check to see if someone else owns this vector or not.
31     // If things go wrong, this ref will be released and the IED will get
32     // cleaned up automatically.
33     auto disp_ref = fbl::AdoptRef<Dispatcher>(disp);
34 
35     disp->set_flags(INTERRUPT_VIRTUAL);
36 
37     // Transfer control of the new dispatcher to the creator and we are done.
38     *rights = default_rights();
39     *dispatcher = ktl::move(disp_ref);
40 
41     return ZX_OK;
42 }
43 
44 //void VirtualInterruptDispatcher::IrqHandler(void* ctx) { }
45 
MaskInterrupt()46 void VirtualInterruptDispatcher::MaskInterrupt() { }
47 
UnmaskInterrupt()48 void VirtualInterruptDispatcher::UnmaskInterrupt() { }
49 
UnregisterInterruptHandler()50 void VirtualInterruptDispatcher::UnregisterInterruptHandler() { }
51