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

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

/**
 * `struct cpuinfo_tlb`
 * TLB（Translation Lookaside Buffer）转换后备缓冲区结构体
 */
data class Tlb(
    /**
     * TLB entries count
     * TLB条目数量
     */
    val entries: UInt,

    /**
     * Associativity of the TLB
     * TLB的关联度
     */
    val associativity: UInt,

    /**
     * Number of pages
     * 页面数量
     */
    val pages: ULong,
) {
    companion object {
        @JvmStatic
        fun fromCpuInfo(
            entries: Int,
            associativity: Int,
            pages: Long,
        ) = Tlb(
            entries.toUInt(),
            associativity.toUInt(),
            pages.toULong(),
        )
    }
}
