xref: /qemu/rust/hw/char/pl011/src/device.rs (revision d1f27ae9ca1c87268b97741c0a2560baa7be4c8b)
1 // Copyright 2024, Linaro Limited
2 // Author(s): Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
3 // SPDX-License-Identifier: GPL-2.0-or-later
4 
5 use core::ptr::{addr_of, addr_of_mut, NonNull};
6 use std::{
7     ffi::CStr,
8     os::raw::{c_int, c_uint, c_void},
9 };
10 
11 use qemu_api::{
12     bindings::{
13         error_fatal, hwaddr, memory_region_init_io, qdev_init_clock_in, qdev_new,
14         qdev_prop_set_chr, qemu_chr_fe_ioctl, qemu_chr_fe_set_handlers, qemu_chr_fe_write_all,
15         qemu_irq, sysbus_connect_irq, sysbus_mmio_map, sysbus_realize_and_unref, CharBackend,
16         Chardev, Clock, ClockEvent, MemoryRegion, QEMUChrEvent, CHR_IOCTL_SERIAL_SET_BREAK,
17     },
18     c_str, impl_vmstate_forward,
19     irq::InterruptSource,
20     prelude::*,
21     qdev::{DeviceImpl, DeviceState, Property},
22     qom::{ClassInitImpl, ObjectImpl, ParentField},
23     sysbus::{SysBusDevice, SysBusDeviceClass},
24     vmstate::VMStateDescription,
25 };
26 
27 use crate::{
28     device_class,
29     memory_ops::PL011_OPS,
30     registers::{self, Interrupt},
31     RegisterOffset,
32 };
33 
34 /// Integer Baud Rate Divider, `UARTIBRD`
35 const IBRD_MASK: u32 = 0xffff;
36 
37 /// Fractional Baud Rate Divider, `UARTFBRD`
38 const FBRD_MASK: u32 = 0x3f;
39 
40 /// QEMU sourced constant.
41 pub const PL011_FIFO_DEPTH: u32 = 16;
42 
43 #[derive(Clone, Copy)]
44 struct DeviceId(&'static [u8; 8]);
45 
46 impl std::ops::Index<hwaddr> for DeviceId {
47     type Output = u8;
48 
49     fn index(&self, idx: hwaddr) -> &Self::Output {
50         &self.0[idx as usize]
51     }
52 }
53 
54 impl DeviceId {
55     const ARM: Self = Self(&[0x11, 0x10, 0x14, 0x00, 0x0d, 0xf0, 0x05, 0xb1]);
56     const LUMINARY: Self = Self(&[0x11, 0x00, 0x18, 0x01, 0x0d, 0xf0, 0x05, 0xb1]);
57 }
58 
59 // FIFOs use 32-bit indices instead of usize, for compatibility with
60 // the migration stream produced by the C version of this device.
61 #[repr(transparent)]
62 #[derive(Debug, Default)]
63 pub struct Fifo([registers::Data; PL011_FIFO_DEPTH as usize]);
64 impl_vmstate_forward!(Fifo);
65 
66 impl Fifo {
67     const fn len(&self) -> u32 {
68         self.0.len() as u32
69     }
70 }
71 
72 impl std::ops::IndexMut<u32> for Fifo {
73     fn index_mut(&mut self, idx: u32) -> &mut Self::Output {
74         &mut self.0[idx as usize]
75     }
76 }
77 
78 impl std::ops::Index<u32> for Fifo {
79     type Output = registers::Data;
80 
81     fn index(&self, idx: u32) -> &Self::Output {
82         &self.0[idx as usize]
83     }
84 }
85 
86 #[repr(C)]
87 #[derive(Debug, qemu_api_macros::Object, qemu_api_macros::offsets)]
88 /// PL011 Device Model in QEMU
89 pub struct PL011State {
90     pub parent_obj: ParentField<SysBusDevice>,
91     pub iomem: MemoryRegion,
92     #[doc(alias = "fr")]
93     pub flags: registers::Flags,
94     #[doc(alias = "lcr")]
95     pub line_control: registers::LineControl,
96     #[doc(alias = "rsr")]
97     pub receive_status_error_clear: registers::ReceiveStatusErrorClear,
98     #[doc(alias = "cr")]
99     pub control: registers::Control,
100     pub dmacr: u32,
101     pub int_enabled: u32,
102     pub int_level: u32,
103     pub read_fifo: Fifo,
104     pub ilpr: u32,
105     pub ibrd: u32,
106     pub fbrd: u32,
107     pub ifl: u32,
108     pub read_pos: u32,
109     pub read_count: u32,
110     pub read_trigger: u32,
111     #[doc(alias = "chr")]
112     pub char_backend: CharBackend,
113     /// QEMU interrupts
114     ///
115     /// ```text
116     ///  * sysbus MMIO region 0: device registers
117     ///  * sysbus IRQ 0: `UARTINTR` (combined interrupt line)
118     ///  * sysbus IRQ 1: `UARTRXINTR` (receive FIFO interrupt line)
119     ///  * sysbus IRQ 2: `UARTTXINTR` (transmit FIFO interrupt line)
120     ///  * sysbus IRQ 3: `UARTRTINTR` (receive timeout interrupt line)
121     ///  * sysbus IRQ 4: `UARTMSINTR` (momem status interrupt line)
122     ///  * sysbus IRQ 5: `UARTEINTR` (error interrupt line)
123     /// ```
124     #[doc(alias = "irq")]
125     pub interrupts: [InterruptSource; IRQMASK.len()],
126     #[doc(alias = "clk")]
127     pub clock: NonNull<Clock>,
128     #[doc(alias = "migrate_clk")]
129     pub migrate_clock: bool,
130 }
131 
132 qom_isa!(PL011State : SysBusDevice, DeviceState, Object);
133 
134 #[repr(C)]
135 pub struct PL011Class {
136     parent_class: <SysBusDevice as ObjectType>::Class,
137     /// The byte string that identifies the device.
138     device_id: DeviceId,
139 }
140 
141 unsafe impl ObjectType for PL011State {
142     type Class = PL011Class;
143     const TYPE_NAME: &'static CStr = crate::TYPE_PL011;
144 }
145 
146 impl ClassInitImpl<PL011Class> for PL011State {
147     fn class_init(klass: &mut PL011Class) {
148         klass.device_id = DeviceId::ARM;
149         <Self as ClassInitImpl<SysBusDeviceClass>>::class_init(&mut klass.parent_class);
150     }
151 }
152 
153 impl ObjectImpl for PL011State {
154     type ParentType = SysBusDevice;
155 
156     const INSTANCE_INIT: Option<unsafe fn(&mut Self)> = Some(Self::init);
157     const INSTANCE_POST_INIT: Option<fn(&Self)> = Some(Self::post_init);
158 }
159 
160 impl DeviceImpl for PL011State {
161     fn properties() -> &'static [Property] {
162         &device_class::PL011_PROPERTIES
163     }
164     fn vmsd() -> Option<&'static VMStateDescription> {
165         Some(&device_class::VMSTATE_PL011)
166     }
167     const REALIZE: Option<fn(&Self)> = Some(Self::realize);
168     const RESET: Option<fn(&mut Self)> = Some(Self::reset);
169 }
170 
171 impl PL011State {
172     /// Initializes a pre-allocated, unitialized instance of `PL011State`.
173     ///
174     /// # Safety
175     ///
176     /// `self` must point to a correctly sized and aligned location for the
177     /// `PL011State` type. It must not be called more than once on the same
178     /// location/instance. All its fields are expected to hold unitialized
179     /// values with the sole exception of `parent_obj`.
180     unsafe fn init(&mut self) {
181         const CLK_NAME: &CStr = c_str!("clk");
182 
183         // SAFETY:
184         //
185         // self and self.iomem are guaranteed to be valid at this point since callers
186         // must make sure the `self` reference is valid.
187         unsafe {
188             memory_region_init_io(
189                 addr_of_mut!(self.iomem),
190                 addr_of_mut!(*self).cast::<Object>(),
191                 &PL011_OPS,
192                 addr_of_mut!(*self).cast::<c_void>(),
193                 Self::TYPE_NAME.as_ptr(),
194                 0x1000,
195             );
196         }
197 
198         // SAFETY:
199         //
200         // self.clock is not initialized at this point; but since `NonNull<_>` is Copy,
201         // we can overwrite the undefined value without side effects. This is
202         // safe since all PL011State instances are created by QOM code which
203         // calls this function to initialize the fields; therefore no code is
204         // able to access an invalid self.clock value.
205         unsafe {
206             let dev: &mut DeviceState = self.upcast_mut();
207             self.clock = NonNull::new(qdev_init_clock_in(
208                 dev,
209                 CLK_NAME.as_ptr(),
210                 None, /* pl011_clock_update */
211                 addr_of_mut!(*self).cast::<c_void>(),
212                 ClockEvent::ClockUpdate.0,
213             ))
214             .unwrap();
215         }
216     }
217 
218     fn post_init(&self) {
219         self.init_mmio(&self.iomem);
220         for irq in self.interrupts.iter() {
221             self.init_irq(irq);
222         }
223     }
224 
225     pub fn read(&mut self, offset: hwaddr, _size: c_uint) -> std::ops::ControlFlow<u64, u64> {
226         use RegisterOffset::*;
227 
228         let value = match RegisterOffset::try_from(offset) {
229             Err(v) if (0x3f8..0x400).contains(&(v >> 2)) => {
230                 let device_id = self.get_class().device_id;
231                 u32::from(device_id[(offset - 0xfe0) >> 2])
232             }
233             Err(_) => {
234                 // qemu_log_mask(LOG_GUEST_ERROR, "pl011_read: Bad offset 0x%x\n", (int)offset);
235                 0
236             }
237             Ok(DR) => {
238                 self.flags.set_receive_fifo_full(false);
239                 let c = self.read_fifo[self.read_pos];
240                 if self.read_count > 0 {
241                     self.read_count -= 1;
242                     self.read_pos = (self.read_pos + 1) & (self.fifo_depth() - 1);
243                 }
244                 if self.read_count == 0 {
245                     self.flags.set_receive_fifo_empty(true);
246                 }
247                 if self.read_count + 1 == self.read_trigger {
248                     self.int_level &= !registers::INT_RX;
249                 }
250                 // Update error bits.
251                 self.receive_status_error_clear.set_from_data(c);
252                 self.update();
253                 // Must call qemu_chr_fe_accept_input, so return Continue:
254                 let c = u32::from(c);
255                 return std::ops::ControlFlow::Continue(u64::from(c));
256             }
257             Ok(RSR) => u32::from(self.receive_status_error_clear),
258             Ok(FR) => u32::from(self.flags),
259             Ok(FBRD) => self.fbrd,
260             Ok(ILPR) => self.ilpr,
261             Ok(IBRD) => self.ibrd,
262             Ok(LCR_H) => u32::from(self.line_control),
263             Ok(CR) => u32::from(self.control),
264             Ok(FLS) => self.ifl,
265             Ok(IMSC) => self.int_enabled,
266             Ok(RIS) => self.int_level,
267             Ok(MIS) => self.int_level & self.int_enabled,
268             Ok(ICR) => {
269                 // "The UARTICR Register is the interrupt clear register and is write-only"
270                 // Source: ARM DDI 0183G 3.3.13 Interrupt Clear Register, UARTICR
271                 0
272             }
273             Ok(DMACR) => self.dmacr,
274         };
275         std::ops::ControlFlow::Break(value.into())
276     }
277 
278     pub fn write(&mut self, offset: hwaddr, value: u64) {
279         // eprintln!("write offset {offset} value {value}");
280         use RegisterOffset::*;
281         let value: u32 = value as u32;
282         match RegisterOffset::try_from(offset) {
283             Err(_bad_offset) => {
284                 eprintln!("write bad offset {offset} value {value}");
285             }
286             Ok(DR) => {
287                 // ??? Check if transmitter is enabled.
288                 let ch: u8 = value as u8;
289                 // XXX this blocks entire thread. Rewrite to use
290                 // qemu_chr_fe_write and background I/O callbacks
291 
292                 // SAFETY: self.char_backend is a valid CharBackend instance after it's been
293                 // initialized in realize().
294                 unsafe {
295                     qemu_chr_fe_write_all(addr_of_mut!(self.char_backend), &ch, 1);
296                 }
297                 self.loopback_tx(value);
298                 self.int_level |= registers::INT_TX;
299                 self.update();
300             }
301             Ok(RSR) => {
302                 self.receive_status_error_clear.reset();
303             }
304             Ok(FR) => {
305                 // flag writes are ignored
306             }
307             Ok(ILPR) => {
308                 self.ilpr = value;
309             }
310             Ok(IBRD) => {
311                 self.ibrd = value;
312             }
313             Ok(FBRD) => {
314                 self.fbrd = value;
315             }
316             Ok(LCR_H) => {
317                 let new_val: registers::LineControl = value.into();
318                 // Reset the FIFO state on FIFO enable or disable
319                 if self.line_control.fifos_enabled() != new_val.fifos_enabled() {
320                     self.reset_rx_fifo();
321                     self.reset_tx_fifo();
322                 }
323                 if self.line_control.send_break() ^ new_val.send_break() {
324                     let mut break_enable: c_int = new_val.send_break().into();
325                     // SAFETY: self.char_backend is a valid CharBackend instance after it's been
326                     // initialized in realize().
327                     unsafe {
328                         qemu_chr_fe_ioctl(
329                             addr_of_mut!(self.char_backend),
330                             CHR_IOCTL_SERIAL_SET_BREAK as i32,
331                             addr_of_mut!(break_enable).cast::<c_void>(),
332                         );
333                     }
334                     self.loopback_break(break_enable > 0);
335                 }
336                 self.line_control = new_val;
337                 self.set_read_trigger();
338             }
339             Ok(CR) => {
340                 // ??? Need to implement the enable bit.
341                 self.control = value.into();
342                 self.loopback_mdmctrl();
343             }
344             Ok(FLS) => {
345                 self.ifl = value;
346                 self.set_read_trigger();
347             }
348             Ok(IMSC) => {
349                 self.int_enabled = value;
350                 self.update();
351             }
352             Ok(RIS) => {}
353             Ok(MIS) => {}
354             Ok(ICR) => {
355                 self.int_level &= !value;
356                 self.update();
357             }
358             Ok(DMACR) => {
359                 self.dmacr = value;
360                 if value & 3 > 0 {
361                     // qemu_log_mask(LOG_UNIMP, "pl011: DMA not implemented\n");
362                     eprintln!("pl011: DMA not implemented");
363                 }
364             }
365         }
366     }
367 
368     #[inline]
369     fn loopback_tx(&mut self, value: u32) {
370         if !self.loopback_enabled() {
371             return;
372         }
373 
374         // Caveat:
375         //
376         // In real hardware, TX loopback happens at the serial-bit level
377         // and then reassembled by the RX logics back into bytes and placed
378         // into the RX fifo. That is, loopback happens after TX fifo.
379         //
380         // Because the real hardware TX fifo is time-drained at the frame
381         // rate governed by the configured serial format, some loopback
382         // bytes in TX fifo may still be able to get into the RX fifo
383         // that could be full at times while being drained at software
384         // pace.
385         //
386         // In such scenario, the RX draining pace is the major factor
387         // deciding which loopback bytes get into the RX fifo, unless
388         // hardware flow-control is enabled.
389         //
390         // For simplicity, the above described is not emulated.
391         self.put_fifo(value);
392     }
393 
394     fn loopback_mdmctrl(&mut self) {
395         if !self.loopback_enabled() {
396             return;
397         }
398 
399         /*
400          * Loopback software-driven modem control outputs to modem status inputs:
401          *   FR.RI  <= CR.Out2
402          *   FR.DCD <= CR.Out1
403          *   FR.CTS <= CR.RTS
404          *   FR.DSR <= CR.DTR
405          *
406          * The loopback happens immediately even if this call is triggered
407          * by setting only CR.LBE.
408          *
409          * CTS/RTS updates due to enabled hardware flow controls are not
410          * dealt with here.
411          */
412 
413         self.flags.set_ring_indicator(self.control.out_2());
414         self.flags.set_data_carrier_detect(self.control.out_1());
415         self.flags.set_clear_to_send(self.control.request_to_send());
416         self.flags
417             .set_data_set_ready(self.control.data_transmit_ready());
418 
419         // Change interrupts based on updated FR
420         let mut il = self.int_level;
421 
422         il &= !Interrupt::MS;
423 
424         if self.flags.data_set_ready() {
425             il |= Interrupt::DSR as u32;
426         }
427         if self.flags.data_carrier_detect() {
428             il |= Interrupt::DCD as u32;
429         }
430         if self.flags.clear_to_send() {
431             il |= Interrupt::CTS as u32;
432         }
433         if self.flags.ring_indicator() {
434             il |= Interrupt::RI as u32;
435         }
436         self.int_level = il;
437         self.update();
438     }
439 
440     fn loopback_break(&mut self, enable: bool) {
441         if enable {
442             self.loopback_tx(registers::Data::BREAK.into());
443         }
444     }
445 
446     fn set_read_trigger(&mut self) {
447         self.read_trigger = 1;
448     }
449 
450     pub fn realize(&self) {
451         // SAFETY: self.char_backend has the correct size and alignment for a
452         // CharBackend object, and its callbacks are of the correct types.
453         unsafe {
454             qemu_chr_fe_set_handlers(
455                 addr_of!(self.char_backend) as *mut CharBackend,
456                 Some(pl011_can_receive),
457                 Some(pl011_receive),
458                 Some(pl011_event),
459                 None,
460                 addr_of!(*self).cast::<c_void>() as *mut c_void,
461                 core::ptr::null_mut(),
462                 true,
463             );
464         }
465     }
466 
467     pub fn reset(&mut self) {
468         self.line_control.reset();
469         self.receive_status_error_clear.reset();
470         self.dmacr = 0;
471         self.int_enabled = 0;
472         self.int_level = 0;
473         self.ilpr = 0;
474         self.ibrd = 0;
475         self.fbrd = 0;
476         self.read_trigger = 1;
477         self.ifl = 0x12;
478         self.control.reset();
479         self.flags.reset();
480         self.reset_rx_fifo();
481         self.reset_tx_fifo();
482     }
483 
484     pub fn reset_rx_fifo(&mut self) {
485         self.read_count = 0;
486         self.read_pos = 0;
487 
488         // Reset FIFO flags
489         self.flags.set_receive_fifo_full(false);
490         self.flags.set_receive_fifo_empty(true);
491     }
492 
493     pub fn reset_tx_fifo(&mut self) {
494         // Reset FIFO flags
495         self.flags.set_transmit_fifo_full(false);
496         self.flags.set_transmit_fifo_empty(true);
497     }
498 
499     pub fn can_receive(&self) -> bool {
500         // trace_pl011_can_receive(s->lcr, s->read_count, r);
501         self.read_count < self.fifo_depth()
502     }
503 
504     pub fn event(&mut self, event: QEMUChrEvent) {
505         if event == QEMUChrEvent::CHR_EVENT_BREAK && !self.loopback_enabled() {
506             self.put_fifo(registers::Data::BREAK.into());
507         }
508     }
509 
510     #[inline]
511     pub fn fifo_enabled(&self) -> bool {
512         self.line_control.fifos_enabled() == registers::Mode::FIFO
513     }
514 
515     #[inline]
516     pub fn loopback_enabled(&self) -> bool {
517         self.control.enable_loopback()
518     }
519 
520     #[inline]
521     pub fn fifo_depth(&self) -> u32 {
522         // Note: FIFO depth is expected to be power-of-2
523         if self.fifo_enabled() {
524             return PL011_FIFO_DEPTH;
525         }
526         1
527     }
528 
529     pub fn put_fifo(&mut self, value: c_uint) {
530         let depth = self.fifo_depth();
531         assert!(depth > 0);
532         let slot = (self.read_pos + self.read_count) & (depth - 1);
533         self.read_fifo[slot] = registers::Data::from(value);
534         self.read_count += 1;
535         self.flags.set_receive_fifo_empty(false);
536         if self.read_count == depth {
537             self.flags.set_receive_fifo_full(true);
538         }
539 
540         if self.read_count == self.read_trigger {
541             self.int_level |= registers::INT_RX;
542             self.update();
543         }
544     }
545 
546     pub fn update(&self) {
547         let flags = self.int_level & self.int_enabled;
548         for (irq, i) in self.interrupts.iter().zip(IRQMASK) {
549             irq.set(flags & i != 0);
550         }
551     }
552 
553     pub fn post_load(&mut self, _version_id: u32) -> Result<(), ()> {
554         /* Sanity-check input state */
555         if self.read_pos >= self.read_fifo.len() || self.read_count > self.read_fifo.len() {
556             return Err(());
557         }
558 
559         if !self.fifo_enabled() && self.read_count > 0 && self.read_pos > 0 {
560             // Older versions of PL011 didn't ensure that the single
561             // character in the FIFO in FIFO-disabled mode is in
562             // element 0 of the array; convert to follow the current
563             // code's assumptions.
564             self.read_fifo[0] = self.read_fifo[self.read_pos];
565             self.read_pos = 0;
566         }
567 
568         self.ibrd &= IBRD_MASK;
569         self.fbrd &= FBRD_MASK;
570 
571         Ok(())
572     }
573 }
574 
575 /// Which bits in the interrupt status matter for each outbound IRQ line ?
576 const IRQMASK: [u32; 6] = [
577     /* combined IRQ */
578     Interrupt::E
579         | Interrupt::MS
580         | Interrupt::RT as u32
581         | Interrupt::TX as u32
582         | Interrupt::RX as u32,
583     Interrupt::RX as u32,
584     Interrupt::TX as u32,
585     Interrupt::RT as u32,
586     Interrupt::MS,
587     Interrupt::E,
588 ];
589 
590 /// # Safety
591 ///
592 /// We expect the FFI user of this function to pass a valid pointer, that has
593 /// the same size as [`PL011State`]. We also expect the device is
594 /// readable/writeable from one thread at any time.
595 pub unsafe extern "C" fn pl011_can_receive(opaque: *mut c_void) -> c_int {
596     let state = NonNull::new(opaque).unwrap().cast::<PL011State>();
597     unsafe { state.as_ref().can_receive().into() }
598 }
599 
600 /// # Safety
601 ///
602 /// We expect the FFI user of this function to pass a valid pointer, that has
603 /// the same size as [`PL011State`]. We also expect the device is
604 /// readable/writeable from one thread at any time.
605 ///
606 /// The buffer and size arguments must also be valid.
607 pub unsafe extern "C" fn pl011_receive(opaque: *mut c_void, buf: *const u8, size: c_int) {
608     let mut state = NonNull::new(opaque).unwrap().cast::<PL011State>();
609     unsafe {
610         if state.as_ref().loopback_enabled() {
611             return;
612         }
613         if size > 0 {
614             debug_assert!(!buf.is_null());
615             state.as_mut().put_fifo(c_uint::from(buf.read_volatile()))
616         }
617     }
618 }
619 
620 /// # Safety
621 ///
622 /// We expect the FFI user of this function to pass a valid pointer, that has
623 /// the same size as [`PL011State`]. We also expect the device is
624 /// readable/writeable from one thread at any time.
625 pub unsafe extern "C" fn pl011_event(opaque: *mut c_void, event: QEMUChrEvent) {
626     let mut state = NonNull::new(opaque).unwrap().cast::<PL011State>();
627     unsafe { state.as_mut().event(event) }
628 }
629 
630 /// # Safety
631 ///
632 /// We expect the FFI user of this function to pass a valid pointer for `chr`.
633 #[no_mangle]
634 pub unsafe extern "C" fn pl011_create(
635     addr: u64,
636     irq: qemu_irq,
637     chr: *mut Chardev,
638 ) -> *mut DeviceState {
639     unsafe {
640         let dev: *mut DeviceState = qdev_new(PL011State::TYPE_NAME.as_ptr());
641         let sysbus: *mut SysBusDevice = dev.cast::<SysBusDevice>();
642 
643         qdev_prop_set_chr(dev, c_str!("chardev").as_ptr(), chr);
644         sysbus_realize_and_unref(sysbus, addr_of_mut!(error_fatal));
645         sysbus_mmio_map(sysbus, 0, addr);
646         sysbus_connect_irq(sysbus, 0, irq);
647         dev
648     }
649 }
650 
651 #[repr(C)]
652 #[derive(Debug, qemu_api_macros::Object)]
653 /// PL011 Luminary device model.
654 pub struct PL011Luminary {
655     parent_obj: ParentField<PL011State>,
656 }
657 
658 impl ClassInitImpl<PL011Class> for PL011Luminary {
659     fn class_init(klass: &mut PL011Class) {
660         klass.device_id = DeviceId::LUMINARY;
661         <Self as ClassInitImpl<SysBusDeviceClass>>::class_init(&mut klass.parent_class);
662     }
663 }
664 
665 qom_isa!(PL011Luminary : PL011State, SysBusDevice, DeviceState, Object);
666 
667 unsafe impl ObjectType for PL011Luminary {
668     type Class = <PL011State as ObjectType>::Class;
669     const TYPE_NAME: &'static CStr = crate::TYPE_PL011_LUMINARY;
670 }
671 
672 impl ObjectImpl for PL011Luminary {
673     type ParentType = PL011State;
674 }
675 
676 impl DeviceImpl for PL011Luminary {}
677