Changeset 7aaed09 in mainline for kernel/genarch/src


Ignore:
Timestamp:
2011-12-18T14:02:30Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c868e2d
Parents:
3b71e84d (diff), 1761268 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
kernel/genarch/src
Files:
1 added
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/drivers/i8042/i8042.c

    r3b71e84d r7aaed09  
    4444#include <mm/slab.h>
    4545#include <ddi/device.h>
     46#include <time/delay.h>
    4647
    4748#define i8042_SET_COMMAND  0x60
     
    5152#define i8042_BUFFER_FULL_MASK  0x01
    5253#define i8042_WAIT_MASK         0x02
     54
     55#define i8042_TIMEOUT  65536
    5356
    5457static irq_ownership_t i8042_claim(irq_t *irq)
     
    7780static void i8042_clear_buffer(i8042_t *dev)
    7881{
    79         while (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK)
     82        for (uint32_t i = 0; i < i8042_TIMEOUT; i++) {
     83                if ((pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK) == 0)
     84                        break;
     85               
    8086                (void) pio_read_8(&dev->data);
     87                delay(50);  /* 50 us think time */
     88        }
     89}
     90
     91static void i8042_send_command(i8042_t *dev, uint8_t cmd)
     92{
     93        for (uint32_t i = 0; i < i8042_TIMEOUT; i++) {
     94                if ((pio_read_8(&dev->status) & i8042_WAIT_MASK) == 0)
     95                        break;
     96               
     97                delay(50);  /* 50 us think time */
     98        }
     99       
     100        pio_write_8(&dev->status, cmd);
     101        delay(10000);  /* 10 ms think time */
    81102}
    82103
     
    84105i8042_instance_t *i8042_init(i8042_t *dev, inr_t inr)
    85106{
    86         i8042_instance_t *instance
    87             = malloc(sizeof(i8042_instance_t), FRAME_ATOMIC);
     107        i8042_instance_t *instance =
     108            malloc(sizeof(i8042_instance_t), FRAME_ATOMIC);
    88109        if (instance) {
    89110                instance->i8042 = dev;
     
    96117                instance->irq.handler = i8042_irq_handler;
    97118                instance->irq.instance = instance;
    98                
    99119        }
    100120       
     
    107127        ASSERT(kbrdin);
    108128       
     129        i8042_clear_buffer(instance->i8042);
     130       
    109131        instance->kbrdin = kbrdin;
    110132        irq_register(&instance->irq);
    111         i8042_clear_buffer(instance->i8042);
    112133}
    113134
     
    116137{
    117138        interrupts_disable();
    118        
    119139        i8042_clear_buffer(dev);
    120        
    121         /* Reset CPU */
    122         pio_write_8(&dev->status, i8042_CPU_RESET);
     140        i8042_send_command(dev, i8042_CPU_RESET);
    123141}
    124142
  • kernel/genarch/src/fb/bfb.c

    r3b71e84d r7aaed09  
    2727 */
    2828
    29 /** @addtogroup ia32
     29/** @addtogroup genarch
    3030 * @{
    3131 */
    3232/**
    3333 * @file
    34  * @brief VESA frame buffer driver.
     34 * @brief Boot framebuffer driver.
    3535 */
    3636
    37 #ifdef CONFIG_FB
     37#include <typedefs.h>
     38#include <genarch/fb/fb.h>
     39#include <genarch/fb/bfb.h>
     40#include <console/console.h>
    3841
    39 #include <genarch/fb/fb.h>
    40 #include <arch/drivers/vesa.h>
    41 #include <console/chardev.h>
    42 #include <console/console.h>
    43 #include <putchar.h>
    44 #include <mm/page.h>
    45 #include <mm/frame.h>
    46 #include <mm/as.h>
    47 #include <arch/mm/page.h>
    48 #include <synch/spinlock.h>
    49 #include <arch/asm.h>
    50 #include <typedefs.h>
    51 #include <memstr.h>
    52 #include <bitops.h>
     42uintptr_t bfb_addr = 0;
     43uint32_t bfb_width = 0;
     44uint32_t bfb_height = 0;
     45uint16_t bfb_bpp = 0;
     46uint32_t bfb_scanline = 0;
    5347
    54 uint32_t vesa_ph_addr;
    55 uint16_t vesa_width;
    56 uint16_t vesa_height;
    57 uint16_t vesa_bpp;
    58 uint16_t vesa_scanline;
     48uint8_t bfb_red_pos = 0;
     49uint8_t bfb_red_size = 0;
    5950
    60 uint8_t vesa_red_mask;
    61 uint8_t vesa_red_pos;
     51uint8_t bfb_green_pos = 0;
     52uint8_t bfb_green_size = 0;
    6253
    63 uint8_t vesa_green_mask;
    64 uint8_t vesa_green_pos;
     54uint8_t bfb_blue_pos = 0;
     55uint8_t bfb_blue_size = 0;
    6556
    66 uint8_t vesa_blue_mask;
    67 uint8_t vesa_blue_pos;
    68 
    69 bool vesa_init(void)
     57bool bfb_init(void)
    7058{
    71         if ((vesa_width == 0xffffU) || (vesa_height == 0xffffU))
     59        if ((bfb_addr == 0) || (bfb_width == 0) || (bfb_height == 0) ||
     60            (bfb_bpp == 0) || (bfb_scanline == 0))
    7261                return false;
    7362       
    74         visual_t visual;
     63        fb_properties_t bfb_props = {
     64                .addr = bfb_addr,
     65                .offset = 0,
     66                .x = bfb_width,
     67                .y = bfb_height,
     68                .scan = bfb_scanline
     69        };
    7570       
    76         switch (vesa_bpp) {
     71        switch (bfb_bpp) {
    7772        case 8:
    78                 visual = VISUAL_INDIRECT_8;
     73                bfb_props.visual = VISUAL_INDIRECT_8;
    7974                break;
    8075        case 16:
    81                 if ((vesa_red_mask == 5) && (vesa_red_pos == 10)
    82                     && (vesa_green_mask == 5) && (vesa_green_pos == 5)
    83                     && (vesa_blue_mask == 5) && (vesa_blue_pos == 0))
    84                         visual = VISUAL_RGB_5_5_5_LE;
     76                if ((bfb_red_pos == 10) && (bfb_red_size == 5) &&
     77                    (bfb_green_pos == 5) && (bfb_green_size == 5) &&
     78                    (bfb_blue_pos == 0) && (bfb_blue_size == 5))
     79                        bfb_props.visual = VISUAL_RGB_5_5_5_LE;
    8580                else
    86                         visual = VISUAL_RGB_5_6_5_LE;
     81                        bfb_props.visual = VISUAL_RGB_5_6_5_LE;
    8782                break;
    8883        case 24:
    89                 visual = VISUAL_BGR_8_8_8;
     84                bfb_props.visual = VISUAL_BGR_8_8_8;
    9085                break;
    9186        case 32:
    92                 visual = VISUAL_BGR_8_8_8_0;
     87                bfb_props.visual = VISUAL_BGR_8_8_8_0;
    9388                break;
    9489        default:
     
    9792        }
    9893       
    99         fb_properties_t vesa_props = {
    100                 .addr = vesa_ph_addr,
    101                 .offset = 0,
    102                 .x = vesa_width,
    103                 .y = vesa_height,
    104                 .scan = vesa_scanline,
    105                 .visual = visual,
    106         };
    107        
    108         outdev_t *fbdev = fb_init(&vesa_props);
     94        outdev_t *fbdev = fb_init(&bfb_props);
    10995        if (!fbdev)
    11096                return false;
     
    114100}
    115101
    116 #endif
    117 
    118102/** @}
    119103 */
  • kernel/genarch/src/multiboot/multiboot.c

    r3b71e84d r7aaed09  
    3333 */
    3434
     35#include <typedefs.h>
    3536#include <genarch/multiboot/multiboot.h>
    36 #include <typedefs.h>
    3737#include <config.h>
    3838#include <str.h>
    39 #include <macros.h>
    4039
    4140/** Extract command name from the multiboot module command line.
    4241 *
    43  * @param buf      Destination buffer (will always NULL-terminate).
    44  * @param s     Size of destination buffer (in bytes).
     42 * @param buf      Destination buffer (will be always NULL-terminated).
     43 * @param size     Size of destination buffer (in bytes).
    4544 * @param cmd_line Input string (the command line).
    4645 *
    4746 */
    48 static void extract_command(char *buf, size_t sz, const char *cmd_line)
     47void multiboot_extract_command(char *buf, size_t size, const char *cmd_line)
    4948{
    5049        /* Find the first space. */
     
    6968       
    7069        /* Copy the command. */
    71         str_ncpy(buf, sz, start, (size_t) (end - start));
     70        str_ncpy(buf, size, start, (size_t) (end - start));
     71}
     72
     73static void multiboot_modules(uint32_t count, multiboot_module_t *mods)
     74{
     75        for (uint32_t i = 0; i < count; i++) {
     76                if (init.cnt >= CONFIG_INIT_TASKS)
     77                        break;
     78               
     79                init.tasks[init.cnt].addr = PA2KA(mods[i].start);
     80                init.tasks[init.cnt].size = mods[i].end - mods[i].start;
     81               
     82                /* Copy command line, if available. */
     83                if (mods[i].string) {
     84                        multiboot_extract_command(init.tasks[init.cnt].name,
     85                            CONFIG_TASK_NAME_BUFLEN, MULTIBOOT_PTR(mods[i].string));
     86                } else
     87                        init.tasks[init.cnt].name[0] = 0;
     88               
     89                init.cnt++;
     90        }
     91}
     92
     93static void multiboot_memmap(uint32_t length, multiboot_memmap_t *memmap)
     94{
     95        uint32_t pos = 0;
     96       
     97        while ((pos < length) && (e820counter < MEMMAP_E820_MAX_RECORDS)) {
     98                e820table[e820counter] = memmap->mm_info;
     99               
     100                /* Compute address of next structure. */
     101                uint32_t size = sizeof(memmap->size) + memmap->size;
     102                memmap = (multiboot_memmap_t *) ((uintptr_t) memmap + size);
     103                pos += size;
     104               
     105                e820counter++;
     106        }
    72107}
    73108
     
    78113 *
    79114 * @param signature Should contain the multiboot signature.
    80  * @param mi        Pointer to the multiboot information structure.
     115 * @param info      Multiboot information structure.
     116 *
    81117 */
    82 void multiboot_info_parse(uint32_t signature, const multiboot_info_t *mi)
     118void multiboot_info_parse(uint32_t signature, const multiboot_info_t *info)
    83119{
    84         uint32_t flags;
     120        if (signature != MULTIBOOT_LOADER_MAGIC)
     121                return;
    85122       
    86         if (signature == MULTIBOOT_LOADER_MAGIC)
    87                 flags = mi->flags;
    88         else {
    89                 /* No multiboot info available. */
    90                 flags = 0;
    91         }
    92        
    93         /* Copy module information. */
    94         uint32_t i;
    95         if ((flags & MBINFO_FLAGS_MODS) != 0) {
    96                 init.cnt = min(mi->mods_count, CONFIG_INIT_TASKS);
    97                 multiboot_mod_t *mods
    98                     = (multiboot_mod_t *) MULTIBOOT_PTR(mi->mods_addr);
    99                
    100                 for (i = 0; i < init.cnt; i++) {
    101                         init.tasks[i].addr = PA2KA(mods[i].start);
    102                         init.tasks[i].size = mods[i].end - mods[i].start;
    103                        
    104                         /* Copy command line, if available. */
    105                         if (mods[i].string) {
    106                                 extract_command(init.tasks[i].name,
    107                                     CONFIG_TASK_NAME_BUFLEN,
    108                                     MULTIBOOT_PTR(mods[i].string));
    109                         } else
    110                                 init.tasks[i].name[0] = 0;
    111                 }
    112         } else
    113                 init.cnt = 0;
     123        /* Copy modules information. */
     124        if ((info->flags & MULTIBOOT_INFO_FLAGS_MODS) != 0)
     125                multiboot_modules(info->mods_count,
     126                    (multiboot_module_t *) MULTIBOOT_PTR(info->mods_addr));
    114127       
    115128        /* Copy memory map. */
    116        
    117         if ((flags & MBINFO_FLAGS_MMAP) != 0) {
    118                 int32_t mmap_length = mi->mmap_length;
    119                 multiboot_mmap_t *mme = MULTIBOOT_PTR(mi->mmap_addr);
    120                 e820counter = 0;
    121                
    122                 i = 0;
    123                 while ((mmap_length > 0) && (i < MEMMAP_E820_MAX_RECORDS)) {
    124                         e820table[i++] = mme->mm_info;
    125                        
    126                         /* Compute address of next structure. */
    127                         uint32_t size = sizeof(mme->size) + mme->size;
    128                         mme = ((void *) mme) + size;
    129                         mmap_length -= size;
    130                 }
    131                
    132                 e820counter = i;
    133         } else
    134                 e820counter = 0;
     129        if ((info->flags & MULTIBOOT_INFO_FLAGS_MMAP) != 0)
     130                multiboot_memmap(info->mmap_length,
     131                    (multiboot_memmap_t *) MULTIBOOT_PTR(info->mmap_addr));
    135132}
    136133
Note: See TracChangeset for help on using the changeset viewer.