Changeset dabe6333 in mainline


Ignore:
Timestamp:
2006-03-16T15:56:40Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1ee9ced
Parents:
37e7d2b9
Message:

Added null console for buffering output when no real output available.
Added identity mapper for AMD64 that allows whole physical memory to be
accessed before paging is initialized.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/include/interrupt.h

    r37e7d2b9 rdabe6333  
    100100extern void trap_virtual_disable_irqs(__u16 irqmask);
    101101extern void trap_virtual_eoi(void);
     102/* AMD64 - specific page handler */
     103extern void ident_page_fault(int n, istate_t *istate);
    102104
    103105#endif
  • arch/amd64/src/interrupt.c

    r37e7d2b9 rdabe6333  
    103103}
    104104
     105
     106/* Definitions for identic page mapper */
     107pte_t helper_ptl1[512] __attribute__((aligned (PAGE_SIZE)));
     108pte_t helper_ptl2[512] __attribute__((aligned (PAGE_SIZE)));
     109pte_t helper_ptl3[512] __attribute__((aligned (PAGE_SIZE)));
     110extern pte_t ptl_0; /* From boot.S */
     111
     112#define PTL1_PRESENT(ptl0, page) (!(GET_PTL1_FLAGS_ARCH(ptl0, PTL0_INDEX_ARCH(page)) & PAGE_NOT_PRESENT))
     113#define PTL2_PRESENT(ptl1, page) (!(GET_PTL2_FLAGS_ARCH(ptl1, PTL1_INDEX_ARCH(page)) & PAGE_NOT_PRESENT))
     114#define PTL3_PRESENT(ptl2, page) (!(GET_PTL3_FLAGS_ARCH(ptl2, PTL2_INDEX_ARCH(page)) & PAGE_NOT_PRESENT))
     115
     116#define PTL1_ADDR(ptl0, page) ((pte_t *)PA2KA(GET_PTL1_ADDRESS_ARCH(ptl0, PTL0_INDEX_ARCH(page))))
     117#define PTL2_ADDR(ptl1, page) ((pte_t *)PA2KA(GET_PTL2_ADDRESS_ARCH(ptl1, PTL1_INDEX_ARCH(page))))
     118#define PTL3_ADDR(ptl2, page) ((pte_t *)PA2KA(GET_PTL3_ADDRESS_ARCH(ptl2, PTL2_INDEX_ARCH(page))))
     119
     120#define SETUP_PTL1(ptl0, page, tgt)  {  \
     121        SET_PTL1_ADDRESS_ARCH(ptl0, PTL0_INDEX_ARCH(page), (__address)KA2PA(tgt)); \
     122        SET_PTL1_FLAGS_ARCH(ptl0, PTL0_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \
     123    }
     124#define SETUP_PTL2(ptl1, page, tgt)  {  \
     125        SET_PTL2_ADDRESS_ARCH(ptl1, PTL1_INDEX_ARCH(page), (__address)KA2PA(tgt)); \
     126        SET_PTL2_FLAGS_ARCH(ptl1, PTL1_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \
     127    }
     128#define SETUP_PTL3(ptl2, page, tgt)  {  \
     129        SET_PTL3_ADDRESS_ARCH(ptl2, PTL2_INDEX_ARCH(page), (__address)KA2PA(tgt)); \
     130        SET_PTL3_FLAGS_ARCH(ptl2, PTL2_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \
     131    }
     132#define SETUP_FRAME(ptl3, page, tgt)  { \
     133        SET_FRAME_ADDRESS_ARCH(ptl3, PTL3_INDEX_ARCH(page), (__address)KA2PA(tgt)); \
     134        SET_FRAME_FLAGS_ARCH(ptl3, PTL3_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \
     135    }
     136
     137/** Identic page mapper
     138 *
     139 * We need to map whole physical memory identically before the page subsystem
     140 * is initializaed. This thing clears page table and fills in the specific
     141 * items.
     142 */
     143void ident_page_fault(int n, istate_t *istate)
     144{
     145        __address page;
     146        static __address oldpage = 0;
     147        pte_t *aptl_1, *aptl_2, *aptl_3;
     148
     149        page = read_cr2();
     150        if (oldpage) {
     151                /* Unmap old address */
     152                aptl_1 = PTL1_ADDR(&ptl_0, oldpage);
     153                aptl_2 = PTL2_ADDR(aptl_1, oldpage);
     154                aptl_3 = PTL3_ADDR(aptl_2, oldpage);
     155
     156                SET_FRAME_FLAGS_ARCH(aptl_3, PTL3_INDEX_ARCH(oldpage), PAGE_NOT_PRESENT);
     157                if (aptl_3 == helper_ptl3)
     158                        SET_PTL3_FLAGS_ARCH(aptl_2, PTL2_INDEX_ARCH(oldpage), PAGE_NOT_PRESENT);
     159                if (aptl_2 == helper_ptl2)
     160                        SET_PTL2_FLAGS_ARCH(aptl_1, PTL1_INDEX_ARCH(oldpage), PAGE_NOT_PRESENT);
     161                if (aptl_1 == helper_ptl1)
     162                        SET_PTL1_FLAGS_ARCH(&ptl_0, PTL0_INDEX_ARCH(oldpage), PAGE_NOT_PRESENT);
     163        }
     164        if (PTL1_PRESENT(&ptl_0, page))
     165                aptl_1 = PTL1_ADDR(&ptl_0, page);
     166        else {
     167                SETUP_PTL1(&ptl_0, page, helper_ptl1);
     168                aptl_1 = helper_ptl1;
     169        }
     170           
     171        if (PTL2_PRESENT(aptl_1, page))
     172                aptl_2 = PTL2_ADDR(aptl_1, page);
     173        else {
     174                SETUP_PTL2(aptl_1, page, helper_ptl2);
     175                aptl_2 = helper_ptl2;
     176        }
     177
     178        if (PTL3_PRESENT(aptl_2, page))
     179                aptl_3 = PTL3_ADDR(aptl_2, page);
     180        else {
     181                SETUP_PTL3(aptl_2, page, helper_ptl3);
     182                aptl_3 = helper_ptl3;
     183        }
     184       
     185        SETUP_FRAME(aptl_3, page, page);
     186
     187        oldpage = page;
     188}
     189
    105190void page_fault(int n, istate_t *istate)
    106191{
  • arch/amd64/src/pm.c

    r37e7d2b9 rdabe6333  
    175175        exc_register( 7, "nm_fault", nm_fault);
    176176        exc_register(12, "ss_fault", ss_fault);
     177        exc_register(14, "ident_mapper", ident_page_fault);
    177178}
    178179
  • generic/include/ipc/ipc.h

    r37e7d2b9 rdabe6333  
    3838
    3939/* Flags for calls */
    40 #define IPC_CALL_ANSWERED      1 /**< This is answer to a call */
    41 #define IPC_CALL_STATIC_ALLOC  2 /**< This call will not be freed on error */
     40#define IPC_CALL_ANSWERED      0x1 /**< This is answer to a call */
     41#define IPC_CALL_STATIC_ALLOC  0x2 /**< This call will not be freed on error */
     42#define IPC_CALL_DISPATCHED    0x4 /**< Call is in dispatch queue */
    4243
    4344/* Flags for ipc_wait_for_call */
  • generic/src/console/console.c

    r37e7d2b9 rdabe6333  
    3939#include <arch/atomic.h>
    4040
     41#define BUFLEN 2048
     42static char debug_buffer[BUFLEN];
     43static size_t offset = 0;
     44/** Initialize stdout to something that does not print, but does not fail
     45 *
     46 * Save data in some buffer so that it could be retrieved in the debugger
     47 */
     48static void null_putchar(chardev_t *d, const char ch)
     49{
     50        if (offset >= BUFLEN)
     51                offset = 0;
     52        debug_buffer[offset++] = ch;
     53}
     54
     55static chardev_operations_t null_stdout_ops = {
     56        .write = null_putchar
     57};
     58chardev_t null_stdout = {
     59        .name = "null",
     60        .op = &null_stdout_ops
     61};
     62
    4163/** Standard input character device. */
    4264chardev_t *stdin = NULL;
    43 chardev_t *stdout = NULL;
     65chardev_t *stdout = &null_stdout;
    4466
    4567/** Get character from character device. Do not echo character.
  • generic/src/ipc/ipc.c

    r37e7d2b9 rdabe6333  
    185185        answerbox_t *callerbox = request->callerbox;
    186186
     187        request->flags &= ~IPC_CALL_DISPATCHED;
    187188        request->flags |= IPC_CALL_ANSWERED;
    188189
     
    218219                        /* Append request to dispatch queue */
    219220                        list_append(&request->list, &box->dispatched_calls);
     221                        request->flags |= IPC_CALL_DISPATCHED;
    220222                } else {
    221223                        if (!(flags & IPC_WAIT_NONBLOCKING)) {
Note: See TracChangeset for help on using the changeset viewer.