Changeset f14291b in mainline for kernel


Ignore:
Timestamp:
2010-10-19T20:55:53Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
Children:
a93d79a
Parents:
1882525 (diff), a7a85d16 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
kernel
Files:
1 added
51 edited
1 moved

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    r1882525 rf14291b  
    120120ifeq ($(CONFIG_LTO),y)
    121121        GCC_CFLAGS += -flto
     122endif
     123
     124ifeq ($(CONFIG_LINE_DEBUG),y)
     125        GCC_CFLAGS += -g
     126        ICC_CFLAGS += -g
     127        SUNCC_CFLAGS += -g
     128        CLANG_CFLAGS += -g
    122129endif
    123130
     
    401408
    402409$(DISASM): $(RAW)
     410ifeq ($(CONFIG_LINE_DEBUG),y)
     411        $(OBJDUMP) -d -S $< > $@
     412else
    403413        $(OBJDUMP) -d $< > $@
     414endif
    404415
    405416$(RAW): $(LINK) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(SYMTAB_OBJECTS)
  • kernel/arch/amd64/_link.ld.in

    r1882525 rf14291b  
    5353        }
    5454       
     55#ifdef CONFIG_LINE_DEBUG
     56        .comment 0 : { *(.comment); }
     57        .debug_abbrev 0 : { *(.debug_abbrev); }
     58        .debug_aranges 0 : { *(.debug_aranges); }
     59        .debug_info 0 : { *(.debug_info); }
     60        .debug_line 0 : { *(.debug_line); }
     61        .debug_loc 0 : { *(.debug_loc); }
     62        .debug_pubnames 0 : { *(.debug_pubnames); }
     63        .debug_pubtypes 0 : { *(.debug_pubtypes); }
     64        .debug_ranges 0 : { *(.debug_ranges); }
     65        .debug_str 0 : { *(.debug_str); }
     66#endif
     67       
    5568        /DISCARD/ : {
    5669                *(*);
  • kernel/arch/amd64/include/pm.h

    r1882525 rf14291b  
    6565#endif /* CONFIG_FB */
    6666
    67 #define gdtselector(des)  ((des) << 3)
    68 #define idtselector(des)  ((des) << 4)
     67#define GDT_SELECTOR(des)  ((des) << 3)
    6968
    7069#define PL_KERNEL  0
     
    168167
    169168extern ptr_16_64_t gdtr;
    170 extern ptr_16_32_t bootstrap_gdtr;
    171169extern ptr_16_32_t protected_ap_gdtr;
    172170
  • kernel/arch/amd64/src/asm.S

    r1882525 rf14291b  
    244244         */
    245245        xorq %rdx, %rdx
    246         cmpq $(gdtselector(KTEXT_DES)), ISTATE_OFFSET_CS(%rsp)
     246        cmpq $(GDT_SELECTOR(KTEXT_DES)), ISTATE_OFFSET_CS(%rsp)
    247247        cmovnzq %rdx, %rbp
    248248
  • kernel/arch/amd64/src/boot/boot.S

    r1882525 rf14291b  
    8585       
    8686        /* Kernel data + stack */
    87         movw $gdtselector(KDATA_DES), %cx
     87        movw $GDT_SELECTOR(KDATA_DES), %cx
    8888        movw %cx, %es
    8989        movw %cx, %ds
     
    9494         * when _visible_ part of GS does not point to user-mode segment.
    9595         */
    96         movw $gdtselector(UDATA_DES), %cx
     96        movw $GDT_SELECTOR(UDATA_DES), %cx
    9797        movw %cx, %fs
    9898        movw %cx, %gs
    9999       
    100         jmpl $gdtselector(KTEXT32_DES), $multiboot_meeting_point
     100        jmpl $GDT_SELECTOR(KTEXT32_DES), $multiboot_meeting_point
    101101        multiboot_meeting_point:
    102102       
     
    182182       
    183183        /* At this point we are in compatibility mode */
    184         jmpl $gdtselector(KTEXT_DES), $start64
     184        jmpl $GDT_SELECTOR(KTEXT_DES), $start64
    185185
    186186/** Print string to EGA display (in light red) and halt.
     
    645645.section K_DATA_START, "aw", @progbits
    646646
    647 .global bootstrap_gdtr
    648647bootstrap_gdtr:
    649         .word gdtselector(GDT_ITEMS)
     648        .word GDT_SELECTOR(GDT_ITEMS)
    650649        .long KA2PA(gdt)
    651650
  • kernel/arch/amd64/src/boot/vesa_ret.inc

    r1882525 rf14291b  
    77       
    88        /* Kernel data + stack */
    9         movw $gdtselector(KDATA_DES), %cx
     9        movw $GDT_SELECTOR(KDATA_DES), %cx
    1010        movw %cx, %es
    1111        movw %cx, %ds
     
    1717         */
    1818       
    19         movw $gdtselector(UDATA_DES), %cx
     19        movw $GDT_SELECTOR(UDATA_DES), %cx
    2020        movw %cx, %fs
    2121        movw %cx, %gs
    2222       
    23         jmpl $gdtselector(KTEXT32_DES), $vesa_meeting_point
     23        jmpl $GDT_SELECTOR(KTEXT32_DES), $vesa_meeting_point
  • kernel/arch/amd64/src/ddi/ddi.c

    r1882525 rf14291b  
    153153        tss_descriptor_t *tss_desc = (tss_descriptor_t *) &gdt_p[TSS_DES];
    154154        tss_desc->type = AR_TSS;
    155         tr_load(gdtselector(TSS_DES));
     155        tr_load(GDT_SELECTOR(TSS_DES));
    156156       
    157157        /*
  • kernel/arch/amd64/src/pm.c

    r1882525 rf14291b  
    171171
    172172                d->unused = 0;
    173                 d->selector = gdtselector(KTEXT_DES);
     173                d->selector = GDT_SELECTOR(KTEXT_DES);
    174174
    175175                d->present = 1;
     
    291291         * to its own TSS. We just need to load the TR register.
    292292         */
    293         tr_load(gdtselector(TSS_DES));
     293        tr_load(GDT_SELECTOR(TSS_DES));
    294294}
    295295
  • kernel/arch/amd64/src/smp/ap.S

    r1882525 rf14291b  
    6161        orl $1, %eax
    6262        movl %eax, %cr0     # switch to protected mode
    63         jmpl $gdtselector(KTEXT32_DES), $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET
     63        jmpl $GDT_SELECTOR(KTEXT32_DES), $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET
    6464
    6565jump_to_kernel:
    6666.code32
    67         movw $gdtselector(KDATA_DES), %ax
     67        movw $GDT_SELECTOR(KDATA_DES), %ax
    6868        movw %ax, %ds
    6969        movw %ax, %es
    7070        movw %ax, %ss
    71         movw $gdtselector(UDATA_DES), %ax
     71        movw $GDT_SELECTOR(UDATA_DES), %ax
    7272        movw %ax, %gs
    7373       
     
    9494       
    9595        # At this point we are in compatibility mode
    96         jmpl $gdtselector(KTEXT_DES), $start64 - BOOT_OFFSET + AP_BOOT_OFFSET
     96        jmpl $GDT_SELECTOR(KTEXT_DES), $start64 - BOOT_OFFSET + AP_BOOT_OFFSET
    9797
    9898.code64
  • kernel/arch/amd64/src/syscall.c

    r1882525 rf14291b  
    5858         */
    5959        write_msr(AMD_MSR_STAR,
    60             ((uint64_t)(gdtselector(KDATA_DES) | PL_USER) << 48) |
    61             ((uint64_t)(gdtselector(KTEXT_DES) | PL_KERNEL) << 32));
     60            ((uint64_t) (GDT_SELECTOR(KDATA_DES) | PL_USER) << 48) |
     61            ((uint64_t) (GDT_SELECTOR(KTEXT_DES) | PL_KERNEL) << 32));
    6262        write_msr(AMD_MSR_LSTAR, (uint64_t)syscall_entry);
    6363        /* Mask RFLAGS on syscall
  • kernel/arch/amd64/src/userspace.c

    r1882525 rf14291b  
    6565                "xorq %%rdi, %%rdi\n"
    6666                "iretq\n"
    67                 :: [udata_des] "i" (gdtselector(UDATA_DES) | PL_USER),
     67                :: [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
    6868                   [stack_size] "r" (kernel_uarg->uspace_stack + THREAD_STACK_SIZE),
    6969                   [ipl] "r" (ipl),
    70                    [utext_des] "i" (gdtselector(UTEXT_DES) | PL_USER),
     70                   [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER),
    7171                   [entry] "r" (kernel_uarg->uspace_entry),
    7272                   [uarg] "r" (kernel_uarg->uspace_uarg)
  • kernel/arch/arm32/include/mach/integratorcp/integratorcp.h

    r1882525 rf14291b  
    105105extern void icp_get_memory_extents(uintptr_t *, uintptr_t *);
    106106extern void icp_frame_init(void);
     107extern size_t icp_get_irq_count(void);
    107108
    108109extern struct arm_machine_ops icp_machine_ops;
  • kernel/arch/arm32/include/mach/testarm/testarm.h

    r1882525 rf14291b  
    7373extern void gxemul_get_memory_extents(uintptr_t *, uintptr_t *);
    7474extern void gxemul_frame_init(void);
     75extern size_t gxemul_get_irq_count(void);
    7576
    7677extern struct arm_machine_ops gxemul_machine_ops;
  • kernel/arch/arm32/include/machine_func.h

    r1882525 rf14291b  
    5555        void (*machine_output_init)(void);
    5656        void (*machine_input_init)(void);
     57        size_t (*machine_get_irq_count)(void);
    5758};
    5859
  • kernel/arch/arm32/src/mach/gta02/gta02.c

    r1882525 rf14291b  
    4343#include <genarch/drivers/s3c24xx_irqc/s3c24xx_irqc.h>
    4444#include <genarch/drivers/s3c24xx_timer/s3c24xx_timer.h>
     45#include <genarch/srln/srln.h>
     46#include <sysinfo/sysinfo.h>
    4547#include <interrupt.h>
    4648#include <ddi/ddi.h>
     
    6870static void gta02_output_init(void);
    6971static void gta02_input_init(void);
     72static size_t gta02_get_irq_count(void);
    7073
    7174static void gta02_timer_irq_init(void);
     
    7477static void gta02_timer_irq_handler(irq_t *irq);
    7578
    76 static void *gta02_scons_out;
    77 static s3c24xx_irqc_t *gta02_irqc;
     79static outdev_t *gta02_scons_dev;
     80static s3c24xx_irqc_t gta02_irqc;
    7881static s3c24xx_timer_t *gta02_timer;
    7982
     
    8891        gta02_frame_init,
    8992        gta02_output_init,
    90         gta02_input_init
     93        gta02_input_init,
     94        gta02_get_irq_count
    9195};
    9296
    9397static void gta02_init(void)
    9498{
    95         gta02_scons_out = (void *) hw_map(GTA02_SCONS_BASE, PAGE_SIZE);
    96         gta02_irqc = (void *) hw_map(S3C24XX_IRQC_ADDRESS, PAGE_SIZE);
     99        s3c24xx_irqc_regs_t *irqc_regs;
     100
    97101        gta02_timer = (void *) hw_map(S3C24XX_TIMER_ADDRESS, PAGE_SIZE);
    98 
    99         /* Make all interrupt sources use IRQ mode (not FIQ). */
    100         pio_write_32(&gta02_irqc->intmod, 0x00000000);
    101 
    102         /* Disable all interrupt sources. */
    103         pio_write_32(&gta02_irqc->intmsk, 0xffffffff);
    104 
    105         /* Disable interrupts from all sub-sources. */
    106         pio_write_32(&gta02_irqc->intsubmsk, 0xffffffff);
     102        irqc_regs = (void *) hw_map(S3C24XX_IRQC_ADDRESS, PAGE_SIZE);
     103
     104        /* Initialize interrupt controller. */
     105        s3c24xx_irqc_init(&gta02_irqc, irqc_regs);
    107106}
    108107
     
    132131        uint32_t inum;
    133132
    134         inum = pio_read_32(&gta02_irqc->intoffset);
     133        /* Determine IRQ number. */
     134        inum = s3c24xx_irqc_inum_get(&gta02_irqc);
     135
     136        /* Clear interrupt condition in the interrupt controller. */
     137        s3c24xx_irqc_clear(&gta02_irqc, inum);
    135138
    136139        irq_t *irq = irq_dispatch_and_lock(inum);
     
    144147                    CPU->id, inum);
    145148        }
    146 
    147         /* Clear interrupt condition in the interrupt controller. */
    148         pio_write_32(&gta02_irqc->srcpnd, S3C24XX_INT_BIT(inum));
    149         pio_write_32(&gta02_irqc->intpnd, S3C24XX_INT_BIT(inum));
    150149}
    151150
     
    176175        }
    177176#endif
    178         outdev_t *scons_dev;
    179 
    180         scons_dev = s3c24xx_uart_init((ioport8_t *) gta02_scons_out);
    181         if (scons_dev)
    182                 stdout_wire(scons_dev);
     177
     178        /* Initialize serial port of the debugging console. */
     179        s3c24xx_uart_io_t *scons_io;
     180
     181        scons_io = (void *) hw_map(GTA02_SCONS_BASE, PAGE_SIZE);
     182        gta02_scons_dev = s3c24xx_uart_init(scons_io, S3C24XX_INT_UART2);
     183
     184        if (gta02_scons_dev) {
     185                /* Create output device. */
     186                stdout_wire(gta02_scons_dev);
     187        }
     188
     189        /*
     190         * This is the necessary evil until the userspace driver is entirely
     191         * self-sufficient.
     192         */
     193        sysinfo_set_item_val("s3c24xx_uart", NULL, true);
     194        sysinfo_set_item_val("s3c24xx_uart.inr", NULL, S3C24XX_INT_UART2);
     195        sysinfo_set_item_val("s3c24xx_uart.address.physical", NULL,
     196            (uintptr_t) GTA02_SCONS_BASE);
     197
    183198}
    184199
    185200static void gta02_input_init(void)
    186201{
     202        s3c24xx_uart_t *scons_inst;
     203
     204        if (gta02_scons_dev) {
     205                /* Create input device. */
     206                scons_inst = (void *) gta02_scons_dev->data;
     207
     208                srln_instance_t *srln_instance = srln_init();
     209                if (srln_instance) {
     210                        indev_t *sink = stdin_wire();
     211                        indev_t *srln = srln_wire(srln_instance, sink);
     212                        s3c24xx_uart_input_wire(scons_inst, srln);
     213
     214                        /* Enable interrupts from UART2 */
     215                        s3c24xx_irqc_src_enable(&gta02_irqc,
     216                            S3C24XX_INT_UART2);
     217
     218                        /* Enable interrupts from UART2 RXD */
     219                        s3c24xx_irqc_subsrc_enable(&gta02_irqc,
     220                            S3C24XX_SUBINT_RXD2);
     221                }
     222        }
     223
     224        /* Enable interrupts from ADC */
     225        s3c24xx_irqc_src_enable(&gta02_irqc, S3C24XX_INT_ADC);
     226
     227        /* Enable interrupts from ADC sub-sources */
     228        s3c24xx_irqc_subsrc_enable(&gta02_irqc, S3C24XX_SUBINT_ADC_S);
     229        s3c24xx_irqc_subsrc_enable(&gta02_irqc, S3C24XX_SUBINT_TC);
     230}
     231
     232size_t gta02_get_irq_count(void)
     233{
     234        return GTA02_IRQ_COUNT;
    187235}
    188236
     
    248296
    249297        /* Enable interrupts from timer0 */
    250         pio_write_32(&gta02_irqc->intmsk, pio_read_32(&gta02_irqc->intmsk) &
    251             ~S3C24XX_INT_BIT(S3C24XX_INT_TIMER0));
     298        s3c24xx_irqc_src_enable(&gta02_irqc, S3C24XX_INT_TIMER0);
    252299
    253300        /* Load data from tcntb0/tcmpb0 into tcnt0/tcmp0. */
  • kernel/arch/arm32/src/mach/integratorcp/integratorcp.c

    r1882525 rf14291b  
    6464        icp_frame_init,
    6565        icp_output_init,
    66         icp_input_init
     66        icp_input_init,
     67        icp_get_irq_count
    6768};
    6869
     
    336337}
    337338
     339size_t icp_get_irq_count(void)
     340{
     341        return ICP_IRQ_COUNT;
     342}
    338343
    339344/** @}
  • kernel/arch/arm32/src/mach/testarm/testarm.c

    r1882525 rf14291b  
    6464        gxemul_frame_init,
    6565        gxemul_output_init,
    66         gxemul_input_init
     66        gxemul_input_init,
     67        gxemul_get_irq_count
    6768};
    6869
     
    126127}
    127128
     129size_t gxemul_get_irq_count(void)
     130{
     131        return GXEMUL_IRQ_COUNT;
     132}
     133
    128134/** Starts gxemul Real Time Clock device, which asserts regular interrupts.
    129135 *
  • kernel/arch/arm32/src/machine_func.c

    r1882525 rf14291b  
    128128size_t machine_get_irq_count(void)
    129129{
    130         size_t irq_count;
    131  
    132 #if defined(MACHINE_gta02)
    133         irq_count = GTA02_IRQ_COUNT;
    134 #elif defined(MACHINE_testarm)
    135         irq_count = GXEMUL_IRQ_COUNT;
    136 #elif defined(MACHINE_integratorcp)
    137         irq_count = ICP_IRQ_COUNT;
    138 #else
    139 #error Machine type not defined.
    140 #endif
    141         return irq_count;
     130        return (machine_ops->machine_get_irq_count)();
    142131}
    143132
  • kernel/arch/ia32/include/bios/bios.h

    r1882525 rf14291b  
    3838#include <typedefs.h>
    3939
    40 #define BIOS_EBDA_PTR  0x40e
    41 
    4240extern uintptr_t ebda;
    4341
  • kernel/arch/ia32/include/mm/as.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup ia32mm 
     29/** @addtogroup ia32mm
    3030 * @{
    3131 */
  • kernel/arch/ia32/include/mm/page.h

    r1882525 rf14291b  
    2727 */
    2828
    29 /** @addtogroup ia32mm 
     29/** @addtogroup ia32mm
    3030 * @{
    3131 */
     
    106106
    107107/* Set PTE flags accessors for each level. */
    108 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \
     108#define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \
    109109        set_pt_flags((pte_t *) (ptl0), (size_t) (i), (x))
    110110#define SET_PTL2_FLAGS_ARCH(ptl1, i, x)
  • kernel/arch/ia32/include/pm.h

    r1882525 rf14291b  
    5858#endif /* CONFIG_FB */
    5959
    60 #define gdtselector(des)  ((des) << 3)
     60#define GDT_SELECTOR(des)  ((des) << 3)
    6161
    6262#define PL_KERNEL  0
     
    153153
    154154extern ptr_16_32_t gdtr;
    155 extern ptr_16_32_t bootstrap_gdtr;
    156155extern ptr_16_32_t protected_ap_gdtr;
    157156extern tss_t *tss_p;
  • kernel/arch/ia32/src/asm.S

    r1882525 rf14291b  
    225225         * Switch to kernel selectors.
    226226         */
    227         movw $(gdtselector(KDATA_DES)), %ax
     227        movw $(GDT_SELECTOR(KDATA_DES)), %ax
    228228        movw %ax, %ds
    229229        movw %ax, %es
     
    304304         * Switch to kernel selectors.
    305305         */
    306         movl $(gdtselector(KDATA_DES)), %eax
     306        movl $(GDT_SELECTOR(KDATA_DES)), %eax
    307307        movl %eax, %ds
    308308        movl %eax, %es
     
    407407         * Switch to kernel selectors.
    408408         */
    409         movl $(gdtselector(KDATA_DES)), %eax
     409        movl $(GDT_SELECTOR(KDATA_DES)), %eax
    410410        movl %eax, %ds
    411411        movl %eax, %es
     
    416416         */
    417417        xorl %eax, %eax
    418         cmpl $(gdtselector(KTEXT_DES)), ISTATE_OFFSET_CS(%esp)
     418        cmpl $(GDT_SELECTOR(KTEXT_DES)), ISTATE_OFFSET_CS(%esp)
    419419        cmovnzl %eax, %ebp
    420420
  • kernel/arch/ia32/src/bios/bios.c

    r1882525 rf14291b  
    3636#include <typedefs.h>
    3737
     38#define BIOS_EBDA_PTR  0x40e
     39
    3840uintptr_t ebda = 0;
    3941
  • kernel/arch/ia32/src/boot/boot.S

    r1882525 rf14291b  
    7878       
    7979        /* Initialize Global Descriptor Table register */
    80         lgdtl KA2PA(bootstrap_gdtr)
     80        lgdtl bootstrap_gdtr
    8181       
    8282        /* Kernel data + stack */
    83         movw $gdtselector(KDATA_DES), %cx
     83        movw $GDT_SELECTOR(KDATA_DES), %cx
    8484        movw %cx, %es
    8585        movw %cx, %fs
     
    8888        movw %cx, %ss
    8989       
    90         jmpl $gdtselector(KTEXT_DES), $multiboot_meeting_point
     90        jmpl $GDT_SELECTOR(KTEXT_DES), $multiboot_meeting_point
    9191        multiboot_meeting_point:
    9292       
     
    514514page_directory:
    515515        .space 4096, 0
     516
     517bootstrap_gdtr:
     518        .word GDT_SELECTOR(GDT_ITEMS)
     519        .long KA2PA(gdt)
    516520
    517521grub_eax:
  • kernel/arch/ia32/src/boot/vesa_real.inc

    r1882525 rf14291b  
    3030.code32
    3131vesa_init:
    32         jmp $gdtselector(VESA_INIT_DES), $vesa_init_real - vesa_init
     32        jmp $GDT_SELECTOR(VESA_INIT_DES), $vesa_init_real - vesa_init
    3333
    3434.code16
     
    335335                vesa_leave_real2:
    336336               
    337                         ljmpl $gdtselector(KTEXT32_DES), $(vesa_init_protected - vesa_init + VESA_INIT_SEGMENT << 4)
     337                        ljmpl $GDT_SELECTOR(KTEXT32_DES), $(vesa_init_protected - vesa_init + VESA_INIT_SEGMENT << 4)
    338338       
    339339        no_mode:
  • kernel/arch/ia32/src/boot/vesa_ret.inc

    r1882525 rf14291b  
    77       
    88        /* Kernel data + stack */
    9         movw $gdtselector(KDATA_DES), %cx
     9        movw $GDT_SELECTOR(KDATA_DES), %cx
    1010        movw %cx, %es
    1111        movw %cx, %fs
     
    1414        movw %cx, %ss
    1515       
    16         jmpl $gdtselector(KTEXT_DES), $vesa_meeting_point
     16        jmpl $GDT_SELECTOR(KTEXT_DES), $vesa_meeting_point
  • kernel/arch/ia32/src/ddi/ddi.c

    r1882525 rf14291b  
    153153         */
    154154        gdt_p[TSS_DES].access = AR_PRESENT | AR_TSS | DPL_KERNEL;
    155         tr_load(gdtselector(TSS_DES));
     155        tr_load(GDT_SELECTOR(TSS_DES));
    156156       
    157157        /*
  • kernel/arch/ia32/src/mm/frame.c

    r1882525 rf14291b  
    131131                        if (last_frame < ALIGN_UP(new_base + new_size, FRAME_SIZE))
    132132                                last_frame = ALIGN_UP(new_base + new_size, FRAME_SIZE);
    133                 }
    134                
    135                 if (e820table[i].type == MEMMAP_MEMORY_RESERVED) {
     133                } else if ((e820table[i].type == MEMMAP_MEMORY_ACPI) ||
     134                    (e820table[i].type == MEMMAP_MEMORY_NVS)) {
     135                        /* To be safe, make the firmware zone possibly larger */
     136                        uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE);
     137                        uint64_t new_size = ALIGN_UP(size + (base - new_base),
     138                            FRAME_SIZE);
     139                       
     140                        zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0,
     141                            ZONE_FIRMWARE);
     142                } else {
    136143                        /* To be safe, make the reserved zone possibly larger */
    137144                        uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE);
     
    141148                        zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0,
    142149                            ZONE_RESERVED);
    143                 }
    144                
    145                 if (e820table[i].type == MEMMAP_MEMORY_ACPI) {
    146                         /* To be safe, make the firmware zone possibly larger */
    147                         uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE);
    148                         uint64_t new_size = ALIGN_UP(size + (base - new_base),
    149                             FRAME_SIZE);
    150                        
    151                         zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0,
    152                             ZONE_FIRMWARE);
    153150                }
    154151        }
     
    203200#ifdef CONFIG_SMP
    204201                /* Reserve AP real mode bootstrap memory */
    205                 frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH, 
     202                frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH,
    206203                    (hardcoded_unmapped_ktext_size +
    207204                    hardcoded_unmapped_kdata_size) >> FRAME_WIDTH);
  • kernel/arch/ia32/src/pm.c

    r1882525 rf14291b  
    7575        /* VESA Init descriptor */
    7676#ifdef CONFIG_FB
    77         { 0xffff, 0, VESA_INIT_SEGMENT>>12, AR_PRESENT | AR_CODE | DPL_KERNEL, 0xf, 0, 0, 0, 0, 0 }
    78 #endif 
     77        { 0xffff, 0, VESA_INIT_SEGMENT >> 12, AR_PRESENT | AR_CODE | DPL_KERNEL, 0xf, 0, 0, 0, 0, 0 }
     78#endif
    7979};
    8080
     
    8686
    8787/* gdtr is changed by kmp before next CPU is initialized */
    88 ptr_16_32_t bootstrap_gdtr = { .limit = sizeof(gdt), .base = KA2PA((uintptr_t) gdt) };
    89 ptr_16_32_t gdtr = { .limit = sizeof(gdt), .base = (uintptr_t) gdt };
     88ptr_16_32_t gdtr = {
     89        .limit = sizeof(gdt),
     90        .base = (uintptr_t) gdt
     91};
    9092
    9193void gdt_setbase(descriptor_t *d, uintptr_t base)
     
    128130
    129131                d->unused = 0;
    130                 d->selector = gdtselector(KTEXT_DES);
     132                d->selector = GDT_SELECTOR(KTEXT_DES);
    131133
    132134                if (i == VECTOR_SYSCALL) {
     
    283285         * to its own TSS. We just need to load the TR register.
    284286         */
    285         tr_load(gdtselector(TSS_DES));
     287        tr_load(GDT_SELECTOR(TSS_DES));
    286288       
    287289        clean_IOPL_NT_flags();    /* Disable I/O on nonprivileged levels and clear NT flag. */
  • kernel/arch/ia32/src/proc/scheduler.c

    r1882525 rf14291b  
    6767        /* Set kernel stack for CPL3 -> CPL0 switch via interrupt */
    6868        CPU->arch.tss->esp0 = kstk;
    69         CPU->arch.tss->ss0 = gdtselector(KDATA_DES);
     69        CPU->arch.tss->ss0 = GDT_SELECTOR(KDATA_DES);
    7070       
    7171        /* Set up TLS in GS register */
  • kernel/arch/ia32/src/syscall.c

    r1882525 rf14291b  
    4545
    4646        /* set kernel mode CS selector */
    47         write_msr(IA32_MSR_SYSENTER_CS, gdtselector(KTEXT_DES));
     47        write_msr(IA32_MSR_SYSENTER_CS, GDT_SELECTOR(KTEXT_DES));
    4848        /* set kernel mode entry point */
    4949        write_msr(IA32_MSR_SYSENTER_EIP, (uint32_t) sysenter_handler);
  • kernel/arch/ia32/src/userspace.c

    r1882525 rf14291b  
    7575                "iret\n"
    7676                :
    77                 : [udata_des] "i" (gdtselector(UDATA_DES) | PL_USER),
     77                : [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
    7878                  [stack_size] "r" ((uint8_t *) kernel_uarg->uspace_stack + THREAD_STACK_SIZE),
    7979                  [ipl] "r" (ipl),
    80                   [utext_des] "i" (gdtselector(UTEXT_DES) | PL_USER),
     80                  [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER),
    8181                  [entry] "r" (kernel_uarg->uspace_entry),
    8282                  [uarg] "r" (kernel_uarg->uspace_uarg),
    83                   [tls_des] "r" (gdtselector(TLS_DES))
     83                  [tls_des] "r" (GDT_SELECTOR(TLS_DES))
    8484                : "eax");
    8585       
  • kernel/arch/mips32/include/context_offset.h

    r1882525 rf14291b  
    6060# define OFFSET_F30     0x5c
    6161#endif /* KERNEL */
    62 
    63 /* istate_t */
    64 #define EOFFSET_AT     0x0
    65 #define EOFFSET_V0     0x4
    66 #define EOFFSET_V1     0x8
    67 #define EOFFSET_A0     0xc
    68 #define EOFFSET_A1     0x10
    69 #define EOFFSET_A2     0x14
    70 #define EOFFSET_A3     0x18
    71 #define EOFFSET_T0     0x1c
    72 #define EOFFSET_T1     0x20
    73 #define EOFFSET_T2     0x24
    74 #define EOFFSET_T3     0x28
    75 #define EOFFSET_T4     0x2c
    76 #define EOFFSET_T5     0x30
    77 #define EOFFSET_T6     0x34
    78 #define EOFFSET_T7     0x38
    79 #define EOFFSET_T8     0x3c
    80 #define EOFFSET_T9     0x40
    81 #define EOFFSET_GP     0x44
    82 #define EOFFSET_SP     0x48
    83 #define EOFFSET_RA     0x4c
    84 #define EOFFSET_LO     0x50
    85 #define EOFFSET_HI     0x54
    86 #define EOFFSET_STATUS 0x58
    87 #define EOFFSET_EPC    0x5c
    88 #define EOFFSET_K1     0x60
    89 #define REGISTER_SPACE 104      /* respect stack alignment */
    9062
    9163#ifdef __ASM__
  • kernel/arch/mips32/include/exception.h

    r1882525 rf14291b  
    6060
    6161typedef struct istate {
     62        /*
     63         * The first seven registers are arranged so that the istate structure
     64         * can be used both for exception handlers and for the syscall handler.
     65         */
     66        uint32_t a0;    /* arg1 */
     67        uint32_t a1;    /* arg2 */
     68        uint32_t a2;    /* arg3 */
     69        uint32_t a3;    /* arg4 */
     70        uint32_t t0;    /* arg5 */
     71        uint32_t t1;    /* arg6 */
     72        uint32_t v0;    /* arg7 */
     73        uint32_t v1;
    6274        uint32_t at;
    63         uint32_t v0;
    64         uint32_t v1;
    65         uint32_t a0;
    66         uint32_t a1;
    67         uint32_t a2;
    68         uint32_t a3;
    69         uint32_t t0;
    70         uint32_t t1;
    7175        uint32_t t2;
    7276        uint32_t t3;
     
    7579        uint32_t t6;
    7680        uint32_t t7;
     81        uint32_t s0;
     82        uint32_t s1;
     83        uint32_t s2;
     84        uint32_t s3;
     85        uint32_t s4;
     86        uint32_t s5;
     87        uint32_t s6;
     88        uint32_t s7;
    7789        uint32_t t8;
    7890        uint32_t t9;
     91        uint32_t kt0;
     92        uint32_t kt1;   /* We use it as thread-local pointer */
    7993        uint32_t gp;
    8094        uint32_t sp;
     95        uint32_t s8;
    8196        uint32_t ra;
    8297       
     
    8499        uint32_t hi;
    85100       
    86         uint32_t status;  /* cp0_status */
    87         uint32_t epc;     /* cp0_epc */
    88         uint32_t k1;      /* We use it as thread-local pointer */
     101        uint32_t status;        /* cp0_status */
     102        uint32_t epc;           /* cp0_epc */
     103
     104        uint32_t alignment;     /* to make sizeof(istate_t) a multiple of 8 */
    89105} istate_t;
    90106
     
    108124NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)
    109125{
    110         /* FIXME */
    111        
    112         return 0;
     126        return istate->sp;
    113127}
    114128
  • kernel/arch/mips32/include/smp/dorder.h

    r1882525 rf14291b  
    11/*
    2  * Copyright (c) 2010 Martin Decky
     2 * Copyright (c) 2007 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup netif_standalone
    30  *  @{
     29/** @addtogroup mips32
     30 * @{
     31 */
     32/** @file
    3133 */
    3234
    33 #ifndef __NETIF_NIL_BUNDLE_H__
    34 #define __NETIF_NIL_BUNDLE_H__
     35#ifndef KERN_mips32_DORDER_H_
     36#define KERN_mips32_DORDER_H_
    3537
    36 #include <ipc/ipc.h>
    37 #include <async.h>
     38#include <typedefs.h>
    3839
    39 extern int netif_nil_module_message(const char *, ipc_callid_t, ipc_call_t *,
    40     ipc_call_t *, int *);
    41 extern int netif_nil_module_start(async_client_conn_t);
     40extern uint32_t dorder_cpuid(void);
     41extern void dorder_ipi_ack(uint32_t);
    4242
    4343#endif
  • kernel/arch/mips32/src/debug/stacktrace.c

    r1882525 rf14291b  
    3131 */
    3232/** @file
     33 */
     34
     35/*
     36 * This stack tracing code is based on the suggested algorithm described on page
     37 * 3-27 and 3-28 of:
     38 *
     39 * SYSTEM V
     40 * APPLICATION BINARY INTERFACE
     41 *
     42 * MIPS RISC Processor
     43 * Supplement
     44 * 3rd Edition
     45 *
     46 * Unfortunately, GCC generates code which is not entirely compliant with this
     47 * method. For example, it places the "jr ra" instruction quite arbitrarily in
     48 * the middle of the function which makes the original algorithm unapplicable.
     49 *
     50 * We deal with this problem by simply not using those parts of the algorithm
     51 * that rely on the "jr ra" instruction occurring in the last basic block of a
     52 * function, which gives us still usable, but less reliable stack tracer. The
     53 * unreliability stems from the fact that under some circumstances it can become
     54 * confused and produce incorrect or incomplete stack trace. We apply extra
     55 * sanity checks so that the algorithm is still safe and should not crash the
     56 * system.
     57 *
     58 * Even though not perfect, our solution is pretty lightweight, especially when
     59 * compared with a prospective alternative solution based on additional
     60 * debugging information stored directly in the kernel image.
    3361 */
    3462
     
    96124extern char ktext_end;
    97125
     126static bool bounds_check(uintptr_t pc)
     127{
     128        return (pc >= (uintptr_t) &ktext_start) &&
     129            (pc < (uintptr_t) &ktext_end);
     130}
     131
    98132static bool
    99133scan(stack_trace_context_t *ctx, uintptr_t *prev_fp, uintptr_t *prev_ra)
     
    106140        do {
    107141                inst--;
     142                if (!bounds_check((uintptr_t) inst))
     143                        return false;
    108144#if 0
    109145                /*
     
    180216                                        return false;
    181217                                /* too big offsets are suspicious */
    182                                 if (offset > 32 * 4)
     218                                if ((size_t) offset > sizeof(istate_t))
    183219                                        return false;
    184220
     
    207243{
    208244        return !((ctx->fp == 0) || ((ctx->fp % 8) != 0) ||
    209             (ctx->pc % 4 != 0) || (ctx->pc < (uintptr_t) &ktext_start) ||
    210             (ctx->pc >= (uintptr_t) &ktext_end));
     245            (ctx->pc % 4 != 0) || !bounds_check(ctx->pc));
    211246}
    212247
  • kernel/arch/mips32/src/exception.c

    r1882525 rf14291b  
    7474void istate_decode(istate_t *istate)
    7575{
    76         printf("at=%p\tv0=%p\tv1=%p\n", istate->at, istate->v0, istate->v1);
    77         printf("a0=%p\ta1=%p\ta2=%p\n", istate->a0, istate->a1, istate->a2);
    78         printf("a3=%p\tt0=%p\tt1=%p\n", istate->a3, istate->t0, istate->t1);
    79         printf("t2=%p\tt3=%p\tt4=%p\n", istate->t2, istate->t3, istate->t4);
    80         printf("t5=%p\tt6=%p\tt7=%p\n", istate->t5, istate->t6, istate->t7);
    81         printf("t8=%p\tt9=%p\tgp=%p\n", istate->t8, istate->t9, istate->gp);
    82         printf("sp=%p\tra=%p\t\n", istate->sp, istate->ra);
    83         printf("lo=%p\thi=%p\t\n", istate->lo, istate->hi);
    84         printf("cp0_status=%p\tcp0_epc=%p\tk1=%p\n",
    85             istate->status, istate->epc, istate->k1);
     76        printf("epc=%p\tsta=%p\tlo =%p\thi =%p\n",
     77            istate->epc, istate->status, istate->lo, istate->hi);
     78        printf("a0 =%p\ta1 =%p\ta2 =%p\ta3 =%p\n",
     79            istate->a0, istate->a1, istate->a2, istate->a3);
     80        printf("t0 =%p\tt1 =%p\tt2 =%p\tt3 =%p\n",
     81            istate->t0, istate->t1, istate->t2, istate->t3);
     82        printf("t4 =%p\tt5 =%p\tt6 =%p\tt7 =%p\n",
     83            istate->t4, istate->t5, istate->t6, istate->t7);
     84        printf("t8 =%p\tt9 =%p\tv0 =%p\tv1 =%p\n",
     85            istate->t8, istate->t9, istate->v0, istate->v1);
     86        printf("s0 =%p\ts1 =%p\ts2 =%p\ts3 =%p\n",
     87            istate->s0, istate->s1, istate->s2, istate->s3);
     88        printf("s4 =%p\ts5 =%p\ts6 =%p\ts7 =%p\n",
     89            istate->s4, istate->s5, istate->s6, istate->s7);
     90        printf("s8 =%p\tat =%p\tkt0=%p\tkt1=%p\n",
     91            istate->s8, istate->at, istate->kt0, istate->kt1);
     92        printf("sp =%p\tra =%p\tgp =%p\n",
     93            istate->sp, istate->ra, istate->gp);
    8694}
    8795
     
    97105                ASSERT(THREAD);
    98106                istate->epc += 4;
    99                 istate->v1 = istate->k1;
     107                istate->v1 = istate->kt1;
    100108        } else
    101109                unhandled_exception(n, istate);
  • kernel/arch/mips32/src/interrupt.c

    r1882525 rf14291b  
    3838#include <arch.h>
    3939#include <arch/cp0.h>
     40#include <arch/smp/dorder.h>
    4041#include <time/clock.h>
    4142#include <ipc/sysipc.h>
     
    4849function virtual_timer_fnc = NULL;
    4950static irq_t timer_irq;
     51static irq_t dorder_irq;
    5052
    5153// TODO: This is SMP unsafe!!!
     
    149151}
    150152
     153static irq_ownership_t dorder_claim(irq_t *irq)
     154{
     155        return IRQ_ACCEPT;
     156}
     157
     158static void dorder_irq_handler(irq_t *irq)
     159{
     160        dorder_ipi_ack(1 << dorder_cpuid());
     161}
     162
    151163/* Initialize basic tables for exception dispatching */
    152164void interrupt_init(void)
     
    163175        timer_start();
    164176        cp0_unmask_int(TIMER_IRQ);
     177       
     178        irq_initialize(&dorder_irq);
     179        dorder_irq.devno = device_assign_devno();
     180        dorder_irq.inr = DORDER_IRQ;
     181        dorder_irq.claim = dorder_claim;
     182        dorder_irq.handler = dorder_irq_handler;
     183        irq_register(&dorder_irq);
     184       
     185        cp0_unmask_int(DORDER_IRQ);
    165186}
    166187
  • kernel/arch/mips32/src/smp/dorder.c

    r1882525 rf14291b  
    3333 */
    3434
     35#include <typedefs.h>
    3536#include <smp/ipi.h>
     37#include <arch/smp/dorder.h>
     38
     39#define MSIM_DORDER_ADDRESS  0xB0000004
    3640
    3741#ifdef CONFIG_SMP
    3842
    39 #define MSIM_DORDER_ADDRESS  0xB0000004
    40 
    4143void ipi_broadcast_arch(int ipi)
    4244{
    43         *((volatile unsigned int *) MSIM_DORDER_ADDRESS) = 0x7FFFFFFF;
     45        *((volatile uint32_t *) MSIM_DORDER_ADDRESS) = 0x7fffffff;
    4446}
    4547
    4648#endif
    4749
     50uint32_t dorder_cpuid(void)
     51{
     52        return *((volatile uint32_t *) MSIM_DORDER_ADDRESS);
     53}
     54
     55void dorder_ipi_ack(uint32_t mask)
     56{
     57        *((volatile uint32_t *) (MSIM_DORDER_ADDRESS + 4)) = mask;
     58}
     59
    4860/** @}
    4961 */
  • kernel/arch/mips32/src/start.S

    r1882525 rf14291b  
    4646
    4747/*
    48  * Which status bits should are thread-local:
     48 * Which status bits are thread-local:
    4949 * KSU(UM), EXL, ERL, IE
    5050 */
    5151#define REG_SAVE_MASK 0x1f
     52
     53#define ISTATE_OFFSET_A0        0
     54#define ISTATE_OFFSET_A1        4
     55#define ISTATE_OFFSET_A2        8
     56#define ISTATE_OFFSET_A3        12
     57#define ISTATE_OFFSET_T0        16
     58#define ISTATE_OFFSET_T1        20
     59#define ISTATE_OFFSET_V0        24
     60#define ISTATE_OFFSET_V1        28
     61#define ISTATE_OFFSET_AT        32
     62#define ISTATE_OFFSET_T2        36
     63#define ISTATE_OFFSET_T3        40
     64#define ISTATE_OFFSET_T4        44
     65#define ISTATE_OFFSET_T5        48
     66#define ISTATE_OFFSET_T6        52
     67#define ISTATE_OFFSET_T7        56
     68#define ISTATE_OFFSET_S0        60
     69#define ISTATE_OFFSET_S1        64
     70#define ISTATE_OFFSET_S2        68
     71#define ISTATE_OFFSET_S3        72
     72#define ISTATE_OFFSET_S4        76
     73#define ISTATE_OFFSET_S5        80
     74#define ISTATE_OFFSET_S6        84
     75#define ISTATE_OFFSET_S7        88
     76#define ISTATE_OFFSET_T8        92
     77#define ISTATE_OFFSET_T9        96
     78#define ISTATE_OFFSET_KT0       100
     79#define ISTATE_OFFSET_KT1       104
     80#define ISTATE_OFFSET_GP        108
     81#define ISTATE_OFFSET_SP        112
     82#define ISTATE_OFFSET_S8        116
     83#define ISTATE_OFFSET_RA        120
     84#define ISTATE_OFFSET_LO        124
     85#define ISTATE_OFFSET_HI        128
     86#define ISTATE_OFFSET_STATUS    132
     87#define ISTATE_OFFSET_EPC       136
     88#define ISTATE_OFFSET_ALIGNMENT 140
     89
     90#define ISTATE_SOFT_SIZE        144
     91
     92/*
     93 * The fake ABI prologue is never executed and may not be part of the
     94 * procedure's body. Instead, it should be immediately preceding the procedure's
     95 * body. Its only purpose is to trick the stack trace walker into thinking that
     96 * the exception is more or less just a normal function call.
     97 */
     98.macro FAKE_ABI_PROLOGUE
     99        sub $sp, ISTATE_SOFT_SIZE
     100        sw $ra, ISTATE_OFFSET_EPC($sp)
     101.endm
    52102
    53103/*
     
    58108 */
    59109.macro REGISTERS_STORE_AND_EXC_RESET r
    60         sw $at, EOFFSET_AT(\r)
    61         sw $v0, EOFFSET_V0(\r)
    62         sw $v1, EOFFSET_V1(\r)
    63         sw $a0, EOFFSET_A0(\r)
    64         sw $a1, EOFFSET_A1(\r)
    65         sw $a2, EOFFSET_A2(\r)
    66         sw $a3, EOFFSET_A3(\r)
    67         sw $t0, EOFFSET_T0(\r)
    68         sw $t1, EOFFSET_T1(\r)
    69         sw $t2, EOFFSET_T2(\r)
    70         sw $t3, EOFFSET_T3(\r)
    71         sw $t4, EOFFSET_T4(\r)
    72         sw $t5, EOFFSET_T5(\r)
    73         sw $t6, EOFFSET_T6(\r)
    74         sw $t7, EOFFSET_T7(\r)
    75         sw $t8, EOFFSET_T8(\r)
    76         sw $t9, EOFFSET_T9(\r)
     110        sw $at, ISTATE_OFFSET_AT(\r)
     111        sw $v0, ISTATE_OFFSET_V0(\r)
     112        sw $v1, ISTATE_OFFSET_V1(\r)
     113        sw $a0, ISTATE_OFFSET_A0(\r)
     114        sw $a1, ISTATE_OFFSET_A1(\r)
     115        sw $a2, ISTATE_OFFSET_A2(\r)
     116        sw $a3, ISTATE_OFFSET_A3(\r)
     117        sw $t0, ISTATE_OFFSET_T0(\r)
     118        sw $t1, ISTATE_OFFSET_T1(\r)
     119        sw $t2, ISTATE_OFFSET_T2(\r)
     120        sw $t3, ISTATE_OFFSET_T3(\r)
     121        sw $t4, ISTATE_OFFSET_T4(\r)
     122        sw $t5, ISTATE_OFFSET_T5(\r)
     123        sw $t6, ISTATE_OFFSET_T6(\r)
     124        sw $t7, ISTATE_OFFSET_T7(\r)
     125        sw $t8, ISTATE_OFFSET_T8(\r)
     126        sw $t9, ISTATE_OFFSET_T9(\r)
     127        sw $s0, ISTATE_OFFSET_S0(\r)
     128        sw $s1, ISTATE_OFFSET_S1(\r)
     129        sw $s2, ISTATE_OFFSET_S2(\r)
     130        sw $s3, ISTATE_OFFSET_S3(\r)
     131        sw $s4, ISTATE_OFFSET_S4(\r)
     132        sw $s5, ISTATE_OFFSET_S5(\r)
     133        sw $s6, ISTATE_OFFSET_S6(\r)
     134        sw $s7, ISTATE_OFFSET_S7(\r)
     135        sw $s8, ISTATE_OFFSET_S8(\r)
    77136       
    78137        mflo $at
    79         sw $at, EOFFSET_LO(\r)
     138        sw $at, ISTATE_OFFSET_LO(\r)
    80139        mfhi $at
    81         sw $at, EOFFSET_HI(\r)
    82        
    83         sw $gp, EOFFSET_GP(\r)
    84         sw $ra, EOFFSET_RA(\r)
    85         sw $k1, EOFFSET_K1(\r)
     140        sw $at, ISTATE_OFFSET_HI(\r)
     141       
     142        sw $gp, ISTATE_OFFSET_GP(\r)
     143        sw $ra, ISTATE_OFFSET_RA(\r)
     144        sw $k0, ISTATE_OFFSET_KT0(\r)
     145        sw $k1, ISTATE_OFFSET_KT1(\r)
    86146       
    87147        mfc0 $t0, $status
     
    95155        and $t0, $t0, $t3
    96156       
    97         sw $t2, EOFFSET_STATUS(\r)
    98         sw $t1, EOFFSET_EPC(\r)
     157        sw $t2, ISTATE_OFFSET_STATUS(\r)
     158        sw $t1, ISTATE_OFFSET_EPC(\r)
    99159        mtc0 $t0, $status
    100160.endm
     
    106166         */
    107167        mfc0 $t0, $status
    108         lw $t1,EOFFSET_STATUS(\r)
     168        lw $t1, ISTATE_OFFSET_STATUS(\r)
    109169       
    110170        /* mask UM, EXL, ERL, IE */
     
    116176        mtc0 $t0, $status
    117177       
    118         lw $v0, EOFFSET_V0(\r)
    119         lw $v1, EOFFSET_V1(\r)
    120         lw $a0, EOFFSET_A0(\r)
    121         lw $a1, EOFFSET_A1(\r)
    122         lw $a2, EOFFSET_A2(\r)
    123         lw $a3, EOFFSET_A3(\r)
    124         lw $t0, EOFFSET_T0(\r)
    125         lw $t1, EOFFSET_T1(\r)
    126         lw $t2, EOFFSET_T2(\r)
    127         lw $t3, EOFFSET_T3(\r)
    128         lw $t4, EOFFSET_T4(\r)
    129         lw $t5, EOFFSET_T5(\r)
    130         lw $t6, EOFFSET_T6(\r)
    131         lw $t7, EOFFSET_T7(\r)
    132         lw $t8, EOFFSET_T8(\r)
    133         lw $t9, EOFFSET_T9(\r)
    134        
    135         lw $gp, EOFFSET_GP(\r)
    136         lw $ra, EOFFSET_RA(\r)
    137         lw $k1, EOFFSET_K1(\r)
    138        
    139         lw $at, EOFFSET_LO(\r)
     178        lw $v0, ISTATE_OFFSET_V0(\r)
     179        lw $v1, ISTATE_OFFSET_V1(\r)
     180        lw $a0, ISTATE_OFFSET_A0(\r)
     181        lw $a1, ISTATE_OFFSET_A1(\r)
     182        lw $a2, ISTATE_OFFSET_A2(\r)
     183        lw $a3, ISTATE_OFFSET_A3(\r)
     184        lw $t0, ISTATE_OFFSET_T0(\r)
     185        lw $t1, ISTATE_OFFSET_T1(\r)
     186        lw $t2, ISTATE_OFFSET_T2(\r)
     187        lw $t3, ISTATE_OFFSET_T3(\r)
     188        lw $t4, ISTATE_OFFSET_T4(\r)
     189        lw $t5, ISTATE_OFFSET_T5(\r)
     190        lw $t6, ISTATE_OFFSET_T6(\r)
     191        lw $t7, ISTATE_OFFSET_T7(\r)
     192        lw $t8, ISTATE_OFFSET_T8(\r)
     193        lw $t9, ISTATE_OFFSET_T9(\r)
     194       
     195        lw $gp, ISTATE_OFFSET_GP(\r)
     196        lw $ra, ISTATE_OFFSET_RA(\r)
     197        lw $k1, ISTATE_OFFSET_KT1(\r)
     198       
     199        lw $at, ISTATE_OFFSET_LO(\r)
    140200        mtlo $at
    141         lw $at, EOFFSET_HI(\r)
     201        lw $at, ISTATE_OFFSET_HI(\r)
    142202        mthi $at
    143203       
    144         lw $at, EOFFSET_EPC(\r)
     204        lw $at, ISTATE_OFFSET_EPC(\r)
    145205        mtc0 $at, $epc
    146206       
    147         lw $at, EOFFSET_AT(\r)
    148         lw $sp, EOFFSET_SP(\r)
     207        lw $at, ISTATE_OFFSET_AT(\r)
     208        lw $sp, ISTATE_OFFSET_SP(\r)
    149209.endm
    150210
     
    159219       
    160220        beq $k0, $0, 1f
    161         add $k0, $sp, 0
     221        move $k0, $sp
    162222       
    163223        /* move $k0 pointer to kernel stack */
     
    166226       
    167227        /* move $k0 (supervisor_sp) */
    168         lw $k0, 0($k0)
     228        lw $k0, ($k0)
    169229       
    170230        1:
     
    202262        nop
    203263
     264        FAKE_ABI_PROLOGUE
    204265exception_handler:
    205266        KERNEL_STACK_TO_K0
    206267       
    207         sub $k0, REGISTER_SPACE
    208         sw $sp, EOFFSET_SP($k0)
     268        sub $k0, ISTATE_SOFT_SIZE
     269        sw $sp, ISTATE_OFFSET_SP($k0)
    209270        move $sp, $k0
    210271       
     
    227288        /* the $sp is automatically restored to former value */
    228289        eret
    229 
    230 #define SS_SP      EOFFSET_SP
    231 #define SS_STATUS  EOFFSET_STATUS
    232 #define SS_EPC     EOFFSET_EPC
    233 #define SS_K1      EOFFSET_K1
    234290
    235291/** Syscall entry
     
    249305 */
    250306syscall_shortcut:
    251         /* we have a lot of space on the stack, with free use */
    252307        mfc0 $t3, $epc
    253308        mfc0 $t2, $status
    254         sw $t3, SS_EPC($sp)  /* save EPC */
    255         sw $k1, SS_K1($sp)   /* save $k1 not saved on context switch */
     309        sw $t3, ISTATE_OFFSET_EPC($sp)  /* save EPC */
     310        sw $k1, ISTATE_OFFSET_KT1($sp)  /* save $k1 not saved on context switch */
    256311       
    257312        and $t4, $t2, REG_SAVE_MASK  /* save only KSU, EXL, ERL, IE */
     
    260315        ori $t2, $t2, 0x1  /* set IE */
    261316       
    262         sw $t4, SS_STATUS($sp)
     317        sw $t4, ISTATE_OFFSET_STATUS($sp)
    263318        mtc0 $t2, $status
    264319       
    265320        /*
    266321         * Call the higher level system call handler.
    267          * We are going to reuse part of the unused exception stack frame.
    268322         *
    269323         */
    270         sw $t0, STACK_ARG4($sp)  /* save the 5th argument on the stack */
    271         sw $t1, STACK_ARG5($sp)  /* save the 6th argument on the stack */
     324        sw $t0, ISTATE_OFFSET_T0($sp)  /* save the 5th argument on the stack */
     325        sw $t1, ISTATE_OFFSET_T1($sp)  /* save the 6th argument on the stack */
    272326        jal syscall_handler
    273         sw $v0, STACK_ARG6($sp)  /* save the syscall number on the stack */
     327        sw $v0, ISTATE_OFFSET_V0($sp)  /* save the syscall number on the stack */
    274328       
    275329        /* restore status */
    276330        mfc0 $t2, $status
    277         lw $t3, SS_STATUS($sp)
     331        lw $t3, ISTATE_OFFSET_STATUS($sp)
    278332       
    279333        /*
     
    288342       
    289343        /* restore epc + 4 */
    290         lw $t2, SS_EPC($sp)
    291         lw $k1, SS_K1($sp)
     344        lw $t2, ISTATE_OFFSET_EPC($sp)
     345        lw $k1, ISTATE_OFFSET_KT1($sp)
    292346        addi $t2, $t2, 4
    293347        mtc0 $t2, $epc
    294348       
    295         lw $sp, SS_SP($sp)  /* restore $sp */
    296         eret
    297 
     349        lw $sp, ISTATE_OFFSET_SP($sp)  /* restore $sp */
     350        eret
     351
     352        FAKE_ABI_PROLOGUE
    298353tlb_refill_handler:
    299354        KERNEL_STACK_TO_K0
    300         sub $k0, REGISTER_SPACE
     355        sub $k0, ISTATE_SOFT_SIZE
    301356        REGISTERS_STORE_AND_EXC_RESET $k0
    302         sw $sp,EOFFSET_SP($k0)
    303         add $sp, $k0, 0
     357        sw $sp, ISTATE_OFFSET_SP($k0)
     358        move $sp, $k0
    304359       
    305360        jal tlb_refill
    306         add $a0, $sp, 0
     361        move $a0, $sp
    307362       
    308363        REGISTERS_LOAD $sp
    309364        eret
    310365
     366        FAKE_ABI_PROLOGUE
    311367cache_error_handler:
    312368        KERNEL_STACK_TO_K0
    313         sub $k0, REGISTER_SPACE
     369        sub $k0, ISTATE_SOFT_SIZE
    314370        REGISTERS_STORE_AND_EXC_RESET $k0
    315         sw $sp,EOFFSET_SP($k0)
    316         add $sp, $k0, 0
     371        sw $sp, ISTATE_OFFSET_SP($k0)
     372        move $sp, $k0
    317373       
    318374        jal cache_error
    319         add $a0, $sp, 0
     375        move $a0, $sp
    320376       
    321377        REGISTERS_LOAD $sp
     
    323379
    324380userspace_asm:
    325         add $sp, $a0, 0
    326         add $v0, $a1, 0
    327         add $t9, $a2, 0    /* set up correct entry into PIC code */
     381        move $sp, $a0
     382        move $v0, $a1
     383        move $t9, $a2      /* set up correct entry into PIC code */
    328384        xor $a0, $a0, $a0  /* $a0 is defined to hold pcb_ptr */
    329385                           /* set it to 0 */
  • kernel/genarch/Makefile.inc

    r1882525 rf14291b  
    9090endif
    9191
     92ifeq ($(CONFIG_S3C24XX_IRQC),y)
     93        GENARCH_SOURCES += \
     94                genarch/src/drivers/s3c24xx_irqc/s3c24xx_irqc.c
     95endif
     96
    9297ifeq ($(CONFIG_S3C24XX_UART),y)
    9398        GENARCH_SOURCES += \
  • kernel/genarch/include/drivers/s3c24xx_irqc/s3c24xx_irqc.h

    r1882525 rf14291b  
    5353        ioport32_t subsrcpnd;   /**< Sub source pending */
    5454        ioport32_t intsubmsk;   /** Interrupt sub mask */
    55 } s3c24xx_irqc_t;
     55} s3c24xx_irqc_regs_t;
    5656
    5757/** S3C24xx Interrupt source numbers.
     
    120120#define S3C24XX_SUBINT_BIT(subsource) (1 << (subsource))
    121121
     122typedef struct {
     123        s3c24xx_irqc_regs_t *regs;
     124} s3c24xx_irqc_t;
     125
     126extern void s3c24xx_irqc_init(s3c24xx_irqc_t *, s3c24xx_irqc_regs_t *);
     127extern unsigned s3c24xx_irqc_inum_get(s3c24xx_irqc_t *);
     128extern void s3c24xx_irqc_clear(s3c24xx_irqc_t *, unsigned);
     129extern void s3c24xx_irqc_src_enable(s3c24xx_irqc_t *, unsigned);
     130extern void s3c24xx_irqc_src_disable(s3c24xx_irqc_t *, unsigned);
     131extern void s3c24xx_irqc_subsrc_enable(s3c24xx_irqc_t *, unsigned);
     132extern void s3c24xx_irqc_subsrc_disable(s3c24xx_irqc_t *, unsigned);
     133
    122134#endif
    123135
  • kernel/genarch/include/drivers/s3c24xx_uart/s3c24xx_uart.h

    r1882525 rf14291b  
    3838#define KERN_S3C24XX_UART_H_
    3939
     40#include <ddi/irq.h>
     41#include <console/chardev.h>
    4042#include <typedefs.h>
    41 #include <console/chardev.h>
    4243
    43 extern outdev_t *s3c24xx_uart_init(ioport8_t *);
     44/** S3C24xx UART I/O */
     45typedef struct {
     46        uint32_t ulcon;
     47        uint32_t ucon;
     48        uint32_t ufcon;
     49        uint32_t umcon;
     50
     51        uint32_t utrstat;
     52        uint32_t uerstat;
     53        uint32_t ufstat;
     54        uint32_t umstat;
     55
     56        uint32_t utxh;
     57        uint32_t urxh;
     58
     59        uint32_t ubrdiv;
     60} s3c24xx_uart_io_t;
     61
     62/* Bits in UTRSTAT register */
     63#define S3C24XX_UTRSTAT_TX_EMPTY        0x4
     64#define S3C24XX_UTRSTAT_RDATA           0x1
     65
     66/* Bits in UFSTAT register */
     67#define S3C24XX_UFSTAT_TX_FULL          0x4000
     68#define S3C24XX_UFSTAT_RX_FULL          0x0040
     69#define S3C24XX_UFSTAT_RX_COUNT         0x002f
     70
     71/* Bits in UCON register */
     72#define UCON_RX_INT_LEVEL               0x100
     73
     74/* Bits in UFCON register */
     75#define UFCON_TX_FIFO_TLEVEL_EMPTY      0x00
     76#define UFCON_RX_FIFO_TLEVEL_1B         0x00
     77#define UFCON_FIFO_ENABLE               0x01
     78
     79
     80/** S3C24xx UART instance */
     81typedef struct {
     82        s3c24xx_uart_io_t *io;
     83        indev_t *indev;
     84        irq_t irq;
     85} s3c24xx_uart_t;
     86
     87extern outdev_t *s3c24xx_uart_init(s3c24xx_uart_io_t *, inr_t inr);
     88extern void s3c24xx_uart_input_wire(s3c24xx_uart_t *,
     89    indev_t *);
    4490
    4591#endif
  • kernel/genarch/src/drivers/s3c24xx_uart/s3c24xx_uart.c

    r1882525 rf14291b  
    4040#include <genarch/drivers/s3c24xx_uart/s3c24xx_uart.h>
    4141#include <console/chardev.h>
     42#include <console/console.h>
     43#include <ddi/device.h>
    4244#include <arch/asm.h>
    4345#include <mm/slab.h>
    44 #include <console/console.h>
    4546#include <sysinfo/sysinfo.h>
    4647#include <str.h>
    4748
    48 /** S3C24xx UART register offsets */
    49 #define S3C24XX_UTRSTAT         0x10
    50 #define S3C24XX_UTXH            0x20
    51 
    52 /* Bits in UTXH register */
    53 #define S3C24XX_UTXH_TX_EMPTY   0x4
    54 
    55 typedef struct {
    56         ioport8_t *base;
    57 } s3c24xx_uart_instance_t;
    58 
    5949static void s3c24xx_uart_sendb(outdev_t *dev, uint8_t byte)
    6050{
    61         s3c24xx_uart_instance_t *instance =
    62             (s3c24xx_uart_instance_t *) dev->data;
    63         ioport32_t *utrstat, *utxh;
     51        s3c24xx_uart_t *uart =
     52            (s3c24xx_uart_t *) dev->data;
    6453
    65         utrstat = (ioport32_t *) (instance->base + S3C24XX_UTRSTAT);
    66         utxh = (ioport32_t *) (instance->base + S3C24XX_UTXH);
    67 
    68         /* Wait for transmitter to be empty. */
    69         while ((pio_read_32(utrstat) & S3C24XX_UTXH_TX_EMPTY) == 0)
     54        /* Wait for space becoming available in Tx FIFO. */
     55        while ((pio_read_32(&uart->io->ufstat) & S3C24XX_UFSTAT_TX_FULL) != 0)
    7056                ;
    7157
    72         pio_write_32(utxh, byte);
     58        pio_write_32(&uart->io->utxh, byte);
    7359}
    7460
     
    8672}
    8773
     74static irq_ownership_t s3c24xx_uart_claim(irq_t *irq)
     75{
     76        return IRQ_ACCEPT;
     77}
     78
     79static void s3c24xx_uart_irq_handler(irq_t *irq)
     80{
     81        s3c24xx_uart_t *uart = irq->instance;
     82
     83        while ((pio_read_32(&uart->io->ufstat) & S3C24XX_UFSTAT_RX_COUNT) != 0) {
     84                uint32_t data = pio_read_32(&uart->io->urxh);
     85                pio_read_32(&uart->io->uerstat);
     86                indev_push_character(uart->indev, data & 0xff);
     87        }
     88}
     89
    8890static outdev_operations_t s3c24xx_uart_ops = {
    8991        .write = s3c24xx_uart_putchar,
     
    9193};
    9294
    93 outdev_t *s3c24xx_uart_init(ioport8_t *base)
     95outdev_t *s3c24xx_uart_init(s3c24xx_uart_io_t *io, inr_t inr)
    9496{
    9597        outdev_t *uart_dev = malloc(sizeof(outdev_t), FRAME_ATOMIC);
     
    9799                return NULL;
    98100
    99         s3c24xx_uart_instance_t *instance =
    100             malloc(sizeof(s3c24xx_uart_instance_t), FRAME_ATOMIC);
    101         if (!instance) {
     101        s3c24xx_uart_t *uart =
     102            malloc(sizeof(s3c24xx_uart_t), FRAME_ATOMIC);
     103        if (!uart) {
    102104                free(uart_dev);
    103105                return NULL;
     
    105107
    106108        outdev_initialize("s3c24xx_uart_dev", uart_dev, &s3c24xx_uart_ops);
    107         uart_dev->data = instance;
     109        uart_dev->data = uart;
    108110
    109         instance->base = base;
     111        uart->io = io;
     112        uart->indev = NULL;
     113
     114        /* Initialize IRQ structure. */
     115        irq_initialize(&uart->irq);
     116        uart->irq.devno = device_assign_devno();
     117        uart->irq.inr = inr;
     118        uart->irq.claim = s3c24xx_uart_claim;
     119        uart->irq.handler = s3c24xx_uart_irq_handler;
     120        uart->irq.instance = uart;
     121
     122        /* Enable FIFO, Tx trigger level: empty, Rx trigger level: 1 byte. */
     123        pio_write_32(&uart->io->ufcon, UFCON_FIFO_ENABLE |
     124            UFCON_TX_FIFO_TLEVEL_EMPTY | UFCON_RX_FIFO_TLEVEL_1B);
     125
     126        /* Set RX interrupt to pulse mode */
     127        pio_write_32(&uart->io->ucon,
     128            pio_read_32(&uart->io->ucon) & ~UCON_RX_INT_LEVEL);
    110129
    111130        if (!fb_exported) {
     
    116135                sysinfo_set_item_val("fb", NULL, true);
    117136                sysinfo_set_item_val("fb.kind", NULL, 3);
    118                 sysinfo_set_item_val("fb.address.physical", NULL, KA2PA(base));
     137                sysinfo_set_item_val("fb.address.physical", NULL, KA2PA(io));
    119138
    120139                fb_exported = true;
     
    124143}
    125144
     145void s3c24xx_uart_input_wire(s3c24xx_uart_t *uart, indev_t *indev)
     146{
     147        ASSERT(uart);
     148        ASSERT(indev);
     149
     150        uart->indev = indev;
     151        irq_register(&uart->irq);
     152}
     153
    126154/** @}
    127155 */
  • kernel/generic/include/ddi/ddi.h

    r1882525 rf14291b  
    5454extern unative_t sys_physmem_map(unative_t, unative_t, unative_t, unative_t);
    5555extern unative_t sys_iospace_enable(ddi_ioarg_t *);
    56 extern unative_t sys_preempt_control(int);
    5756
    5857/*
  • kernel/generic/include/security/cap.h

    r1882525 rf14291b  
    7070
    7171/**
    72  * CAP_PREEMPT_CONTROL allows its holder to disable/enable preemption.
    73  */
    74 #define CAP_PREEMPT_CONTROL     (1<<3)
    75 
    76 /**
    7772 * CAP_IRQ_REG entitles its holder to register IRQ handlers.
    7873 */
    79 #define CAP_IRQ_REG             (1<<4)
     74#define CAP_IRQ_REG             (1<<3)
    8075
    8176typedef uint32_t cap_t;
  • kernel/generic/include/syscall/syscall.h

    r1882525 rf14291b  
    8080        SYS_PHYSMEM_MAP,
    8181        SYS_IOSPACE_ENABLE,
    82         SYS_PREEMPT_CONTROL,
    8382       
    8483        SYS_SYSINFO_GET_TAG,
  • kernel/generic/src/ddi/ddi.c

    r1882525 rf14291b  
    258258}
    259259
    260 /** Disable or enable preemption.
    261  *
    262  * @param enable If non-zero, the preemption counter will be decremented,
    263  *               leading to potential enabling of preemption. Otherwise
    264  *               the preemption counter will be incremented, preventing
    265  *               preemption from occurring.
    266  *
    267  * @return Zero on success or EPERM if callers capabilities are not sufficient.
    268  *
    269  */
    270 unative_t sys_preempt_control(int enable)
    271 {
    272         if (!(cap_get(TASK) & CAP_PREEMPT_CONTROL))
    273                 return EPERM;
    274        
    275         if (enable)
    276                 preemption_enable();
    277         else
    278                 preemption_disable();
    279        
    280         return 0;
    281 }
    282 
    283260/** @}
    284261 */
  • kernel/generic/src/main/kinit.c

    r1882525 rf14291b  
    208208                         */
    209209                        cap_set(programs[i].task, CAP_CAP | CAP_MEM_MANAGER |
    210                             CAP_IO_MANAGER | CAP_PREEMPT_CONTROL | CAP_IRQ_REG);
     210                            CAP_IO_MANAGER | CAP_IRQ_REG);
    211211                       
    212212                        if (!ipc_phone_0)
  • kernel/generic/src/mm/frame.c

    r1882525 rf14291b  
    161161        for (j = zones.count; j > i; j--) {
    162162                zones.info[j] = zones.info[j - 1];
    163                 zones.info[j].buddy_system->data =
    164                     (void *) &zones.info[j - 1];
     163                if (zones.info[j].buddy_system != NULL)
     164                        zones.info[j].buddy_system->data =
     165                            (void *) &zones.info[j];
    165166        }
    166167       
     
    762763        for (i = z2 + 1; i < zones.count; i++) {
    763764                zones.info[i - 1] = zones.info[i];
    764                 zones.info[i - 1].buddy_system->data =
    765                     (void *) &zones.info[i - 1];
     765                if (zones.info[i - 1].buddy_system != NULL)
     766                        zones.info[i - 1].buddy_system->data =
     767                            (void *) &zones.info[i - 1];
    766768        }
    767769       
  • kernel/generic/src/syscall/syscall.c

    r1882525 rf14291b  
    159159        (syshandler_t) sys_physmem_map,
    160160        (syshandler_t) sys_iospace_enable,
    161         (syshandler_t) sys_preempt_control,
    162161       
    163162        /* Sysinfo syscalls */
Note: See TracChangeset for help on using the changeset viewer.