Ignore:
Timestamp:
2011-06-24T15:58:01Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7250d2c
Parents:
ee2fa30a
Message:

automatic kernel console lockout

  • kernel automatically relinquishes the access to the kernel console when the uspace maps the respective physical memory area
  • kernel output before uspace initialization is currently broken on Ski (no physical memory area), but this is pending further unification
  • kernel console devices are now independent (there is no system-wide "silent" variable), thus on multiple devices the kernel console and uspace output might be usable at the same time
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/src/drivers/sgcn.c

    ree2fa30a rb366a6f4  
    102102#define SGCN_BUFFER_HEADER  (SGCN_BUFFER(sgcn_buffer_header_t, 0))
    103103
    104 static void sgcn_putchar(outdev_t *, const wchar_t, bool);
     104static void sgcn_putchar(outdev_t *, const wchar_t);
    105105
    106106static outdev_operations_t sgcndev_ops = {
     
    111111static sgcn_instance_t *instance = NULL;
    112112
    113 /**
    114  * Set some sysinfo values (SRAM address and SRAM size).
    115  */
    116 static void register_sram(uintptr_t sram_begin_physical)
    117 {
    118         sysinfo_set_item_val("sram.area.size", NULL, MAPPED_AREA_SIZE);
    119         sysinfo_set_item_val("sram.address.physical", NULL,
    120             sram_begin_physical);
    121 }
    122 
    123 /**
    124  * Initializes the starting address of SRAM.
     113/** Initialize the starting address of SRAM.
    125114 *
    126115 * The SRAM starts 0x900000 + C bytes behind the SBBC start in the
     
    129118 * be set to the virtual address which maps to the SRAM physical
    130119 * address.
     120 *
    131121 */
    132122static void init_sram_begin(void)
     
    149139        instance->sram_begin = hw_map(sram_begin_physical, MAPPED_AREA_SIZE);
    150140       
    151         register_sram(sram_begin_physical);
    152 }
    153 
    154 /**
    155  * Function regularly called by the keyboard polling thread. Finds out whether
    156  * there are some unread characters in the input queue. If so, it picks them up
    157  * and sends them to the upper layers of HelenOS.
     141        link_initialize(&instance->parea.link);
     142        instance->parea.pbase = sram_begin_physical;
     143        instance->parea.frames = SIZE2FRAMES(MAPPED_AREA_SIZE);
     144        instance->parea.unpriv = false;
     145        instance->parea.mapped = false;
     146        ddi_parea_register(&instance->parea);
     147       
     148        sysinfo_set_item_val("sram.area.size", NULL, MAPPED_AREA_SIZE);
     149        sysinfo_set_item_val("sram.address.physical", NULL,
     150            sram_begin_physical);
     151}
     152
     153/** Get unread characters from the input queue.
     154 *
     155 * Check for unread characters in the input queue.
     156 *
    158157 */
    159158static void sgcn_poll(sgcn_instance_t *instance)
     
    163162        uint32_t size = end - begin;
    164163       
    165         if (silent)
     164        if ((instance->parea.mapped) && (!console_override))
    166165                return;
    167166       
    168167        spinlock_lock(&instance->input_lock);
    169168       
    170         /* we need pointers to volatile variables */
     169        /* We need pointers to volatile variables */
    171170        volatile char *buf_ptr = (volatile char *)
    172171            SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr);
     
    186185}
    187186
    188 /**
    189  * Polling thread function.
     187/** Polling thread function.
     188 *
    190189 */
    191190static void ksgcnpoll(void *instance) {
    192191        while (true) {
    193                 if (!silent)
    194                         sgcn_poll(instance);
    195                
     192                sgcn_poll(instance);
    196193                thread_usleep(POLL_INTERVAL);
    197194        }
    198195}
    199196
    200 /**
    201  * Initializes the starting address of the SGCN buffer.
     197/** Initialize the starting address of the SGCN buffer.
    202198 *
    203199 * The offset of the SGCN buffer within SRAM is obtained from the
    204200 * SRAM table of contents. The table of contents contains
    205201 * information about several buffers, among which there is an OBP
    206  * console buffer - this one will be used as the SGCN buffer.
     202 * console buffer -- this one will be used as the SGCN buffer.
    207203 *
    208204 * This function also writes the offset of the SGCN buffer within SRAM
    209205 * under the sram.buffer.offset sysinfo key.
     206 *
    210207 */
    211208static void sgcn_init(void)
     
    248245}
    249246
    250 /**
    251  * Writes a single character to the SGCN (circular) output buffer
    252  * and updates the output write pointer so that SGCN gets to know
     247/** Write a single character to the SGCN output buffer
     248 *
     249 * Write a single character to the SGCN (circular) output buffer
     250 * and update the output write pointer so that SGCN gets to know
    253251 * that the character has been written.
     252 *
    254253 */
    255254static void sgcn_do_putchar(const char c)
     
    286285}
    287286
    288 /**
    289  * SGCN output operation. Prints a single character to the SGCN. Newline
     287/** SGCN output operation
     288 *
     289 * Print a single character to the SGCN. Newline
    290290 * character is converted to CRLF.
    291  */
    292 static void sgcn_putchar(outdev_t *dev, const wchar_t ch, bool silent)
    293 {
    294         if (!silent) {
     291 *
     292 */
     293static void sgcn_putchar(outdev_t *dev, const wchar_t ch)
     294{
     295        if ((!instance->parea.mapped) || (console_override)) {
    295296                spinlock_lock(&instance->output_lock);
    296297               
     
    306307}
    307308
    308 /**
    309  * A public function which initializes input from the Serengeti console.
     309/** Initialize input from the Serengeti console.
     310 *
    310311 */
    311312sgcn_instance_t *sgcnin_init(void)
     
    326327}
    327328
    328 /**
    329  * A public function which initializes output to the Serengeti console.
     329/** Initialize output to the Serengeti console.
     330 *
    330331 */
    331332outdev_t *sgcnout_init(void)
Note: See TracChangeset for help on using the changeset viewer.