Changeset 99 for trunk/hal


Ignore:
Timestamp:
Jun 29, 2017, 3:48:39 PM (7 years ago)
Author:
max@…
Message:

add the irq functions; we will forbid nested critical sections, so
the argument will disappear soon

Location:
trunk/hal/x86_64/core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/x86_64/core/hal_cpu.S

    r98 r99  
    9191        ret
    9292
     93ASM_ENTRY(rcr2)
     94        movq    %cr2,%rax
     95        ret
     96
    9397ASM_ENTRY(x86_stop) /* debug only */
    9498        int     $0x0b
  • trunk/hal/x86_64/core/hal_init.c

    r94 r99  
    2828#include <hal_internal.h>
    2929#include <hal_remote.h>
     30#include <hal_irqmask.h>
    3031
    3132#include <memcpy.h>
     
    181182        xptr_t myptr = XPTR(0, &mytest);
    182183
    183         hal_remote_atomic_add(myptr, 3);
    184         x86_printf("-> mytest = %z\n", mytest);
    185 
    186184        hal_remote_spt(myptr, hoho);
    187185        x86_printf("-> mytest = %Z\n", hal_remote_lpt(myptr));
    188186
    189 
    190187        init_bootinfo(&btinfo);
     188
     189        reg_t dummy;
     190        hal_enable_irq(&dummy);
     191
    191192        kernel_init(&btinfo);
     193
    192194        x86_printf("[+] kernel_init called\n");
     195
     196        while (1);
    193197
    194198//      void x86_stop();
    195199//      x86_stop();
    196 
    197         sti();
    198         while (1);
    199200
    200201        int m = 0;
  • trunk/hal/x86_64/core/hal_internal.h

    r98 r99  
    4040uint64_t rdmsr(uint32_t);
    4141void wrmsr(uint32_t, uint64_t);
     42vaddr_t rcr2(void);
    4243
    4344uint32_t atomic_cas_32(volatile uint32_t *ptr, uint32_t exp, uint32_t new);
  • trunk/hal/x86_64/core/hal_irqmask.c

    r51 r99  
    11/*
    2  * hal_irqmask.c - implementation of Generic IRQ Masking API for TSAR-MIPS32
    3  *
    4  * Author  Ghassan Almaless (2008,2009,2010,2011,2012)
    5  *         Alain Greiner    (2016)
     2 * hal_irqmask.c - implementation of Generic IRQ Masking API for x86
    63 *
    7  * Copyright (c) UPMC Sorbonne Universites
    8  *
    9  * This file is part of ALMOS-MKH..
     4 * Copyright (c) 2017 Maxime Villard
    105 *
    11  * ALMOS-MKH. is free software; you can redistribute it and/or modify it
     6 * This file is part of ALMOS-MKH.
     7 *
     8 * ALMOS-MKH is free software; you can redistribute it and/or modify it
    129 * under the terms of the GNU General Public License as published by
    1310 * the Free Software Foundation; version 2.0 of the License.
    1411 *
    15  * ALMOS-MKH. is distributed in the hope that it will be useful, but
     12 * ALMOS-MKH is distributed in the hope that it will be useful, but
    1613 * WITHOUT ANY WARRANTY; without even the implied warranty of
    1714 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     
    2623#include <hal_internal.h>
    2724
    28 inline void hal_disable_irq( uint32_t * old )
     25static int interrupts_enabled __in_kdata = 0;
     26
     27inline void hal_disable_irq(uint32_t *old)
     28{
     29        if (!interrupts_enabled) {
     30                x86_panic("nested critical sections forbidden");
     31        }
     32        interrupts_enabled = 0;
     33        cli();
     34}
     35
     36inline void hal_enable_irq(uint32_t *old)
     37{
     38        if (interrupts_enabled) {
     39                x86_panic("nested critical sections forbidden");
     40        }
     41        interrupts_enabled = 1;
     42        sti();
     43}
     44
     45inline void hal_restore_irq(uint32_t old)
    2946{
    3047        x86_panic((char *)__func__);
    3148}
    3249
    33 inline void hal_enable_irq( uint32_t * old )
    34 {
    35         x86_panic((char *)__func__);
    36 }
    37 
    38 inline void hal_restore_irq( uint32_t old )
    39 {
    40         x86_panic((char *)__func__);
    41 }
    42 
  • trunk/hal/x86_64/core/hal_trap.c

    r91 r99  
    6969        x86_printf("-> rsp = %Z\n", tf->tf_rsp);
    7070        x86_printf("-> err = %Z\n", tf->tf_err);
     71        if (trapno == T_PAGEFLT)
     72                x86_printf("-> va  = %Z\n", rcr2());
    7173        x86_printf("****** FAULT OCCURRED ******\n\n");
    7274
Note: See TracChangeset for help on using the changeset viewer.