Changeset e037cf37 in mainline


Ignore:
Timestamp:
2020-12-29T22:17:21Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
11e394f, d70dc1c4
Parents:
1483981
Message:

Show kernel console again when its physical area is unmapped

It's good to be able to see the stack trace if e.g. display server
crashes.

Location:
kernel
Files:
6 edited

Legend:

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

    r1483981 re037cf37  
    568568}
    569569
    570 static void ega_redraw(outdev_t *dev)
    571 {
    572         ega_instance_t *instance = (ega_instance_t *) dev->data;
    573 
    574         irq_spinlock_lock(&instance->lock, true);
    575 
     570static void ega_redraw_internal(ega_instance_t *instance)
     571{
    576572        memcpy(instance->addr, instance->backbuf, EGA_VRAM_SIZE);
    577573        ega_move_cursor(instance);
    578574        ega_show_cursor(instance);
    579 
     575}
     576
     577static void ega_redraw(outdev_t *dev)
     578{
     579        ega_instance_t *instance = (ega_instance_t *) dev->data;
     580
     581        irq_spinlock_lock(&instance->lock, true);
     582        ega_redraw_internal(instance);
    580583        irq_spinlock_unlock(&instance->lock, true);
     584}
     585
     586/** EGA was mapped or unmapped.
     587 *
     588 * @param arg EGA instance
     589 */
     590static void ega_mapped_changed(void *arg)
     591{
     592        ega_instance_t *instance = (ega_instance_t *) arg;
     593
     594        if (!instance->parea.mapped) {
     595                irq_spinlock_lock(&instance->lock, true);
     596                ega_redraw_internal(instance);
     597                irq_spinlock_unlock(&instance->lock, true);
     598        }
    581599}
    582600
     
    621639        instance->parea.unpriv = false;
    622640        instance->parea.mapped = false;
     641        instance->parea.mapped_changed = ega_mapped_changed;
     642        instance->parea.arg = (void *) instance;
    623643        ddi_parea_register(&instance->parea);
    624644
  • kernel/genarch/src/fb/fb.c

    r1483981 re037cf37  
    516516}
    517517
     518/** Framebuffer was mapped or unmapped.
     519 *
     520 * @param arg Framebuffer instance
     521 */
     522static void fb_mapped_changed(void *arg)
     523{
     524        fb_instance_t *instance = (fb_instance_t *) arg;
     525
     526        if (!instance->parea.mapped) {
     527                spinlock_lock(&instance->lock);
     528                fb_redraw_internal(instance);
     529                spinlock_unlock(&instance->lock);
     530        }
     531}
     532
    518533/** Initialize framebuffer as a output character device
    519534 *
     
    661676        instance->parea.unpriv = false;
    662677        instance->parea.mapped = false;
     678        instance->parea.mapped_changed = fb_mapped_changed;
     679        instance->parea.arg = (void *) instance;
    663680        ddi_parea_register(&instance->parea);
    664681
  • kernel/generic/include/ddi/ddi.h

    r1483981 re037cf37  
    4242
    4343/** Structure representing contiguous physical memory area. */
    44 typedef struct {
     44typedef struct parea {
    4545        /** Link to @c pareas ordered dictionary */
    4646        odlink_t lpareas;
     
    5454        /** Indicate whether the area is actually mapped. */
    5555        bool mapped;
     56        /** Called when @c mapped field has changed */
     57        void (*mapped_changed)(void *);
     58        /** Callback argument */
     59        void *arg;
    5660} parea_t;
    5761
     
    5963extern void ddi_parea_init(parea_t *);
    6064extern void ddi_parea_register(parea_t *);
     65extern void ddi_parea_unmap_notify(parea_t *);
    6166
    6267extern void *pio_map(void *, size_t);
  • kernel/generic/include/mm/as.h

    r1483981 re037cf37  
    236236                size_t frames;
    237237                bool anonymous;
     238                struct parea *parea;
    238239        };
    239240
  • kernel/generic/src/ddi/ddi.c

    r1483981 re037cf37  
    107107}
    108108
     109/** Norify physical area has been unmapped.
     110 *
     111 * @param parea Physical area
     112 */
     113void ddi_parea_unmap_notify(parea_t *parea)
     114{
     115        parea->mapped = false;
     116        if (parea->mapped_changed != NULL)
     117                parea->mapped_changed(parea->arg);
     118}
     119
    109120/** Map piece of physical memory into virtual address space of current task.
    110121 *
     
    204215
    205216map:
     217        backend_data.parea = parea;
     218
    206219        if (!as_area_create(TASK->as, flags, FRAMES2SIZE(pages),
    207220            AS_AREA_ATTR_NONE, &phys_backend, &backend_data, virt, bound)) {
  • kernel/generic/src/mm/backend_phys.c

    r1483981 re037cf37  
    3838
    3939#include <assert.h>
     40#include <ddi/ddi.h>
    4041#include <typedefs.h>
    4142#include <mm/as.h>
     
    101102{
    102103        /*
    103          * Nothing to do.
    104104         * The anonymous frames, if any, are released in
    105105         * phys_destroy_shared_data().
    106106         */
     107
     108        /* Notify parea has been unmapped */
     109        if (area->backend_data.parea != NULL)
     110                ddi_parea_unmap_notify(area->backend_data.parea);
    107111}
    108112
Note: See TracChangeset for help on using the changeset viewer.