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