Changeset 9979acb in mainline


Ignore:
Timestamp:
2009-02-20T17:19:03Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c9b550b
Parents:
5c06c1c
Message:

make hw_area API more generic
this allows mapping of EGA VRAM on ia32/amd64

Location:
kernel
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/include/mm/tlb.h

    r5c06c1c r9979acb  
    3636#define KERN_amd64_TLB_H_
    3737
    38 #define tlb_arch_init()
    39 #define tlb_print()
    40 
    4138#endif
    4239
  • kernel/arch/amd64/src/mm/page.c

    r5c06c1c r9979acb  
    3535#include <arch/mm/page.h>
    3636#include <genarch/mm/page_pt.h>
     37#include <genarch/drivers/ega/ega.h>
     38#include <genarch/drivers/legacy/ia32/io.h>
    3739#include <arch/mm/frame.h>
    3840#include <mm/page.h>
     
    4749#include <panic.h>
    4850#include <align.h>
     51#include <ddi/ddi.h>
     52
     53/** Physical memory area for devices. */
     54static parea_t dev_area;
     55static parea_t ega_area;
    4956
    5057/* Definitions for identity page mapper */
     
    215222}
    216223
    217 void hw_area(uintptr_t *physaddr, pfn_t *frames)
    218 {
    219         *physaddr = end_frame;
    220         *frames = ADDR2PFN(0xfffffffffffff - end_frame);
     224void hw_area(void)
     225{
     226        dev_area.pbase = end_frame;
     227        dev_area.frames = SIZE2FRAMES(0xfffffffffffff - end_frame);
     228        ddi_parea_register(&dev_area);
     229       
     230        ega_area.pbase = EGA_VIDEORAM;
     231        ega_area.frames = SIZE2FRAMES(EGA_VRAM_SIZE);
     232        ddi_parea_register(&ega_area);
    221233}
    222234
  • kernel/arch/arm32/include/mm/tlb.h

    r5c06c1c r9979acb  
    3737#define KERN_arm32_TLB_H_
    3838
    39 #define tlb_arch_init()
    40 #define tlb_print()
    41 
    4239#endif
    4340
  • kernel/arch/arm32/src/mm/page.c

    r5c06c1c r9979acb  
    4444#include <interrupt.h>
    4545#include <arch/mm/frame.h>
     46#include <ddi/ddi.h>
     47
     48/** Physical memory area for devices. */
     49static parea_t dev_area;
    4650
    4751/** Initializes page tables.
     
    107111}
    108112
    109 void hw_area(uintptr_t *physaddr, pfn_t *frames)
     113void hw_area(void)
    110114{
    111         *physaddr = end_frame;
    112         *frames = ADDR2PFN(0xffffffff - end_frame);
     115        dev_area.pbase = end_frame;
     116        dev_area.frames = SIZE2FRAMES(0xffffffff - end_frame);
     117        ddi_parea_register(&dev_area);
    113118}
    114119
  • kernel/arch/arm32/src/mm/tlb.c

    r5c06c1c r9979acb  
    9090}
    9191
     92void tlb_arch_init(void)
     93{
     94}
     95
     96void tlb_print(void)
     97{
     98}
     99
    92100/** @}
    93101 */
  • kernel/arch/ia32/include/mm/tlb.h

    r5c06c1c r9979acb  
    2727 */
    2828
    29 /** @addtogroup ia32mm 
     29/** @addtogroup ia32mm
    3030 * @{
    3131 */
     
    3636#define KERN_ia32_TLB_H_
    3737
    38 #define tlb_arch_init()
    39 #define tlb_print()
    40 
    4138#endif
    4239
  • kernel/arch/ia32/src/mm/page.c

    r5c06c1c r9979acb  
    3535#include <arch/mm/page.h>
    3636#include <genarch/mm/page_pt.h>
     37#include <genarch/drivers/ega/ega.h>
     38#include <genarch/drivers/legacy/ia32/io.h>
    3739#include <arch/mm/frame.h>
    3840#include <mm/frame.h>
     
    4951#include <print.h>
    5052#include <interrupt.h>
     53#include <ddi/ddi.h>
     54
     55/** Physical memory area for devices. */
     56static parea_t dev_area;
     57static parea_t ega_area;
    5158
    5259void page_arch_init(void)
     
    94101}
    95102
    96 void hw_area(uintptr_t *physaddr, pfn_t *frames)
     103void hw_area(void)
    97104{
    98         *physaddr = end_frame;
    99         *frames = ADDR2PFN(0xffffffff - end_frame);
     105        dev_area.pbase = end_frame;
     106        dev_area.frames = SIZE2FRAMES(0xffffffff - end_frame);
     107        ddi_parea_register(&dev_area);
     108       
     109        ega_area.pbase = EGA_VIDEORAM;
     110        ega_area.frames = SIZE2FRAMES(EGA_VRAM_SIZE);
     111        ddi_parea_register(&ega_area);
    100112}
    101113
  • kernel/arch/ia32/src/mm/tlb.c

    r5c06c1c r9979acb  
    6868}
    6969
     70void tlb_arch_init(void)
     71{
     72}
     73
     74void tlb_print(void)
     75{
     76}
     77
    7078/** @}
    7179 */
  • kernel/arch/ia64/include/mm/tlb.h

    r5c06c1c r9979acb  
    3535#ifndef KERN_ia64_TLB_H_
    3636#define KERN_ia64_TLB_H_
    37 
    38 #define tlb_arch_init()
    39 #define tlb_print()
    4037
    4138#include <arch/mm/page.h>
  • kernel/arch/ia64/src/mm/page.c

    r5c06c1c r9979acb  
    2828 */
    2929
    30 /** @addtogroup ia64mm 
     30/** @addtogroup ia64mm
    3131 * @{
    3232 */
     
    4949#include <memstr.h>
    5050#include <align.h>
     51#include <ddi/ddi.h>
     52
     53/** Physical memory area for devices. */
     54static parea_t dev_area;
    5155
    5256static void set_environment(void);
     
    275279}
    276280
    277 void hw_area(uintptr_t *physaddr, pfn_t *frames)
    278 {
    279         *physaddr = end_frame;
    280         *frames = ADDR2PFN(0x7fffffffffffffffUL - end_frame);
     281void hw_area(void)
     282{
     283        dev_area.pbase = end_frame;
     284        dev_area.frames = SIZE2FRAMES(0x7fffffffffffffffUL - end_frame);
     285        ddi_parea_register(&dev_area);
    281286}
    282287
  • kernel/arch/ia64/src/mm/tlb.c

    r5c06c1c r9979acb  
    750750}
    751751
     752void tlb_arch_init(void)
     753{
     754}
     755
     756void tlb_print(void)
     757{
     758}
     759
    752760/** @}
    753761 */
  • kernel/arch/mips32/src/mm/page.c

    r5c06c1c r9979acb  
    3737#include <mm/page.h>
    3838#include <mm/frame.h>
     39#include <ddi/ddi.h>
     40
     41/** Physical memory area for devices. */
     42static parea_t dev_area;
    3943
    4044void page_arch_init(void)
     
    5256}
    5357
    54 void hw_area(uintptr_t *physaddr, pfn_t *frames)
     58void hw_area(void)
    5559{
    56         *physaddr = end_frame;
    57         *frames = ADDR2PFN(0xffffffff - end_frame);
     60        dev_area.pbase = end_frame;
     61        dev_area.frames = SIZE2FRAMES(0xffffffff - end_frame);
     62        ddi_parea_register(&dev_area);
    5863}
    5964
  • kernel/arch/ppc32/src/mm/page.c

    r5c06c1c r9979acb  
    3838#include <align.h>
    3939#include <config.h>
     40#include <ddi/ddi.h>
     41
     42/** Physical memory area for devices. */
     43static parea_t dev_area;
    4044
    4145void page_arch_init(void)
     
    6468}
    6569
    66 void hw_area(uintptr_t *physaddr, pfn_t *frames)
     70void hw_area(void)
    6771{
    68         *physaddr = end_frame;
    69         *frames = ADDR2PFN(0xffffffff - end_frame);
     72        dev_area.pbase = end_frame;
     73        dev_area.frames = SIZE2FRAMES(0xffffffff - end_frame);
     74        ddi_parea_register(&dev_area);
    7075}
    7176
  • kernel/arch/sparc64/src/mm/page.c

    r5c06c1c r9979acb  
    2727 */
    2828
    29 /** @addtogroup sparc64mm       
     29/** @addtogroup sparc64mm
    3030 * @{
    3131 */
     
    4242#include <align.h>
    4343#include <config.h>
     44#include <ddi/ddi.h>
     45
     46/** Physical memory area for devices. */
     47static parea_t dev_area;
    4448
    4549#ifdef CONFIG_SMP
     
    165169}
    166170
    167 void hw_area(uintptr_t *physaddr, pfn_t *frames)
     171void hw_area(void)
    168172{
    169         *physaddr = end_frame;
    170         *frames = ADDR2PFN(0x7ffffffffff - end_frame);
     173        dev_area.pbase = end_frame;
     174        dev_area.frames = SIZE2FRAMES(0x7ffffffffff - end_frame);
     175        ddi_parea_register(&dev_area);
    171176}
    172177
  • kernel/genarch/include/drivers/ega/ega.h

    r5c06c1c r9979acb  
    2727 */
    2828
    29 /** @addtogroup genarch_drivers 
     29/** @addtogroup genarch_drivers
    3030 * @{
    3131 */
     
    3838#include <arch/types.h>
    3939
    40 #define ROW             80
    41 #define ROWS            25
    42 #define SCREEN          (ROW * ROWS)
     40#define EGA_COLS       80
     41#define EGA_ROWS       25
     42#define EGA_SCREEN     (EGA_COLS * EGA_ROWS)
     43#define EGA_VRAM_SIZE  (2 * EGA_SCREEN)
    4344
    4445/* EGA device registers. */
    45 #define EGA_INDEX_REG   0
    46 #define EGA_DATA_REG    1
     46#define EGA_INDEX_REG  0
     47#define EGA_DATA_REG   1
    4748
    4849extern void ega_redraw(void);
  • kernel/genarch/include/drivers/legacy/ia32/io.h

    r5c06c1c r9979acb  
    3131 */
    3232/** @file
    33  * @brief       This file contains definitions used by architectures with the
    34  *              ia32 legacy I/O space (i.e. ia32, amd64 and ia64).
     33 * @brief This file contains definitions used by architectures with the
     34 *        ia32 legacy I/O space (i.e. ia32, amd64 and ia64).
    3535 */
    3636
     
    4040#include <arch/types.h>
    4141
    42 #define I8042_BASE      ((ioport8_t *)0x60)
     42#define I8042_BASE    ((ioport8_t *) 0x60)
     43#define EGA_BASE      ((ioport8_t *) 0x3d4)
     44#define NS16550_BASE  ((ioport8_t *) 0x3f8)
    4345
    44 #define EGA_VIDEORAM    0xb8000
    45 #define EGA_BASE        ((ioport8_t *)0x3d4)
    46 
    47 #define NS16550_BASE    ((ioport8_t *)0x3f8)
     46#define EGA_VIDEORAM  0xb8000
    4847
    4948#endif
  • kernel/genarch/src/drivers/ega/ega.c

    r5c06c1c r9979acb  
    2727 */
    2828
    29 /** @addtogroup genarch_drivers 
     29/** @addtogroup genarch_drivers
    3030 * @{
    3131 */
     
    6868static void ega_check_cursor(void)
    6969{
    70         if (ega_cursor < SCREEN)
     70        if (ega_cursor < EGA_SCREEN)
    7171                return;
    7272
    73         memmove((void *) videoram, (void *) (videoram + ROW * 2),
    74             (SCREEN - ROW) * 2);
    75         memmove((void *) backbuf, (void *) (backbuf + ROW * 2),
    76             (SCREEN - ROW) * 2);
    77         memsetw(videoram + (SCREEN - ROW) * 2, ROW, 0x0720);
    78         memsetw(backbuf + (SCREEN - ROW) * 2, ROW, 0x0720);
    79         ega_cursor = ega_cursor - ROW;
     73        memmove((void *) videoram, (void *) (videoram + EGA_COLS * 2),
     74            (EGA_SCREEN - EGA_COLS) * 2);
     75        memmove((void *) backbuf, (void *) (backbuf + EGA_COLS * 2),
     76            (EGA_SCREEN - EGA_COLS) * 2);
     77        memsetw(videoram + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, 0x0720);
     78        memsetw(backbuf + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, 0x0720);
     79        ega_cursor = ega_cursor - EGA_COLS;
    8080}
    8181
     
    8585        pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) ((ega_cursor >> 8) & 0xff));
    8686        pio_write_8(ega_base + EGA_INDEX_REG, 0xf);
    87         pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff));   
     87        pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff));
    8888}
    8989
     
    105105        switch (ch) {
    106106        case '\n':
    107                 ega_cursor = (ega_cursor + ROW) - ega_cursor % ROW;
     107                ega_cursor = (ega_cursor + EGA_COLS) - ega_cursor % EGA_COLS;
    108108                break;
    109109        case '\t':
     
    111111                break;
    112112        case '\b':
    113                 if (ega_cursor % ROW)
     113                if (ega_cursor % EGA_COLS)
    114114                        ega_cursor--;
    115115                break;
     
    134134void ega_init(ioport8_t *base, uintptr_t videoram_phys)
    135135{
    136         /* Initialize the software structure. */       
     136        /* Initialize the software structure. */
    137137        ega_base = base;
    138138       
    139         backbuf = (uint8_t *) malloc(SCREEN * 2, 0);
     139        backbuf = (uint8_t *) malloc(EGA_VRAM_SIZE, 0);
    140140        if (!backbuf)
    141141                panic("Unable to allocate backbuffer.");
    142142       
    143         videoram = (uint8_t *) hw_map(videoram_phys, SCREEN * 2);
     143        videoram = (uint8_t *) hw_map(videoram_phys, EGA_VRAM_SIZE);
    144144       
    145145        /* Clear the screen and set the cursor position. */
    146         memsetw(videoram, SCREEN, 0x0720);
    147         memsetw(backbuf, SCREEN, 0x0720);
     146        memsetw(videoram, EGA_SCREEN, 0x0720);
     147        memsetw(backbuf, EGA_SCREEN, 0x0720);
    148148        ega_move_cursor();
    149149       
     
    153153        sysinfo_set_item_val("fb", NULL, true);
    154154        sysinfo_set_item_val("fb.kind", NULL, 2);
    155         sysinfo_set_item_val("fb.width", NULL, ROW);
    156         sysinfo_set_item_val("fb.height", NULL, ROWS);
     155        sysinfo_set_item_val("fb.width", NULL, EGA_COLS);
     156        sysinfo_set_item_val("fb.height", NULL, EGA_ROWS);
    157157        sysinfo_set_item_val("fb.blinking", NULL, true);
    158158        sysinfo_set_item_val("fb.address.physical", NULL, videoram_phys);
     
    161161void ega_redraw(void)
    162162{
    163         memcpy(videoram, backbuf, SCREEN * 2);
     163        memcpy(videoram, backbuf, EGA_VRAM_SIZE);
    164164        ega_move_cursor();
    165165}
  • kernel/generic/include/mm/page.h

    r5c06c1c r9979acb  
    6262
    6363extern uintptr_t hw_map(uintptr_t physaddr, size_t size);
    64 extern void hw_area(uintptr_t *physaddr, pfn_t *frames);
     64extern void hw_area(void);
    6565
    6666#endif
  • kernel/generic/src/ddi/ddi.c

    r5c06c1c r9979acb  
    5959static LIST_INITIALIZE(parea_head);
    6060
    61 /** Physical memory area for devices. */
    62 static parea_t dev_area;
    63 
    6461/** Initialize DDI. */
    6562void ddi_init(void)
    6663{
    67         hw_area(&dev_area.pbase, &dev_area.frames);
    68         ddi_parea_register(&dev_area);
     64        hw_area();
    6965}
    7066
Note: See TracChangeset for help on using the changeset viewer.