You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: cpu.rs
    path of file: ./repos/core-os-riscv/kernel/src/process
    
    the code of the file until where you have to start completion: // Copyright (c) 2020 Alex Chi
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT

use super::{Process, TrapFrame, Context};
use alloc::boxed::Box;
use core::mem::MaybeUninit;
use core::cell::UnsafeCell;
use crate::{arch, panic};
use crate::arch::hart_id;

/// Holding CPU
    
    pub fn lock(&mut self) -> IntrLockGuard {
        let enabled = arch::intr_get();
        arch::intr_off();
        unsafe {
            if *self.cnt.get() == 0 {
                self.is_enabled_before = enabled;
                self.hart_id = arch::hart_id();
            } else {
                if enabled {
                    panic!("lock held but intr enabled");
                }
                if self.hart_id != arch::hart_id() {
                    panic!("lock on different hart");
                }
            }
            *self.cnt.get() += 1;
            IntrLockGuard { lock: self }
        }
    }