/*
 * SPDX-FileCopyrightText: Sebastiano Barezzi
 * SPDX-License-Identifier: Apache-2.0
 */

package com.xyzshell.andinfo.libs.cpu.models

import com.xyzshell.andinfo.libs.cpu.models.Cache

/**
 * `struct cpuinfo_processor { struct {...} cache }`
 * 处理器缓存层次结构
 */
data class ProcessorCache(
    /**
     * Level 1 instruction cache
     * 一级指令缓存
     */
    val l1i: Cache?,
    /**
     * Level 1 data cache
     * 一级数据缓存
     */
    val l1d: Cache?,
    /**
     * Level 2 unified or data cache
     * 二级统一缓存或数据缓存
     */
    val l2: Cache?,
    /**
     * Level 3 unified or data cache
     * 三级统一缓存或数据缓存
     */
    val l3: Cache?,
    /**
     * Level 4 unified or data cache
     * 四级统一缓存或数据缓存
     */
    val l4: Cache?,
) {
    companion object {
        @JvmStatic
        fun fromCpuInfo(
            l1i: Cache?,
            l1d: Cache?,
            l2: Cache?,
            l3: Cache?,
            l4: Cache?,
        ) = ProcessorCache(
            l1i,
            l1d,
            l2,
            l3,
            l4,
        )
    }
}
