Changeset 93165be in mainline


Ignore:
Timestamp:
2006-03-16T23:54:05Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5fceec7
Parents:
ff14c520
Message:

Add support for more then 2GB of address space for AMD64.

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/include/mm/as.h

    rff14c520 r93165be  
    3232#include <arch/types.h>
    3333
    34 #define KERNEL_ADDRESS_SPACE_START_ARCH         (__address) 0xffffffff80000000
     34#define KERNEL_ADDRESS_SPACE_START_ARCH         (__address) 0xffff800000000000
    3535#define KERNEL_ADDRESS_SPACE_END_ARCH           (__address) 0xffffffffffffffff
    3636#define USER_ADDRESS_SPACE_START_ARCH           (__address) 0x0000000000000000
  • arch/amd64/include/mm/page.h

    rff14c520 r93165be  
    2727 */
    2828
     29/** Paging on AMD64
     30 *
     31 * The space is divided in positive numbers - userspace and
     32 * negative numbers - kernel space. The 'negative' space starting
     33 * with 0xffff800000000000 and ending with 0xffffffff80000000
     34 * (-2GB) is identically mapped physical memory. The area
     35 * (0xffffffff80000000 ... 0xffffffffffffffff is again identically
     36 * mapped first 2GB.
     37 *
     38 * ATTENTION - PA2KA(KA2PA(x)) != x if 'x' is in kernel
     39 */
     40
    2941#ifndef __amd64_PAGE_H__
    3042#define __amd64_PAGE_H__
     
    4355
    4456#ifndef __ASM__
    45 # define KA2PA(x)      (((__address) (x)) - 0xffffffff80000000)
    46 # define PA2KA(x)      (((__address) (x)) + 0xffffffff80000000)
     57static inline __address ka2pa(__address x)
     58{
     59        if (x > 0xffffffff80000000)
     60                return x - 0xffffffff80000000;
     61        else
     62                return x - 0xffff800000000000;
     63}
     64/* Linker symbol */
     65extern int ktext_start;
     66extern int kdata_end;
     67static inline __address pa2ka(__address x)
     68{
     69        if (x >= ka2pa((__address)(&kdata_end)) || \
     70            x <= ka2pa((__address)&ktext_start))
     71                return x + 0xffff800000000000;
     72        else
     73                return x + 0xffffffff80000000;
     74}
     75# define KA2PA(x)      ka2pa((__address)x)
     76# define PA2KA(x)      pa2ka((__address)x)
     77# define PA2KA_IDENT(x)      (((__address) (x)) + 0xffff800000000000)
     78# define PA2KA_CODE(x)      (((__address) (x)) + 0xffffffff80000000)
    4779#else
    4880# define KA2PA(x)      ((x) - 0xffffffff80000000)
    4981# define PA2KA(x)      ((x) + 0xffffffff80000000)
     82# define PA2KA_DATA(x)      ((x) + 0xffff800000000000)
    5083#endif
    5184
  • arch/amd64/src/boot/boot.S

    rff14c520 r93165be  
    175175                        xorq %rdx, %rdx
    176176                        movl 0(%esi), %edx                                      # mods->mod_start
    177                         addq $0xffffffff80000000, %rdx
     177                        movq $0xffff800000000000, %r10
     178                        addq %r10, %rdx
    178179                        movq %rdx, 8(%rdi)
    179180                       
     
    304305ptl_0:
    305306        .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
    306         .fill 510,8,0
     307        .fill 255,8,0
     308        .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
     309        .fill 254,8,0
    307310        .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
    308311
  • arch/amd64/src/mm/page.c

    rff14c520 r93165be  
    4040#include <print.h>
    4141#include <panic.h>
     42#include <align.h>
    4243
    4344/* Definitions for identity page mapper */
     
    7172        SET_FRAME_FLAGS_ARCH(ptl3, PTL3_INDEX_ARCH(page), PAGE_WRITE | PAGE_EXEC); \
    7273    }
    73 
    7474void page_arch_init(void)
    7575{
    7676        __address cur;
    77         int flags;
     77        int i;
     78        int identity_flags = PAGE_CACHEABLE | PAGE_EXEC | PAGE_GLOBAL;
    7879
    7980        if (config.cpu_active == 1) {
     
    8485                 */
    8586                for (cur = 0; cur < last_frame; cur += FRAME_SIZE) {
    86                         flags = PAGE_CACHEABLE | PAGE_EXEC;
    87                         if ((PA2KA(cur) >= config.base) && (PA2KA(cur) < config.base + config.kernel_size))
    88                                 flags |= PAGE_GLOBAL;
    89                         page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags);
     87                        /* Standard identity mapping */
     88                        page_mapping_insert(AS_KERNEL, PA2KA_IDENT(cur), cur, identity_flags);
    9089                }
     90                /* Upper kernel mapping
     91                 * - from zero to top of kernel (include bottom addresses
     92                 *   because some are needed for init )
     93                 */
     94                for (cur = PA2KA_CODE(0); cur < config.base+config.kernel_size; cur += FRAME_SIZE) {
     95                        page_mapping_insert(AS_KERNEL, cur, KA2PA(cur), identity_flags);
     96                }
     97                for (i=0; i < init.cnt; i++) {
     98                        for (cur=init.tasks[i].addr;cur < init.tasks[i].size; cur += FRAME_SIZE) {
     99                                page_mapping_insert(AS_KERNEL, PA2KA_CODE(KA2PA(cur)), KA2PA(cur), identity_flags);
     100                        }
     101                }
     102
    91103                exc_register(14, "page_fault", (iroutine)page_fault);
    92104                write_cr3((__address) AS_KERNEL->page_table);
  • generic/include/macros.h

    rff14c520 r93165be  
    4040#define max(a,b)        ((a)>(b)?(a):(b))
    4141
     42/* Return true if the interlvals overlap */
     43static inline int overlaps(__address s1,size_t sz1, __address s2, size_t sz2)
     44{
     45        __address e1 = s1+sz1;
     46        __address e2 = s2+sz2;
     47
     48        return s1 < e2 && s2 < e1;
     49}
     50/* Compute overlapping of physical addresses */
     51#define PA_overlaps(x,szx,y,szy)  overlaps(KA2PA(x),szx,KA2PA(y), szy)
     52
    4253#endif
  • generic/include/mm/frame.h

    rff14c520 r93165be  
    6262#define FRAME_ERROR             2       /* frame_alloc return status */
    6363
    64 /* Return true if the interlvals overlap */
    65 static inline int overlaps(__address s1,__address sz1, __address s2, __address sz2)
    66 {
    67         __address e1 = s1+sz1;
    68         __address e2 = s2+sz2;
    69 
    70         return s1 < e2 && s2 < e1;
    71 }
    72 
    7364static inline __address PFN2ADDR(pfn_t frame)
    7465{
  • generic/src/ipc/sysipc.c

    rff14c520 r93165be  
    165165                /* If the users accepted call, connect */
    166166                if (!IPC_GET_RETVAL(answer->data)) {
    167                         printf("Connecting Phone %P\n",IPC_GET_ARG3(*olddata));
    168167                        ipc_phone_connect((phone_t *)IPC_GET_ARG3(*olddata),
    169168                                          &TASK->answerbox);
  • generic/src/main/main.c

    rff14c520 r93165be  
    5656#include <typedefs.h>
    5757#include <ipc/ipc.h>
     58#include <macros.h>
    5859
    5960#ifdef CONFIG_SMP
     
    117118        bool overlap = false;
    118119        for (i = 0; i < init.cnt; i++)
    119                 if (overlaps(stackaddr, CONFIG_STACK_SIZE, init.tasks[i].addr, init.tasks[i].size)) {
     120                if (PA_overlaps(stackaddr, CONFIG_STACK_SIZE, init.tasks[i].addr, init.tasks[i].size)) {
    120121                        stackaddr = ALIGN_UP(init.tasks[i].addr + init.tasks[i].size, CONFIG_STACK_SIZE);
    121122                        init.tasks[i].size = ALIGN_UP(init.tasks[i].size, CONFIG_STACK_SIZE) + CONFIG_STACK_SIZE;
  • generic/src/mm/frame.c

    rff14c520 r93165be  
    5252#include <mm/slab.h>
    5353#include <bitops.h>
     54#include <macros.h>
    5455
    5556typedef struct {
Note: See TracChangeset for help on using the changeset viewer.