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

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

/**
 * CPU物理封装信息
 */
data class Package(
    /**
     * SoC or processor chip model name
     * SoC或处理器芯片型号名称
     */
    val name: String,

    /**
     * Index of the first logical processor on this physical package
     * 此物理封装上第一个逻辑处理器的索引
     */
    val processorStart: UInt,

    /**
     * Number of logical processors on this physical package
     * 此物理封装上的逻辑处理器数量
     */
    val processorCount: UInt,

    /**
     * Index of the first core on this physical package
     * 此物理封装上第一个核心的索引
     */
    val coreStart: UInt,

    /**
     * Number of cores on this physical package
     * 此物理封装上的核心数量
     */
    val coreCount: UInt,

    /**
     * Index of the first cluster of cores on this physical package
     * 此物理封装上第一个核心集群的索引
     */
    val clusterStart: UInt,

    /**
     * Number of clusters of cores on this physical package
     * 此物理封装上的核心集群数量
     */
    val clusterCount: UInt,
) {
    companion object {
        @JvmStatic
        fun fromCpuInfo(
            name: String,
            processorStart: Int,
            processorCount: Int,
            coreStart: Int,
            coreCount: Int,
            clusterStart: Int,
            clusterCount: Int,
        ) = Package(
            name,
            processorStart.toUInt(),
            processorCount.toUInt(),
            coreStart.toUInt(),
            coreCount.toUInt(),
            clusterStart.toUInt(),
            clusterCount.toUInt(),
        )
    }
}
