Changeset 47 for trunk/hal/x86_64


Ignore:
Timestamp:
Jun 26, 2017, 11:48:28 AM (7 years ago)
Author:
max@…
Message:

Use mcmodel=large, in order to have a kernel image that is located at the
beginning of each cluster in virtual memory, as discussed with Alain. The
performance cost will be taken care of later.

Now, the active kernel is located at 0xfffff00000000000, and the base of
the clusters is 0xffff800000000000.

Location:
trunk/hal/x86_64
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/x86_64/hal_boot.h

    r44 r47  
    2424#define PGSHIFT         12
    2525
    26 #define KERNBASE        0xffffffff80000000
    27 #define KERNBASE_HI     0xffffffff
    28 #define KERNBASE_LO     0x80000000
     26#define KERNBASE        0xfffff00000000000
     27#define KERNBASE_HI     0xfffff000
     28#define KERNBASE_LO     0x00000000
    2929
    30 #define KERNTEXTOFF     0xffffffff80200000
    31 #define KERNTEXTOFF_HI  0xffffffff
    32 #define KERNTEXTOFF_LO  0x80200000
     30#define KERNTEXTOFF     0xfffff00000200000
     31#define KERNTEXTOFF_HI  0xfffff000
     32#define KERNTEXTOFF_LO  0x00200000
    3333
    3434/* -------------------------------------------------------------------------- */
     
    109109
    110110#define L4_SLOT_PTE             255
    111 #define L4_SLOT_KERN            256
    112 #define L4_SLOT_KERNBASE        511
     111#define L4_SLOT_KERNBASE        480
    113112
    114113/*
     
    116115 * L2 = (KERNBASE % NBPD_L3) / NBPD_L2
    117116 */
    118 #define L3_SLOT_KERNBASE        510
     117#define L3_SLOT_KERNBASE        0
    119118#define L2_SLOT_KERNBASE        0
    120119
    121 #define PDIR_SLOT_KERN  L4_SLOT_KERN
    122120#define PDIR_SLOT_PTE   L4_SLOT_PTE
    123121
     
    132130/* -------------------------------------------------------------------------- */
    133131
    134 /*
    135  * There are two arrays: one for the heap, one for the kernel image. They are
    136  * separated by 64TB of VA, which is more than enough to avoid collision.
    137  */
    138 #define CLUSTERS_HEAP_BASE_VA   0xffff800000000000
    139 #define CLUSTERS_KIMG_BASE_VA   0xffffc00000000000
     132#define KERNEL_VA_SIZE          (NKL2_KIMG_ENTRIES * NBPD_L2)
     133#define CLUSTERS_BASE_VA        0xffff800000000000
    140134
    141135/* These parameters are configurable. */
    142 #define CLUSTER_HEAP_VA_SIZE    0x100000000 /* 4GB */
    143 #define CLUSTER_HEAP_PA_SIZE    0x200000000 /* 8GB */
     136#define CLUSTER_VA_SIZE 0x100000000 /* 4GB */
     137#define CLUSTER_PA_SIZE 0x200000000 /* 8GB */
    144138
    145 /* These parameters are *not* configurable. */
    146 #define CLUSTER_KIMG_VA_SIZE    0x80000000  /* 2GB */
     139/* Macros to get the VA ranges for a cluster */
     140#define CLUSTER_MIN_VA(n) \
     141        (CLUSTERS_BASE_VA + n * CLUSTER_VA_SIZE)
     142#define CLUSTER_MAX_VA(n) \
     143        (CLUSTER_MIN_VA(n) + CLUSTER_VA_SIZE)
    147144
    148 /* Macros to get the heap/kimg ranges for a cluster */
    149 #define CLUSTER_HEAP_MIN_VA(n) \
    150         (CLUSTERS_HEAP_BASE_VA + n * CLUSTER_HEAP_VA_SIZE)
    151 #define CLUSTER_HEAP_MAX_VA(n) \
    152         (CLUSTER_HEAP_MIN_VA(n) + CLUSTER_HEAP_VA_SIZE)
    153 #define CLUSTER_KIMG_MIN_VA(n) \
    154         (CLUSTERS_KIMG_BASE_VA + n * CLUSTER_KIMG_VA_SIZE)
    155 #define CLUSTER_KIMG_MAX_VA(n) \
    156         (CLUSTER_KIMG_MIN_VA(n) + CLUSTER_KIMG_VA_SIZE)
    157 
  • trunk/hal/x86_64/hal_gpt.c

    r45 r47  
    7171void hal_gpt_bootstrap_reset()
    7272{
    73         size_t npages = (va_avail - CLUSTER_HEAP_MIN_VA(0)) / PAGE_SIZE;
    74         hal_gpt_leave_range(CLUSTER_HEAP_MIN_VA(0), npages);
     73        size_t npages = (va_avail - (CLUSTER_MIN_VA(0) + KERNEL_VA_SIZE)) / PAGE_SIZE;
     74        hal_gpt_leave_range(CLUSTER_MIN_VA(0) + KERNEL_VA_SIZE, npages);
    7575}
    7676
     
    211211        /* Initialize global values */
    212212        pa_avail = firstpa;
    213         va_avail = CLUSTER_HEAP_MIN_VA(0);
     213        va_avail = CLUSTER_MIN_VA(0) + KERNEL_VA_SIZE;
    214214        kimg_size = ((uint64_t)&__kernel_end - KERNBASE);
    215215        XASSERT(kimg_size % PAGE_SIZE == 0);
     
    217217
    218218        /* Create cluster0's heap entry. */
    219         hal_gpt_maptree_area(CLUSTER_HEAP_MIN_VA(0), CLUSTER_HEAP_MAX_VA(0));
    220 
    221         /* Create cluster0's kimg entry. */
    222         hal_gpt_maptree_area(CLUSTER_KIMG_MIN_VA(0), CLUSTER_KIMG_MAX_VA(0));
     219        hal_gpt_maptree_area(CLUSTER_MIN_VA(0), CLUSTER_MAX_VA(0));
    223220
    224221        /* Manually enter cluster0's kimg */
    225         hal_gpt_enter_range(CLUSTER_KIMG_MIN_VA(0), kimg_min_pa, kimg_size);
     222        hal_gpt_enter_range(CLUSTER_MIN_VA(0), kimg_min_pa, kimg_size);
    226223}
    227224
  • trunk/hal/x86_64/hal_init.c

    r46 r47  
    8888        x86_printf("[+] cpu_attach called\n");
    8989
    90         x86_printf("[+] bootloader: %s\n", mb_loader_name);
     90        x86_printf("[+] bootloader: '%s'\n", mb_loader_name);
    9191
    9292        dump_memmap();
     
    109109
    110110        x86_printf("-> mytest = %z\n", mytest);
    111         size_t *myptr = XPTR_KIMG(0, &mytest) + CLUSTER_KIMG_MIN_VA(0);
     111        size_t *myptr = CLUSTER_MIN_VA(0) + XPTR(0, &mytest);
    112112        *myptr = 1;
    113113        x86_printf("-> mytest = %z\n", mytest);
  • trunk/hal/x86_64/x86_printf.c

    r39 r47  
    214214                                x86_printf("0x%s", buf);
    215215                        } else if (c == 's') {
    216                                 x86_printf((char *) va_arg(ap, int));
     216                                x86_printf((char *) va_arg(ap, uint64_t));
    217217                        }
    218218                } else
Note: See TracChangeset for help on using the changeset viewer.