Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2088 → Rev 2089

/trunk/kernel/arch/ia32/include/interrupt.h
68,7 → 68,7
#define VECTOR_TLB_SHOOTDOWN_IPI (IVT_FREEBASE + 1)
#define VECTOR_DEBUG_IPI (IVT_FREEBASE + 2)
 
struct istate {
typedef struct {
uint32_t eax;
uint32_t ecx;
uint32_t edx;
87,7 → 87,7
uint32_t cs;
uint32_t eflags;
uint32_t stack[];
};
} istate_t;
 
/** Return true if exception happened while in userspace */
static inline int istate_from_uspace(istate_t *istate)
/trunk/kernel/arch/ia32/include/types.h
36,6 → 36,8
#define KERN_ia32_TYPES_H_
 
#define NULL 0
#define false 0
#define true 1
 
typedef signed char int8_t;
typedef signed short int16_t;
47,6 → 49,10
typedef unsigned long uint32_t;
typedef unsigned long long uint64_t;
 
typedef uint32_t size_t;
typedef uint32_t count_t;
typedef uint32_t index_t;
 
typedef uint32_t uintptr_t;
typedef uint32_t pfn_t;
 
55,8 → 61,29
typedef uint32_t unative_t;
typedef int32_t native_t;
 
typedef struct page_specifier pte_t;
typedef uint8_t bool;
typedef uint64_t task_id_t;
typedef uint32_t context_id_t;
 
typedef int32_t inr_t;
typedef int32_t devno_t;
 
/** Page Table Entry. */
typedef struct {
unsigned present : 1;
unsigned writeable : 1;
unsigned uaccessible : 1;
unsigned page_write_through : 1;
unsigned page_cache_disable : 1;
unsigned accessed : 1;
unsigned dirty : 1;
unsigned pat : 1;
unsigned global : 1;
unsigned soft_valid : 1; /**< Valid content even if the present bit is not set. */
unsigned avl : 2;
unsigned frame_address : 20;
} __attribute__ ((packed)) pte_t;
 
#endif
 
/** @}
/trunk/kernel/arch/ia32/include/smp/apic.h
107,7 → 107,7
/** Interrupt Command Register. */
#define ICRlo (0x300/sizeof(uint32_t))
#define ICRhi (0x310/sizeof(uint32_t))
struct icr {
typedef struct {
union {
uint32_t lo;
struct {
130,8 → 130,7
uint8_t dest; /**< Destination field. */
} __attribute__ ((packed));
};
} __attribute__ ((packed));
typedef struct icr icr_t;
} __attribute__ ((packed)) icr_t;
 
/* End Of Interrupt. */
#define EOI (0x0b0/sizeof(uint32_t))
138,7 → 137,7
 
/** Error Status Register. */
#define ESR (0x280/sizeof(uint32_t))
union esr {
typedef union {
uint32_t value;
uint8_t err_bitmap;
struct {
152,23 → 151,21
unsigned illegal_register_address : 1;
unsigned : 24;
} __attribute__ ((packed));
};
typedef union esr esr_t;
} esr_t;
 
/* Task Priority Register */
#define TPR (0x080/sizeof(uint32_t))
union tpr {
typedef union {
uint32_t value;
struct {
unsigned pri_sc : 4; /**< Task Priority Sub-Class. */
unsigned pri : 4; /**< Task Priority. */
} __attribute__ ((packed));
};
typedef union tpr tpr_t;
} tpr_t;
 
/** Spurious-Interrupt Vector Register. */
#define SVR (0x0f0/sizeof(uint32_t))
union svr {
typedef union {
uint32_t value;
struct {
uint8_t vector; /**< Spurious Vector. */
176,19 → 173,17
unsigned focus_checking : 1; /**< Focus Processor Checking. */
unsigned : 22; /**< Reserved. */
} __attribute__ ((packed));
};
typedef union svr svr_t;
} svr_t;
 
/** Time Divide Configuration Register. */
#define TDCR (0x3e0/sizeof(uint32_t))
union tdcr {
typedef union {
uint32_t value;
struct {
unsigned div_value : 4; /**< Divide Value, bit 2 is always 0. */
unsigned : 28; /**< Reserved. */
} __attribute__ ((packed));
};
typedef union tdcr tdcr_t;
} tdcr_t;
 
/* Initial Count Register for Timer */
#define ICRT (0x380/sizeof(uint32_t))
198,7 → 193,7
 
/** LVT Timer register. */
#define LVT_Tm (0x320/sizeof(uint32_t))
union lvt_tm {
typedef union {
uint32_t value;
struct {
uint8_t vector; /**< Local Timer Interrupt vector. */
209,13 → 204,12
unsigned mode : 1; /**< Timer Mode. */
unsigned : 14; /**< Reserved. */
} __attribute__ ((packed));
};
typedef union lvt_tm lvt_tm_t;
} lvt_tm_t;
 
/** LVT LINT registers. */
#define LVT_LINT0 (0x350/sizeof(uint32_t))
#define LVT_LINT1 (0x360/sizeof(uint32_t))
union lvt_lint {
typedef union {
uint32_t value;
struct {
uint8_t vector; /**< LINT Interrupt vector. */
228,12 → 222,11
unsigned masked : 1; /**< Interrupt Mask. */
unsigned : 15; /**< Reserved. */
} __attribute__ ((packed));
};
typedef union lvt_lint lvt_lint_t;
} lvt_lint_t;
 
/** LVT Error register. */
#define LVT_Err (0x370/sizeof(uint32_t))
union lvt_error {
typedef union {
uint32_t value;
struct {
uint8_t vector; /**< Local Timer Interrupt vector. */
243,19 → 236,17
unsigned masked : 1; /**< Interrupt Mask. */
unsigned : 15; /**< Reserved. */
} __attribute__ ((packed));
};
typedef union lvt_error lvt_error_t;
} lvt_error_t;
 
/** Local APIC ID Register. */
#define L_APIC_ID (0x020/sizeof(uint32_t))
union l_apic_id {
typedef union {
uint32_t value;
struct {
unsigned : 24; /**< Reserved. */
uint8_t apic_id; /**< Local APIC ID. */
} __attribute__ ((packed));
};
typedef union l_apic_id l_apic_id_t;
} l_apic_id_t;
 
/** Local APIC Version Register */
#define LAVR (0x030/sizeof(uint32_t))
266,25 → 257,23
 
/** Logical Destination Register. */
#define LDR (0x0d0/sizeof(uint32_t))
union ldr {
typedef union {
uint32_t value;
struct {
unsigned : 24; /**< Reserved. */
uint8_t id; /**< Logical APIC ID. */
} __attribute__ ((packed));
};
typedef union ldr ldr_t;
} ldr_t;
 
/** Destination Format Register. */
#define DFR (0x0e0/sizeof(uint32_t))
union dfr {
typedef union {
uint32_t value;
struct {
unsigned : 28; /**< Reserved, all ones. */
unsigned model : 4; /**< Model. */
} __attribute__ ((packed));
};
typedef union dfr dfr_t;
} dfr_t;
 
/* IO APIC */
#define IOREGSEL (0x00/sizeof(uint32_t))
296,17 → 285,16
#define IOREDTBL 0x10
 
/** I/O Register Select Register. */
union io_regsel {
typedef union {
uint32_t value;
struct {
uint8_t reg_addr; /**< APIC Register Address. */
unsigned : 24; /**< Reserved. */
} __attribute__ ((packed));
};
typedef union io_regsel io_regsel_t;
} io_regsel_t;
 
/** I/O Redirection Register. */
struct io_redirection_reg {
typedef struct io_redirection_reg {
union {
uint32_t lo;
struct {
329,12 → 317,11
} __attribute__ ((packed));
};
} __attribute__ ((packed));
typedef struct io_redirection_reg io_redirection_reg_t;
} __attribute__ ((packed)) io_redirection_reg_t;
 
 
/** IO APIC Identification Register. */
union io_apic_id {
typedef union {
uint32_t value;
struct {
unsigned : 24; /**< Reserved. */
341,8 → 328,7
unsigned apic_id : 4; /**< IO APIC ID. */
unsigned : 4; /**< Reserved. */
} __attribute__ ((packed));
};
typedef union io_apic_id io_apic_id_t;
} io_apic_id_t;
 
extern volatile uint32_t *l_apic;
extern volatile uint32_t *io_apic;
/trunk/kernel/arch/ia32/include/smp/mps.h
36,7 → 36,6
#define KERN_ia32_MPS_H_
 
#include <arch/types.h>
#include <typedefs.h>
#include <synch/waitq.h>
#include <config.h>
#include <arch/smp/smp.h>
/trunk/kernel/arch/ia32/include/smp/smp.h
36,7 → 36,6
#define KERN_ia32_SMP_H_
 
#include <arch/types.h>
#include <typedefs.h>
 
/** SMP config opertaions interface. */
struct smp_config_operations {
/trunk/kernel/arch/ia32/include/atomic.h
38,7 → 38,6
#include <arch/types.h>
#include <arch/barrier.h>
#include <preemption.h>
#include <typedefs.h>
 
static inline void atomic_inc(atomic_t *val) {
#ifdef CONFIG_SMP
/trunk/kernel/arch/ia32/include/pm.h
81,7 → 81,6
#ifndef __ASM__
 
#include <arch/types.h>
#include <typedefs.h>
#include <arch/context.h>
 
struct ptr_16_32 {
/trunk/kernel/arch/ia32/include/boot/memmap.h
57,18 → 57,16
 
#include <arch/types.h>
 
struct e820memmap_ {
typedef struct {
uint64_t base_address;
uint64_t size;
uint32_t type;
} __attribute__ ((packed));
} __attribute__ ((packed)) e820memmap_t;
 
extern struct e820memmap_ e820table[MEMMAP_E820_MAX_RECORDS];
 
extern e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS];
extern uint8_t e820counter;
extern uint32_t e801memorysize; /**< Size of available memory in KB. */
 
extern uint32_t e801memorysize; /**< Size of available memory in KB. */
 
#endif
 
#endif
/trunk/kernel/arch/ia32/include/proc/task.h
35,7 → 35,6
#ifndef KERN_ia32_TASK_H_
#define KERN_ia32_TASK_H_
 
#include <typedefs.h>
#include <arch/types.h>
#include <adt/bitmap.h>
 
/trunk/kernel/arch/ia32/include/mm/memory_init.h
36,8 → 36,6
#ifndef KERN_ia32_MEMORY_INIT_H_
#define KERN_ia32_MEMORY_INIT_H_
 
#include <typedefs.h>
 
size_t get_memory_size(void);
 
void memory_print_map(void);
/trunk/kernel/arch/ia32/include/mm/page.h
61,15 → 61,15
#define PTL2_ENTRIES_ARCH 0
#define PTL3_ENTRIES_ARCH 1024
 
#define PTL0_INDEX_ARCH(vaddr) (((vaddr)>>22)&0x3ff)
#define PTL0_INDEX_ARCH(vaddr) (((vaddr) >> 22) & 0x3ff)
#define PTL1_INDEX_ARCH(vaddr) 0
#define PTL2_INDEX_ARCH(vaddr) 0
#define PTL3_INDEX_ARCH(vaddr) (((vaddr)>>12)&0x3ff)
#define PTL3_INDEX_ARCH(vaddr) (((vaddr) >> 12) & 0x3ff)
 
#define GET_PTL1_ADDRESS_ARCH(ptl0, i) ((pte_t *)((((pte_t *)(ptl0))[(i)].frame_address)<<12))
#define GET_PTL1_ADDRESS_ARCH(ptl0, i) ((pte_t *)((((pte_t *)(ptl0))[(i)].frame_address) << 12))
#define GET_PTL2_ADDRESS_ARCH(ptl1, i) (ptl1)
#define GET_PTL3_ADDRESS_ARCH(ptl2, i) (ptl2)
#define GET_FRAME_ADDRESS_ARCH(ptl3, i) ((uintptr_t)((((pte_t *)(ptl3))[(i)].frame_address)<<12))
#define GET_FRAME_ADDRESS_ARCH(ptl3, i) ((uintptr_t)((((pte_t *)(ptl3))[(i)].frame_address) << 12))
 
#define SET_PTL0_ADDRESS_ARCH(ptl0) (write_cr3((uintptr_t) (ptl0)))
#define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) (((pte_t *)(ptl0))[(i)].frame_address = (a)>>12)
89,59 → 89,41
 
#define PTE_VALID_ARCH(p) (*((uint32_t *) (p)) != 0)
#define PTE_PRESENT_ARCH(p) ((p)->present != 0)
#define PTE_GET_FRAME_ARCH(p) ((p)->frame_address<<FRAME_WIDTH)
#define PTE_GET_FRAME_ARCH(p) ((p)->frame_address << FRAME_WIDTH)
#define PTE_WRITABLE_ARCH(p) ((p)->writeable != 0)
#define PTE_EXECUTABLE_ARCH(p) 1
 
#ifndef __ASM__
 
#include <mm/page.h>
#include <arch/types.h>
#include <arch/mm/frame.h>
#include <typedefs.h>
#include <mm/mm.h>
#include <arch/interrupt.h>
 
/* Page fault error codes. */
 
/** When bit on this position is 0, the page fault was caused by a not-present page. */
#define PFERR_CODE_P (1<<0)
#define PFERR_CODE_P (1 << 0)
 
/** When bit on this position is 1, the page fault was caused by a write. */
#define PFERR_CODE_RW (1<<1)
#define PFERR_CODE_RW (1 << 1)
 
/** When bit on this position is 1, the page fault was caused in user mode. */
#define PFERR_CODE_US (1<<2)
#define PFERR_CODE_US (1 << 2)
 
/** When bit on this position is 1, a reserved bit was set in page directory. */
#define PFERR_CODE_RSVD (1<<3)
#define PFERR_CODE_RSVD (1 << 3)
 
/** Page Table Entry. */
struct page_specifier {
unsigned present : 1;
unsigned writeable : 1;
unsigned uaccessible : 1;
unsigned page_write_through : 1;
unsigned page_cache_disable : 1;
unsigned accessed : 1;
unsigned dirty : 1;
unsigned pat : 1;
unsigned global : 1;
unsigned soft_valid : 1; /**< Valid content even if the present bit is not set. */
unsigned avl : 2;
unsigned frame_address : 20;
} __attribute__ ((packed));
 
static inline int get_pt_flags(pte_t *pt, index_t i)
{
pte_t *p = &pt[i];
return (
(!p->page_cache_disable)<<PAGE_CACHEABLE_SHIFT |
(!p->present)<<PAGE_PRESENT_SHIFT |
p->uaccessible<<PAGE_USER_SHIFT |
(!p->page_cache_disable) << PAGE_CACHEABLE_SHIFT |
(!p->present) << PAGE_PRESENT_SHIFT |
p->uaccessible << PAGE_USER_SHIFT |
1<<PAGE_READ_SHIFT |
p->writeable<<PAGE_WRITE_SHIFT |
p->writeable << PAGE_WRITE_SHIFT |
1<<PAGE_EXEC_SHIFT |
p->global<<PAGE_GLOBAL_SHIFT
p->global << PAGE_GLOBAL_SHIFT
);
}
 
/trunk/kernel/arch/ia32/include/mm/asid.h
42,11 → 42,13
#ifndef KERN_ia32_ASID_H_
#define KERN_ia32_ASID_H_
 
typedef int asid_t;
#include <arch/types.h>
 
typedef int32_t asid_t;
 
#define ASID_MAX_ARCH 3
 
#define asid_get() (ASID_START+1)
#define asid_get() (ASID_START + 1)
#define asid_put(asid)
 
#endif
/trunk/kernel/arch/ia32/include/mm/as.h
47,6 → 47,8
typedef struct {
} as_arch_t;
 
#include <genarch/mm/as_pt.h>
 
#define as_constructor_arch(as, flags) (as != as)
#define as_destructor_arch(as) (as != as)
#define as_create_arch(as, flags) (as != as)
/trunk/kernel/arch/ia32/include/cpu.h
35,7 → 35,6
#ifndef KERN_ia32_CPU_H_
#define KERN_ia32_CPU_H_
 
#include <typedefs.h>
#include <arch/pm.h>
#include <arch/asm.h>