Subversion Repositories HelenOS-historic

Compare Revisions

Regard whitespace Rev 1779 → Rev 1780

/kernel/trunk/genarch/include/fb/fb.h
39,7 → 39,7
#include <arch/types.h>
 
extern spinlock_t fb_lock;
void fb_init(__address addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan);
void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan);
 
#endif
 
/kernel/trunk/genarch/include/mm/page_pt.h
109,8 → 109,8
 
extern page_mapping_operations_t pt_mapping_operations;
 
extern void page_mapping_insert_pt(as_t *as, __address page, __address frame, int flags);
extern pte_t *page_mapping_find_pt(as_t *as, __address page);
extern void page_mapping_insert_pt(as_t *as, uintptr_t page, uintptr_t frame, int flags);
extern pte_t *page_mapping_find_pt(as_t *as, uintptr_t page);
 
#endif
 
/kernel/trunk/genarch/include/mm/page_ht.h
66,8 → 66,8
struct pte {
link_t link; /**< Page hash table link. */
as_t *as; /**< Address space. */
__address page; /**< Virtual memory page. */
__address frame; /**< Physical memory frame. */
uintptr_t page; /**< Virtual memory page. */
uintptr_t frame; /**< Physical memory frame. */
unsigned g : 1; /**< Global page. */
unsigned x : 1; /**< Execute. */
unsigned w : 1; /**< Writable. */
/kernel/trunk/genarch/include/ofw/ofw.h
39,7 → 39,7
 
#define MAX_OFW_ARGS 10
 
typedef __native ofw_arg_t;
typedef unative_t ofw_arg_t;
typedef int ihandle;
typedef int phandle;
 
48,8 → 48,8
*/
typedef struct {
const char *service; /**< Command name */
__native nargs; /**< Number of in arguments */
__native nret; /**< Number of out arguments */
unative_t nargs; /**< Number of in arguments */
unative_t nret; /**< Number of out arguments */
ofw_arg_t args[MAX_OFW_ARGS]; /**< List of arguments */
} ofw_args_t;
 
59,7 → 59,7
 
extern void ofw_init(void);
extern void ofw_done(void);
extern __native ofw_call(const char *service, const int nargs, const int nret, ...);
extern unative_t ofw_call(const char *service, const int nargs, const int nret, ...);
extern void ofw_putchar(const char ch);
extern char ofw_getchar(void);
extern phandle ofw_find_device(const char *name);
/kernel/trunk/genarch/include/acpi/acpi.h
39,32 → 39,32
 
/* Root System Description Pointer */
struct acpi_rsdp {
__u8 signature[8];
__u8 checksum;
__u8 oemid[6];
__u8 revision;
__u32 rsdt_address;
__u32 length;
__u64 xsdt_address;
__u32 ext_checksum;
__u8 reserved[3];
uint8_t signature[8];
uint8_t checksum;
uint8_t oemid[6];
uint8_t revision;
uint32_t rsdt_address;
uint32_t length;
uint64_t xsdt_address;
uint32_t ext_checksum;
uint8_t reserved[3];
} __attribute__ ((packed));
 
/* System Description Table Header */
struct acpi_sdt_header {
__u8 signature[4];
__u32 length;
__u8 revision;
__u8 checksum;
__u8 oemid[6];
__u8 oem_table_id[8];
__u32 oem_revision;
__u32 creator_id;
__u32 creator_revision;
uint8_t signature[4];
uint32_t length;
uint8_t revision;
uint8_t checksum;
uint8_t oemid[6];
uint8_t oem_table_id[8];
uint32_t oem_revision;
uint32_t creator_id;
uint32_t creator_revision;
} __attribute__ ((packed));;
 
struct acpi_signature_map {
__u8 *signature;
uint8_t *signature;
struct acpi_sdt_header **sdt_ptr;
char *description;
};
72,13 → 72,13
/* Root System Description Table */
struct acpi_rsdt {
struct acpi_sdt_header header;
__u32 entry[];
uint32_t entry[];
} __attribute__ ((packed));;
 
/* Extended System Description Table */
struct acpi_xsdt {
struct acpi_sdt_header header;
__u64 entry[];
uint64_t entry[];
} __attribute__ ((packed));;
 
extern struct acpi_rsdp *acpi_rsdp;
86,7 → 86,7
extern struct acpi_xsdt *acpi_xsdt;
 
extern void acpi_init(void);
extern int acpi_sdt_check(__u8 *sdt);
extern int acpi_sdt_check(uint8_t *sdt);
 
#endif /* __ACPI_H__ */
 
/kernel/trunk/genarch/include/acpi/madt.h
53,8 → 53,8
#define MADT_RESERVED_OEM_BEGIN 128
 
struct madt_apic_header {
__u8 type;
__u8 length;
uint8_t type;
uint8_t length;
} __attribute__ ((packed));
 
 
61,81 → 61,81
/* Multiple APIC Description Table */
struct acpi_madt {
struct acpi_sdt_header header;
__u32 l_apic_address;
__u32 flags;
uint32_t l_apic_address;
uint32_t flags;
struct madt_apic_header apic_header[];
} __attribute__ ((packed));
 
struct madt_l_apic {
struct madt_apic_header header;
__u8 acpi_id;
__u8 apic_id;
__u32 flags;
uint8_t acpi_id;
uint8_t apic_id;
uint32_t flags;
} __attribute__ ((packed));
 
struct madt_io_apic {
struct madt_apic_header header;
__u8 io_apic_id;
__u8 reserved;
__u32 io_apic_address;
__u32 global_intr_base;
uint8_t io_apic_id;
uint8_t reserved;
uint32_t io_apic_address;
uint32_t global_intr_base;
} __attribute__ ((packed));
 
struct madt_intr_src_ovrd {
struct madt_apic_header header;
__u8 bus;
__u8 source;
__u32 global_int;
__u16 flags;
uint8_t bus;
uint8_t source;
uint32_t global_int;
uint16_t flags;
} __attribute__ ((packed));
 
struct madt_nmi_src {
struct madt_apic_header header;
__u16 flags;
__u32 global_intr;
uint16_t flags;
uint32_t global_intr;
} __attribute__ ((packed));
 
struct madt_l_apic_nmi {
struct madt_apic_header header;
__u8 acpi_id;
__u16 flags;
__u8 l_apic_lint;
uint8_t acpi_id;
uint16_t flags;
uint8_t l_apic_lint;
} __attribute__ ((packed));
 
struct madt_l_apic_addr_ovrd {
struct madt_apic_header header;
__u16 reserved;
__u64 l_apic_address;
uint16_t reserved;
uint64_t l_apic_address;
} __attribute__ ((packed));
 
struct madt_io_sapic {
struct madt_apic_header header;
__u8 io_apic_id;
__u8 reserved;
__u32 global_intr_base;
__u64 io_apic_address;
uint8_t io_apic_id;
uint8_t reserved;
uint32_t global_intr_base;
uint64_t io_apic_address;
} __attribute__ ((packed));
 
struct madt_l_sapic {
struct madt_apic_header header;
__u8 acpi_id;
__u8 sapic_id;
__u8 sapic_eid;
__u8 reserved[3];
__u32 flags;
__u32 acpi_processor_uid_value;
__u8 acpi_processor_uid_str[1];
uint8_t acpi_id;
uint8_t sapic_id;
uint8_t sapic_eid;
uint8_t reserved[3];
uint32_t flags;
uint32_t acpi_processor_uid_value;
uint8_t acpi_processor_uid_str[1];
} __attribute__ ((packed));
 
struct madt_platform_intr_src {
struct madt_apic_header header;
__u16 flags;
__u8 intr_type;
__u8 processor_id;
__u8 processor_eid;
__u8 io_sapic_vector;
__u32 global_intr;
__u32 platform_intr_src_flags;
uint16_t flags;
uint8_t intr_type;
uint8_t processor_id;
uint8_t processor_eid;
uint8_t io_sapic_vector;
uint32_t global_intr;
uint32_t platform_intr_src_flags;
} __attribute__ ((packed));
 
extern struct acpi_madt *acpi_madt;
/kernel/trunk/genarch/src/i8042/i8042.c
84,8 → 84,8
*/
#define IGNORE_CODE 0x7f
 
static void key_released(__u8 sc);
static void key_pressed(__u8 sc);
static void key_released(uint8_t sc);
static void key_pressed(uint8_t sc);
static char key_read(chardev_t *d);
 
#define PRESSED_SHIFT (1<<0)
94,7 → 94,7
 
#define ACTIVE_READ_BUFF_SIZE 16 /* Must be power of 2 */
 
static __u8 active_read_buff[ACTIVE_READ_BUFF_SIZE];
static uint8_t active_read_buff[ACTIVE_READ_BUFF_SIZE];
 
SPINLOCK_INITIALIZE(keylock); /**< keylock protects keyflags and lockflags. */
static volatile int keyflags; /**< Tracking of multiple keypresses. */
322,8 → 322,8
*/
void i8042_interrupt(int n, istate_t *istate)
{
__u8 x;
__u8 status;
uint8_t x;
uint8_t status;
 
while (((status=i8042_status_read()) & i8042_BUFFER_FULL_MASK)) {
x = i8042_data_read();
350,7 → 350,7
*
* @param sc Scancode of the key being released.
*/
void key_released(__u8 sc)
void key_released(uint8_t sc)
{
spinlock_lock(&keylock);
switch (sc) {
375,7 → 375,7
*
* @param sc Scancode of the key being pressed.
*/
void key_pressed(__u8 sc)
void key_pressed(uint8_t sc)
{
char *map = sc_primary_map;
char ascii = sc_primary_map[sc];
453,7 → 453,7
{
}
 
static __u8 active_read_buff_read(void)
static uint8_t active_read_buff_read(void)
{
static int i=0;
i &= (ACTIVE_READ_BUFF_SIZE-1);
463,7 → 463,7
return active_read_buff[i++];
}
 
static void active_read_buff_write(__u8 ch)
static void active_read_buff_write(uint8_t ch)
{
static int i=0;
active_read_buff[i] = ch;
473,7 → 473,7
}
 
 
static void active_read_key_pressed(__u8 sc)
static void active_read_key_pressed(uint8_t sc)
{
char *map = sc_primary_map;
char ascii = sc_primary_map[sc];
547,7 → 547,7
char ch;
 
while(!(ch = active_read_buff_read())) {
__u8 x;
uint8_t x;
while (!(i8042_status_read() & i8042_BUFFER_FULL_MASK))
;
x = i8042_data_read();
567,7 → 567,7
*/
void i8042_poll(void)
{
__u8 x;
uint8_t x;
 
while (((x = i8042_status_read() & i8042_BUFFER_FULL_MASK))) {
x = i8042_data_read();
/kernel/trunk/genarch/src/fb/fb.c
49,10 → 49,10
 
SPINLOCK_INITIALIZE(fb_lock);
 
static __u8 *fbaddress = NULL;
static uint8_t *fbaddress = NULL;
 
static __u8 *blankline = NULL;
static __u8 *dbbuffer = NULL; /* Buffer for fast scrolling console */
static uint8_t *blankline = NULL;
static uint8_t *dbbuffer = NULL; /* Buffer for fast scrolling console */
static int dboffset;
 
static unsigned int xres = 0;
98,7 → 98,7
 
static void rgb_3byte(void *dst, int rgb)
{
__u8 *scr = dst;
uint8_t *scr = dst;
#if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN))
scr[0] = RED(rgb, 8);
scr[1] = GREEN(rgb, 8);
112,7 → 112,7
 
static int byte3_rgb(void *src)
{
__u8 *scr = src;
uint8_t *scr = src;
#if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN))
return scr[0] << 16 | scr[1] << 8 | scr[2];
#else
124,13 → 124,13
static void rgb_2byte(void *dst, int rgb)
{
/* 5-bit, 6-bits, 5-bits */
*((__u16 *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5);
*((uint16_t *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5);
}
 
/** 16-bit depth (5:6:5) */
static int byte2_rgb(void *src)
{
int color = *(__u16 *)(src);
int color = *(uint16_t *)(src);
return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3);
}
 
137,13 → 137,13
/** Put pixel - 8-bit depth (3:2:3) */
static void rgb_1byte(void *dst, int rgb)
{
*(__u8 *)dst = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3);
*(uint8_t *)dst = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3);
}
 
/** Return pixel color - 8-bit depth (3:2:3) */
static int byte1_rgb(void *src)
{
int color = *(__u8 *)src;
int color = *(uint8_t *)src;
return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5);
}
 
184,7 → 184,7
/** Scroll screen one row up */
static void scroll_screen(void)
{
__u8 *lastline = &fbaddress[(rows - 1) * ROW_BYTES];
uint8_t *lastline = &fbaddress[(rows - 1) * ROW_BYTES];
int firstsz;
 
if (dbbuffer) {
225,7 → 225,7
/* Character-console functions */
 
/** Draw character at given position */
static void draw_glyph(__u8 glyph, unsigned int col, unsigned int row)
static void draw_glyph(uint8_t glyph, unsigned int col, unsigned int row)
{
unsigned int y;
 
336,7 → 336,7
* @param scan Bytes per one scanline
*
*/
void fb_init(__address addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan)
void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan)
{
switch (bpp) {
case 8:
366,7 → 366,7
unsigned int fbsize = scan * y;
/* Map the framebuffer */
fbaddress = (__u8 *) hw_map((__address) addr, fbsize);
fbaddress = (uint8_t *) hw_map((uintptr_t) addr, fbsize);
xres = x;
yres = y;
399,7 → 399,7
dboffset = 0;
 
/* Initialized blank line */
blankline = (__u8 *) malloc(ROW_BYTES, FRAME_ATOMIC);
blankline = (uint8_t *) malloc(ROW_BYTES, FRAME_ATOMIC);
if (!blankline)
panic("Failed to allocate blank line for framebuffer.");
for (y=0; y < FONT_SCANLINES; y++)
/kernel/trunk/genarch/src/mm/page_pt.c
46,9 → 46,9
#include <arch/asm.h>
#include <memstr.h>
 
static void pt_mapping_insert(as_t *as, __address page, __address frame, int flags);
static void pt_mapping_remove(as_t *as, __address page);
static pte_t *pt_mapping_find(as_t *as, __address page);
static void pt_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int flags);
static void pt_mapping_remove(as_t *as, uintptr_t page);
static pte_t *pt_mapping_find(as_t *as, uintptr_t page);
 
page_mapping_operations_t pt_mapping_operations = {
.mapping_insert = pt_mapping_insert,
68,16 → 68,16
* @param frame Physical address of memory frame to which the mapping is done.
* @param flags Flags to be used for mapping.
*/
void pt_mapping_insert(as_t *as, __address page, __address frame, int flags)
void pt_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int flags)
{
pte_t *ptl0, *ptl1, *ptl2, *ptl3;
pte_t *newpt;
 
ptl0 = (pte_t *) PA2KA((__address) as->page_table);
ptl0 = (pte_t *) PA2KA((uintptr_t) as->page_table);
 
if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) {
newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA);
memsetb((__address)newpt, PAGE_SIZE, 0);
memsetb((uintptr_t)newpt, PAGE_SIZE, 0);
SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt));
SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
}
86,7 → 86,7
 
if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) {
newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA);
memsetb((__address)newpt, PAGE_SIZE, 0);
memsetb((uintptr_t)newpt, PAGE_SIZE, 0);
SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt));
SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
}
95,7 → 95,7
 
if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) {
newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA);
memsetb((__address)newpt, PAGE_SIZE, 0);
memsetb((uintptr_t)newpt, PAGE_SIZE, 0);
SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt));
SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE);
}
119,7 → 119,7
* @param as Address space to wich page belongs.
* @param page Virtual address of the page to be demapped.
*/
void pt_mapping_remove(as_t *as, __address page)
void pt_mapping_remove(as_t *as, uintptr_t page)
{
pte_t *ptl0, *ptl1, *ptl2, *ptl3;
bool empty = true;
129,7 → 129,7
* First, remove the mapping, if it exists.
*/
 
ptl0 = (pte_t *) PA2KA((__address) as->page_table);
ptl0 = (pte_t *) PA2KA((uintptr_t) as->page_table);
 
if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT)
return;
147,7 → 147,7
ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page)));
 
/* Destroy the mapping. Setting to PAGE_NOT_PRESENT is not sufficient. */
memsetb((__address) &ptl3[PTL3_INDEX(page)], sizeof(pte_t), 0);
memsetb((uintptr_t) &ptl3[PTL3_INDEX(page)], sizeof(pte_t), 0);
 
/*
* Second, free all empty tables along the way from PTL3 down to PTL0.
165,13 → 165,13
* PTL3 is empty.
* Release the frame and remove PTL3 pointer from preceding table.
*/
frame_free(KA2PA((__address) ptl3));
frame_free(KA2PA((uintptr_t) ptl3));
if (PTL2_ENTRIES)
memsetb((__address) &ptl2[PTL2_INDEX(page)], sizeof(pte_t), 0);
memsetb((uintptr_t) &ptl2[PTL2_INDEX(page)], sizeof(pte_t), 0);
else if (PTL1_ENTRIES)
memsetb((__address) &ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0);
memsetb((uintptr_t) &ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0);
else
memsetb((__address) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
memsetb((uintptr_t) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
} else {
/*
* PTL3 is not empty.
194,11 → 194,11
* PTL2 is empty.
* Release the frame and remove PTL2 pointer from preceding table.
*/
frame_free(KA2PA((__address) ptl2));
frame_free(KA2PA((uintptr_t) ptl2));
if (PTL1_ENTRIES)
memsetb((__address) &ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0);
memsetb((uintptr_t) &ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0);
else
memsetb((__address) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
memsetb((uintptr_t) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
}
else {
/*
223,8 → 223,8
* PTL1 is empty.
* Release the frame and remove PTL1 pointer from preceding table.
*/
frame_free(KA2PA((__address) ptl1));
memsetb((__address) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
frame_free(KA2PA((uintptr_t) ptl1));
memsetb((uintptr_t) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0);
}
}
 
241,11 → 241,11
*
* @return NULL if there is no such mapping; entry from PTL3 describing the mapping otherwise.
*/
pte_t *pt_mapping_find(as_t *as, __address page)
pte_t *pt_mapping_find(as_t *as, uintptr_t page)
{
pte_t *ptl0, *ptl1, *ptl2, *ptl3;
 
ptl0 = (pte_t *) PA2KA((__address) as->page_table);
ptl0 = (pte_t *) PA2KA((uintptr_t) as->page_table);
 
if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT)
return NULL;
/kernel/trunk/genarch/src/mm/as_pt.c
76,9 → 76,9
dst_ptl0 = (pte_t *) frame_alloc(ONE_FRAME, FRAME_KA);
 
if (flags & FLAG_AS_KERNEL) {
memsetb((__address) dst_ptl0, PAGE_SIZE, 0);
memsetb((uintptr_t) dst_ptl0, PAGE_SIZE, 0);
} else {
__address src, dst;
uintptr_t src, dst;
/*
* Copy the kernel address space portion to new PTL0.
86,18 → 86,18
ipl = interrupts_disable();
mutex_lock(&AS_KERNEL->lock);
src_ptl0 = (pte_t *) PA2KA((__address) AS_KERNEL->page_table);
src_ptl0 = (pte_t *) PA2KA((uintptr_t) AS_KERNEL->page_table);
 
src = (__address) &src_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
dst = (__address) &dst_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
src = (uintptr_t) &src_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
dst = (uintptr_t) &dst_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
 
memsetb((__address) dst_ptl0, PAGE_SIZE, 0);
memcpy((void *) dst, (void *) src, PAGE_SIZE - (src - (__address) src_ptl0));
memsetb((uintptr_t) dst_ptl0, PAGE_SIZE, 0);
memcpy((void *) dst, (void *) src, PAGE_SIZE - (src - (uintptr_t) src_ptl0));
mutex_unlock(&AS_KERNEL->lock);
interrupts_restore(ipl);
}
 
return (pte_t *) KA2PA((__address) dst_ptl0);
return (pte_t *) KA2PA((uintptr_t) dst_ptl0);
}
 
/** Destroy page table.
108,7 → 108,7
*/
void ptl0_destroy(pte_t *page_table)
{
frame_free((__address)page_table);
frame_free((uintptr_t)page_table);
}
 
/** Lock page tables.
/kernel/trunk/genarch/src/mm/page_ht.c
52,13 → 52,13
#include <adt/hash_table.h>
#include <align.h>
 
static index_t hash(__native key[]);
static bool compare(__native key[], count_t keys, link_t *item);
static index_t hash(unative_t key[]);
static bool compare(unative_t key[], count_t keys, link_t *item);
static void remove_callback(link_t *item);
 
static void ht_mapping_insert(as_t *as, __address page, __address frame, int flags);
static void ht_mapping_remove(as_t *as, __address page);
static pte_t *ht_mapping_find(as_t *as, __address page);
static void ht_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int flags);
static void ht_mapping_remove(as_t *as, uintptr_t page);
static pte_t *ht_mapping_find(as_t *as, uintptr_t page);
 
/**
* This lock protects the page hash table. It must be acquired
93,10 → 93,10
*
* @return Index into page hash table.
*/
index_t hash(__native key[])
index_t hash(unative_t key[])
{
as_t *as = (as_t *) key[KEY_AS];
__address page = (__address) key[KEY_PAGE];
uintptr_t page = (uintptr_t) key[KEY_PAGE];
index_t index;
/*
111,7 → 111,7
* similar addresses. Least significant bits compose the
* hash index.
*/
index |= ((__native) as) & (PAGE_HT_ENTRIES-1);
index |= ((unative_t) as) & (PAGE_HT_ENTRIES-1);
return index;
}
124,7 → 124,7
*
* @return true on match, false otherwise.
*/
bool compare(__native key[], count_t keys, link_t *item)
bool compare(unative_t key[], count_t keys, link_t *item)
{
pte_t *t;
 
137,9 → 137,9
t = hash_table_get_instance(item, pte_t, link);
 
if (keys == PAGE_HT_KEYS) {
return (key[KEY_AS] == (__address) t->as) && (key[KEY_PAGE] == t->page);
return (key[KEY_AS] == (uintptr_t) t->as) && (key[KEY_PAGE] == t->page);
} else {
return (key[KEY_AS] == (__address) t->as);
return (key[KEY_AS] == (uintptr_t) t->as);
}
}
 
173,10 → 173,10
* @param frame Physical address of memory frame to which the mapping is done.
* @param flags Flags to be used for mapping.
*/
void ht_mapping_insert(as_t *as, __address page, __address frame, int flags)
void ht_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int flags)
{
pte_t *t;
__native key[2] = { (__address) as, page = ALIGN_DOWN(page, PAGE_SIZE) };
unative_t key[2] = { (uintptr_t) as, page = ALIGN_DOWN(page, PAGE_SIZE) };
if (!hash_table_find(&page_ht, key)) {
t = (pte_t *) malloc(sizeof(pte_t), FRAME_ATOMIC);
208,9 → 208,9
* @param as Address space to wich page belongs.
* @param page Virtual address of the page to be demapped.
*/
void ht_mapping_remove(as_t *as, __address page)
void ht_mapping_remove(as_t *as, uintptr_t page)
{
__native key[2] = { (__address) as, page = ALIGN_DOWN(page, PAGE_SIZE) };
unative_t key[2] = { (uintptr_t) as, page = ALIGN_DOWN(page, PAGE_SIZE) };
/*
* Note that removed PTE's will be freed
231,11 → 231,11
*
* @return NULL if there is no such mapping; requested mapping otherwise.
*/
pte_t *ht_mapping_find(as_t *as, __address page)
pte_t *ht_mapping_find(as_t *as, uintptr_t page)
{
link_t *hlp;
pte_t *t = NULL;
__native key[2] = { (__address) as, page = ALIGN_DOWN(page, PAGE_SIZE) };
unative_t key[2] = { (uintptr_t) as, page = ALIGN_DOWN(page, PAGE_SIZE) };
hlp = hash_table_find(&page_ht, key);
if (hlp)
/kernel/trunk/genarch/src/ofw/memory_init.c
43,7 → 43,7
#define MEMMAP_MAX_RECORDS 32
 
typedef struct {
__address start;
uintptr_t start;
size_t size;
} memmap_t;
 
/kernel/trunk/genarch/src/ofw/ofw.c
63,7 → 63,7
cpu_halt();
}
 
__native ofw_call(const char *service, const int nargs, const int nret, ...)
unative_t ofw_call(const char *service, const int nargs, const int nret, ...)
{
va_list list;
ofw_args_t args;
/kernel/trunk/genarch/src/acpi/madt.c
55,9 → 55,9
/** Standard ISA IRQ map; can be overriden by Interrupt Source Override entries of MADT. */
int isa_irq_map[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
 
static void madt_l_apic_entry(struct madt_l_apic *la, __u32 index);
static void madt_io_apic_entry(struct madt_io_apic *ioa, __u32 index);
static void madt_intr_src_ovrd_entry(struct madt_intr_src_ovrd *override, __u32 index);
static void madt_l_apic_entry(struct madt_l_apic *la, uint32_t index);
static void madt_io_apic_entry(struct madt_io_apic *ioa, uint32_t index);
static void madt_intr_src_ovrd_entry(struct madt_intr_src_ovrd *override, uint32_t index);
static int madt_cmp(void * a, void * b);
 
struct madt_l_apic *madt_l_apic_entries = NULL;
90,7 → 90,7
static count_t madt_cpu_count(void);
static bool madt_cpu_enabled(index_t i);
static bool madt_cpu_bootstrap(index_t i);
static __u8 madt_cpu_apic_id(index_t i);
static uint8_t madt_cpu_apic_id(index_t i);
static int madt_irq_to_pin(int irq);
 
struct smp_config_operations madt_config_operations = {
119,7 → 119,7
return ((struct madt_l_apic *) madt_entries_index[madt_l_apic_entry_index + i])->apic_id == l_apic_id();
}
 
__u8 madt_cpu_apic_id(index_t i)
uint8_t madt_cpu_apic_id(index_t i)
{
ASSERT(i < madt_l_apic_entry_cnt);
return ((struct madt_l_apic *) madt_entries_index[madt_l_apic_entry_index + i])->apic_id;
141,13 → 141,13
void acpi_madt_parse(void)
{
struct madt_apic_header *end = (struct madt_apic_header *) (((__u8 *) acpi_madt) + acpi_madt->header.length);
struct madt_apic_header *end = (struct madt_apic_header *) (((uint8_t *) acpi_madt) + acpi_madt->header.length);
struct madt_apic_header *h;
l_apic = (__u32 *) (__native) acpi_madt->l_apic_address;
l_apic = (uint32_t *) (unative_t) acpi_madt->l_apic_address;
 
/* calculate madt entries */
for (h = &acpi_madt->apic_header[0]; h < end; h = (struct madt_apic_header *) (((__u8 *) h) + h->length)) {
for (h = &acpi_madt->apic_header[0]; h < end; h = (struct madt_apic_header *) (((uint8_t *) h) + h->length)) {
madt_entries_index_cnt++;
}
 
156,14 → 156,14
if (!madt_entries_index)
panic("Memory allocation error.");
 
__u32 index = 0;
uint32_t index = 0;
 
for (h = &acpi_madt->apic_header[0]; h < end; h = (struct madt_apic_header *) (((__u8 *) h) + h->length)) {
for (h = &acpi_madt->apic_header[0]; h < end; h = (struct madt_apic_header *) (((uint8_t *) h) + h->length)) {
madt_entries_index[index++] = h;
}
 
/* Quicksort MADT index structure */
qsort(madt_entries_index, madt_entries_index_cnt, sizeof(__address), &madt_cmp);
qsort(madt_entries_index, madt_entries_index_cnt, sizeof(uintptr_t), &madt_cmp);
 
/* Parse MADT entries */
for (index = 0; index < madt_entries_index_cnt - 1; index++) {
206,7 → 206,7
}
 
void madt_l_apic_entry(struct madt_l_apic *la, __u32 index)
void madt_l_apic_entry(struct madt_l_apic *la, uint32_t index)
{
if (!madt_l_apic_entry_cnt++) {
madt_l_apic_entry_index = index;
221,12 → 221,12
apic_id_mask |= 1<<la->apic_id;
}
 
void madt_io_apic_entry(struct madt_io_apic *ioa, __u32 index)
void madt_io_apic_entry(struct madt_io_apic *ioa, uint32_t index)
{
if (!madt_io_apic_entry_cnt++) {
/* remember index of the first io apic entry */
madt_io_apic_entry_index = index;
io_apic = (__u32 *) (__native) ioa->io_apic_address;
io_apic = (uint32_t *) (unative_t) ioa->io_apic_address;
} else {
/* currently not supported */
return;
233,7 → 233,7
}
}
 
void madt_intr_src_ovrd_entry(struct madt_intr_src_ovrd *override, __u32 index)
void madt_intr_src_ovrd_entry(struct madt_intr_src_ovrd *override, uint32_t index)
{
ASSERT(override->source < sizeof(isa_irq_map)/sizeof(int));
printf("MADT: ignoring %s entry: bus=%zd, source=%zd, global_int=%zd, flags=%#hx\n",
/kernel/trunk/genarch/src/acpi/acpi.c
51,12 → 51,12
struct acpi_xsdt *acpi_xsdt = NULL;
 
struct acpi_signature_map signature_map[] = {
{ (__u8 *)"APIC", (void *) &acpi_madt, "Multiple APIC Description Table" }
{ (uint8_t *)"APIC", (void *) &acpi_madt, "Multiple APIC Description Table" }
};
 
static int rsdp_check(__u8 *rsdp) {
static int rsdp_check(uint8_t *rsdp) {
struct acpi_rsdp *r = (struct acpi_rsdp *) rsdp;
__u8 sum = 0;
uint8_t sum = 0;
int i;
for (i=0; i<20; i++)
75,10 → 75,10
}
 
int acpi_sdt_check(__u8 *sdt)
int acpi_sdt_check(uint8_t *sdt)
{
struct acpi_sdt_header *h = (struct acpi_sdt_header *) sdt;
__u8 sum = 0;
uint8_t sum = 0;
int i;
 
for (i=0; i<h->length; i++)
89,21 → 89,21
 
static void map_sdt(struct acpi_sdt_header *sdt)
{
page_mapping_insert(AS_KERNEL, (__address) sdt, (__address) sdt, PAGE_NOT_CACHEABLE);
map_structure((__address) sdt, sdt->length);
page_mapping_insert(AS_KERNEL, (uintptr_t) sdt, (uintptr_t) sdt, PAGE_NOT_CACHEABLE);
map_structure((uintptr_t) sdt, sdt->length);
}
 
static void configure_via_rsdt(void)
{
int i, j, cnt = (acpi_rsdt->header.length - sizeof(struct acpi_sdt_header))/sizeof(__u32);
int i, j, cnt = (acpi_rsdt->header.length - sizeof(struct acpi_sdt_header))/sizeof(uint32_t);
for (i=0; i<cnt; i++) {
for (j=0; j<sizeof(signature_map)/sizeof(struct acpi_signature_map); j++) {
struct acpi_sdt_header *h = (struct acpi_sdt_header *) (__native) acpi_rsdt->entry[i];
struct acpi_sdt_header *h = (struct acpi_sdt_header *) (unative_t) acpi_rsdt->entry[i];
map_sdt(h);
if (*((__u32 *) &h->signature[0])==*((__u32 *) &signature_map[j].signature[0])) {
if (!acpi_sdt_check((__u8 *) h))
if (*((uint32_t *) &h->signature[0])==*((uint32_t *) &signature_map[j].signature[0])) {
if (!acpi_sdt_check((uint8_t *) h))
goto next;
*signature_map[j].sdt_ptr = h;
printf("%#zx: ACPI %s\n", *signature_map[j].sdt_ptr, signature_map[j].description);
116,15 → 116,15
 
static void configure_via_xsdt(void)
{
int i, j, cnt = (acpi_xsdt->header.length - sizeof(struct acpi_sdt_header))/sizeof(__u64);
int i, j, cnt = (acpi_xsdt->header.length - sizeof(struct acpi_sdt_header))/sizeof(uint64_t);
for (i=0; i<cnt; i++) {
for (j=0; j<sizeof(signature_map)/sizeof(struct acpi_signature_map); j++) {
struct acpi_sdt_header *h = (struct acpi_sdt_header *) ((__address) acpi_rsdt->entry[i]);
struct acpi_sdt_header *h = (struct acpi_sdt_header *) ((uintptr_t) acpi_rsdt->entry[i]);
 
map_sdt(h);
if (*((__u32 *) &h->signature[0])==*((__u32 *) &signature_map[j].signature[0])) {
if (!acpi_sdt_check((__u8 *) h))
if (*((uint32_t *) &h->signature[0])==*((uint32_t *) &signature_map[j].signature[0])) {
if (!acpi_sdt_check((uint8_t *) h))
goto next;
*signature_map[j].sdt_ptr = h;
printf("%#zx: ACPI %s\n", *signature_map[j].sdt_ptr, signature_map[j].description);
138,9 → 138,9
 
void acpi_init(void)
{
__u8 *addr[2] = { NULL, (__u8 *) PA2KA(0xe0000) };
uint8_t *addr[2] = { NULL, (uint8_t *) PA2KA(0xe0000) };
int i, j, length[2] = { 1024, 128*1024 };
__u64 *sig = (__u64 *) RSDP_SIGNATURE;
uint64_t *sig = (uint64_t *) RSDP_SIGNATURE;
 
/*
* Find Root System Description Pointer
148,10 → 148,10
* 2. search 128K starting at 0xe0000
*/
 
addr[0] = (__u8 *) PA2KA(ebda);
addr[0] = (uint8_t *) PA2KA(ebda);
for (i = (ebda ? 0 : 1); i < 2; i++) {
for (j = 0; j < length[i]; j += 16) {
if (*((__u64 *) &addr[i][j]) == *sig && rsdp_check(&addr[i][j])) {
if (*((uint64_t *) &addr[i][j]) == *sig && rsdp_check(&addr[i][j])) {
acpi_rsdp = (struct acpi_rsdp *) &addr[i][j];
goto rsdp_found;
}
163,17 → 163,17
rsdp_found:
printf("%#zx: ACPI Root System Description Pointer\n", acpi_rsdp);
 
acpi_rsdt = (struct acpi_rsdt *) (__native) acpi_rsdp->rsdt_address;
if (acpi_rsdp->revision) acpi_xsdt = (struct acpi_xsdt *) ((__address) acpi_rsdp->xsdt_address);
acpi_rsdt = (struct acpi_rsdt *) (unative_t) acpi_rsdp->rsdt_address;
if (acpi_rsdp->revision) acpi_xsdt = (struct acpi_xsdt *) ((uintptr_t) acpi_rsdp->xsdt_address);
 
if (acpi_rsdt) map_sdt((struct acpi_sdt_header *) acpi_rsdt);
if (acpi_xsdt) map_sdt((struct acpi_sdt_header *) acpi_xsdt);
 
if (acpi_rsdt && !acpi_sdt_check((__u8 *) acpi_rsdt)) {
if (acpi_rsdt && !acpi_sdt_check((uint8_t *) acpi_rsdt)) {
printf("RSDT: %s\n", "bad checksum");
return;
}
if (acpi_xsdt && !acpi_sdt_check((__u8 *) acpi_xsdt)) {
if (acpi_xsdt && !acpi_sdt_check((uint8_t *) acpi_xsdt)) {
printf("XSDT: %s\n", "bad checksum");
return;
}