Skip to content

Commit

Permalink
Table definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
phaubertin committed Jan 21, 2025
1 parent b118e64 commit 9f21896
Show file tree
Hide file tree
Showing 2 changed files with 231 additions and 0 deletions.
116 changes: 116 additions & 0 deletions include/kernel/infrastructure/i686/asm/mp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
* Copyright (C) 2025 Philippe Aubertin.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the author nor the names of other contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef JINUE_KERNEL_INFRASTRUCTURE_I686_ASM_MP_H
#define JINUE_KERNEL_INFRASTRUCTURE_I686_ASM_MP_H

/* Multiprocessor Specification 1.4 section 4.1 MP Floating Pointer
* Structure */

#define MP_FLOATING_PTR_SIGNATURE "_MP_"


#define MP_FEATURE2_IMCRP (1 << 7)

/* Multiprocessor Specification 1.4 section 4.2 MP Configuration Table
* Header */

#define MP_CONF_TABLE_SIGNATURE "PCMP"

/* Multiprocessor Specification 1.4 Table 4-3 Base MP Configuration Table Entry
* Types */

#define MP_ENTRY_TYPE_PROCESSOR 0

#define MP_ENTRY_TYPE_BUS 1

#define MP_ENTRY_TYPE_IO_APIC 2

#define MP_ENTRY_TYPE_IO_INTR 3

#define MP_ENTRY_TYPE_LOCAL_INTR 4

/* Multiprocessor Specification 1.4 Table 4-8 Bus Type String Values */

#define MP_BUS_TYPE_EISA "EISA"

#define MP_BUS_TYPE_ISA "ISA"

#define MP_BUS_TYPE_PCI "PCI"

/* Multiprocessor Specification 1.4 section 4.3.3 I/O APIC Entries */

#define MP_IO_API_FLAG_EN (1 << 0)

/* Multiprocessor Specification 1.4 Table 4-10 I/O Interrupt Entry Fields */

#define MP_PO_BUS_DEFAULT 0

#define MP_PO_ACTIVE_HIGH 1

#define MP_PO_ACTIVE_LOW 3


#define MP_EL_BUS_DEFAULT (0 << 2)

#define MP_EL_EDGE (1 << 2)

#define MP_EL_LEVEL (2 << 2)

/* Multiprocessor Specification 1.4 Table 4-11 Interrupt Type Values */

#define MP_INTR_TYPE_INT 0

#define MP_INTR_TYPE_NMI 1

#define MP_INTR_TYPE_SMI 2

#define MP_INTR_TYPE_EXTINT 3

/* Multiprocessor Specification 1.4 Table 5-1 Default Configurations */

#define MP_NO_DEFAULT 0

#define MP_DEFAULT_ISA 1

#define MP_DEFAULT_EISA_NO_IRQ0 2

#define MP_DEFAULT_EISA 3

#define MP_DEFAULT_MCA 4

#define MP_DEFAULT_ISA_PCI_APIC 5

#define MP_DEFAULT_EISA_PIC_APIC 6

#define MP_DEFAULT_MCA_PCI_APIC 7

#endif
115 changes: 115 additions & 0 deletions include/kernel/infrastructure/i686/mp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* Copyright (C) 2025 Philippe Aubertin.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the author nor the names of other contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef JINUE_KERNEL_INFRASTRUCTURE_I686_MP_H
#define JINUE_KERNEL_INFRASTRUCTURE_I686_MP_H

#include <stdint.h>

/* Multiprocessor Specification 1.4 section 4.1 MP Floating Pointer
* Structure */

typedef struct {
char signature[4];
uint32_t addr;
uint8_t length;
uint8_t revision;
uint8_t checksum;
uint8_t feature1;
uint8_t feature2;
uint8_t feature_reserved[3];
} mp_floating_ptr_t;

/* Multiprocessor Specification 1.4 section 4.2 MP Configuration Table
* Header */

typedef struct {
char signature[4];
uint16_t base_length;
uint8_t revision;
uint8_t checksum;
char oem_id[8];
char product_id[12];
uint32_t oem_table_addr;
uint16_t oem_table_size;
uint16_t entry_count;
uint32_t lapic_addr;
uint16_t ext_table_length;
uint8_t ext_table_checksum;
uint8_t reserved;
char entries[];
} mp_conf_table_t;

/* Multiprocessor Specification 1.4 section 4.3.1 Processor Entries */

typedef struct {
uint8_t entry_type;
uint8_t apic_id;
uint8_t apic_version;
uint8_t cpu_flags;
uint32_t cpu_signature;
uint32_t feature_flags;
uint32_t reserved1;
uint32_t reserved2;
} mp_entry_processor_t;

/* Multiprocessor Specification 1.4 section 4.3.2 Bus Entries */

typedef struct {
uint8_t entry_type;
uint8_t bus_id;
char bus_type[6];
} mp_entry_bus_t;

/* Multiprocessor Specification 1.4 section 4.3.3 I/O APIC Entries */

typedef struct {
uint8_t entry_type;
uint8_t apic_id;
uint8_t apic_version;
uint8_t flag;
uint32_t addr;
} mp_entry_io_apic_t;

/* Multiprocessor Specification 1.4 section 4.3.4 I/O Interrupt Assignment
* Entries and 4.3.5 Local Interrupt Assignment Entries */

typedef struct {
uint8_t entry_type;
uint8_t intr_type;
uint16_t io_intr_flag;
uint8_t source_bus_id;
uint8_t source_bus_irq;
uint8_t dest_apic_id;
uint8_t dest_apic_intn;
} mp_entry_intr_t;

#endif

0 comments on commit 9f21896

Please sign in to comment.