Changes in / [bb0d3d24:e056e820] in mainline


Ignore:
Files:
3 added
40 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • HelenOS.config

    rbb0d3d24 re056e820  
    3131
    3232% Platform
    33 @ "abs32le" abstract 32-bit little endian
    3433@ "amd64" AMD64/Intel EM64T (PC)
    3534@ "arm32" ARM 32-bit
     
    9291
    9392% Kernel architecture
    94 @ "abs32le"
    95 ! [PLATFORM=abs32le] KARCH (choice)
    96 
    97 % Kernel architecture
    9893@ "amd64"
    9994! [PLATFORM=amd64] KARCH (choice)
     
    135130
    136131% User space architecture
    137 @ "abs32le"
    138 ! [PLATFORM=abs32le] UARCH (choice)
    139 
    140 % User space architecture
    141132@ "amd64"
    142133! [PLATFORM=amd64] UARCH (choice)
     
    176167
    177168## Mapping between platform and boot architecture
    178 
    179 % Boot architecture
    180 @ "abs32le"
    181 ! [PLATFORM=abs32le] BARCH (choice)
    182169
    183170% Boot architecture
     
    256243! [PLATFORM=arm32|PLATFORM=mips32|PLATFORM=ppc32] COMPILER (choice)
    257244
    258 % Compiler
    259 @ "gcc_native" GNU C Compiler (native)
    260 @ "clang" Clang
    261 ! [PLATFORM=abs32le] COMPILER (choice)
    262 
    263245
    264246## Kernel configuration
     
    277259
    278260% Hierarchical page tables support
    279 ! [PLATFORM=abs32le|PLATFORM=ia32|PLATFORM=amd64|PLATFORM=arm32|PLATFORM=mips32|PLATFORM=ppc32] CONFIG_PAGE_PT (y)
     261! [PLATFORM=ia32|PLATFORM=amd64|PLATFORM=arm32|PLATFORM=mips32|PLATFORM=ppc32] CONFIG_PAGE_PT (y)
    280262
    281263% Page hash table support
     
    504486% Mount /data on startup
    505487! [CONFIG_START_BD=y] CONFIG_MOUNT_DATA (n/y)
    506 
    507 % Verbose task dumps
    508 ! CONFIG_VERBOSE_DUMPS (n/y)
  • Makefile

    rbb0d3d24 re056e820  
    5959
    6060distclean: clean
    61         rm -f $(CSCOPE).out Makefile.config config.h config.defs tools/*.pyc tools/checkers/*.pyc
     61        rm -f $(CSCOPE).out Makefile.config config.h config.defs tools/*.pyc
    6262
    6363clean:
  • boot/Makefile.common

    rbb0d3d24 re056e820  
    5656        $(USPACEDIR)/srv/fs/devfs/devfs \
    5757        $(USPACEDIR)/srv/fs/tmpfs/tmpfs \
    58         $(USPACEDIR)/srv/fs/fat/fat \
    59         $(USPACEDIR)/srv/taskmon/taskmon
     58        $(USPACEDIR)/srv/fs/fat/fat
    6059
    6160RD_APPS = \
     
    6665        $(USPACEDIR)/app/mkfat/mkfat \
    6766        $(USPACEDIR)/app/redir/redir \
    68         $(USPACEDIR)/app/taskdump/taskdump \
    6967        $(USPACEDIR)/app/tester/tester \
    7068        $(USPACEDIR)/app/tetris/tetris \
  • kernel/generic/include/interrupt.h

    rbb0d3d24 re056e820  
    4646typedef void (* iroutine)(int n, istate_t *istate);
    4747
    48 extern void fault_if_from_uspace(istate_t *istate, char *fmt, ...);
     48#define fault_if_from_uspace(istate, fmt, ...) \
     49{ \
     50        if (istate_from_uspace(istate)) { \
     51                task_t *task = TASK; \
     52                printf("Task %s (%" PRIu64 ") killed due to an exception at " \
     53                    "program counter %p.\n", task->name, task->taskid, istate_get_pc(istate)); \
     54                stack_trace_istate(istate); \
     55                printf("Kill message: " fmt "\n", ##__VA_ARGS__); \
     56                task_kill(task->taskid); \
     57                thread_exit(); \
     58        } \
     59}
     60
    4961extern iroutine exc_register(int n, const char *name, iroutine f);
    5062extern void exc_dispatch(int n, istate_t *t);
  • kernel/generic/include/ipc/event_types.h

    rbb0d3d24 re056e820  
    3737
    3838typedef enum event_type {
    39         /** New data available in kernel log */
    4039        EVENT_KLOG = 0,
    41         /** Returning from kernel console to userspace */
    4240        EVENT_KCONSOLE,
    43         /** A thread has faulted and will be terminated */
    44         EVENT_FAULT,
    4541        EVENT_END
    4642} event_type_t;
  • kernel/generic/include/mm/as.h

    rbb0d3d24 re056e820  
    3636#define KERN_AS_H_
    3737
    38 #ifdef KERNEL
    39 #include <arch/types.h>
    40 #else
    41 #include <sys/types.h>
    42 #endif
    43 
    4438/** Address space area flags. */
    4539#define AS_AREA_READ            1
     
    4741#define AS_AREA_EXEC            4
    4842#define AS_AREA_CACHEABLE       8
    49 
    50 /** Address space area info exported to userspace. */
    51 typedef struct {
    52         /** Starting address */
    53         uintptr_t start_addr;
    54 
    55         /** Area size */
    56         size_t size;
    57 
    58         /** Area flags */
    59         int flags;
    60 } as_area_info_t;
    6143
    6244#ifdef KERNEL
     
    286268
    287269/* Introspection functions. */
    288 extern void as_get_area_info(as_t *as, as_area_info_t **obuf, size_t *osize);
    289270extern void as_print(as_t *as);
    290271
  • kernel/generic/include/udebug/udebug.h

    rbb0d3d24 re056e820  
    9696 */
    9797UDEBUG_M_THREAD_READ,
    98 
    99 /** Read the list of the debugged task's address space areas.
    100  *
    101  * - ARG2 - destination address in the caller's address space
    102  * - ARG3 - size of receiving buffer in bytes
    103  *
    104  * The kernel fills the buffer with a series of as_area_info_t structures.
    105  * Upon answer, the kernel will set:
    106  *
    107  * - ARG2 - number of bytes that were actually copied
    108  * - ARG3 - number of bytes of the complete data
    109  *
    110  */
    111 UDEBUG_M_AREAS_READ,
    11298
    11399/** Read the debugged tasks's memory.
     
    153139
    154140#include <synch/mutex.h>
    155 #include <synch/condvar.h>
    156141#include <arch/interrupt.h>
    157142#include <atomic.h>
     
    196181        bool stoppable;         /**< thread is stoppable */
    197182        bool active;            /**< thread is in a debugging session */
    198         condvar_t active_cv;
    199183} udebug_thread_t;
    200184
  • kernel/generic/include/udebug/udebug_ops.h

    rbb0d3d24 re056e820  
    4545int udebug_stop(thread_t *t, call_t *call);
    4646
    47 int udebug_thread_read(void **buffer, size_t buf_size, size_t *stored,
    48     size_t *needed);
     47int udebug_thread_read(void **buffer, size_t buf_size, size_t *n);
    4948int udebug_args_read(thread_t *t, void **buffer);
    5049
  • kernel/generic/src/interrupt/interrupt.c

    rbb0d3d24 re056e820  
    4444#include <console/console.h>
    4545#include <console/cmd.h>
    46 #include <ipc/event.h>
    47 #include <synch/mutex.h>
    48 #include <time/delay.h>
    49 #include <macros.h>
    5046#include <panic.h>
    5147#include <print.h>
     
    111107        fault_if_from_uspace(istate, "Unhandled exception %d.", n);
    112108        panic("Unhandled exception %d.", n);
    113 }
    114 
    115 /** Terminate thread and task if exception came from userspace. */
    116 void fault_if_from_uspace(istate_t *istate, char *fmt, ...)
    117 {
    118         task_t *task = TASK;
    119         va_list args;
    120 
    121         if (!istate_from_uspace(istate))
    122                 return;
    123 
    124         printf("Task %s (%" PRIu64 ") killed due to an exception at "
    125             "program counter %p.\n", task->name, task->taskid,
    126             istate_get_pc(istate));
    127 
    128         stack_trace_istate(istate);
    129 
    130         printf("Kill message: ");
    131         va_start(args, fmt);
    132         vprintf(fmt, args);
    133         va_end(args);
    134         printf("\n");
    135 
    136         if (event_is_subscribed(EVENT_FAULT)) {
    137                 event_notify_3(EVENT_FAULT, LOWER32(TASK->taskid),
    138                     UPPER32(TASK->taskid), (unative_t) THREAD);
    139         }
    140 
    141 #ifdef CONFIG_UDEBUG
    142         /* Wait until a debugger attends to us. */
    143         mutex_lock(&THREAD->udebug.lock);
    144         while (!THREAD->udebug.active)
    145                 condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
    146         mutex_unlock(&THREAD->udebug.lock);
    147 
    148         udebug_stoppable_begin();
    149         udebug_stoppable_end();
    150 
    151         /* Make sure the debugging session is over before proceeding. */
    152         mutex_lock(&THREAD->udebug.lock);
    153         while (THREAD->udebug.active)
    154                 condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
    155         mutex_unlock(&THREAD->udebug.lock);
    156 #endif
    157 
    158         task_kill(task->taskid);
    159         thread_exit();
    160109}
    161110
  • kernel/generic/src/mm/as.c

    rbb0d3d24 re056e820  
    19201920}
    19211921
    1922 /** Get list of adress space areas.
    1923  *
    1924  * @param as            Address space.
    1925  * @param obuf          Place to save pointer to returned buffer.
    1926  * @param osize         Place to save size of returned buffer.
    1927  */
    1928 void as_get_area_info(as_t *as, as_area_info_t **obuf, size_t *osize)
    1929 {
    1930         ipl_t ipl;
    1931         size_t area_cnt, area_idx, i;
    1932         link_t *cur;
    1933 
    1934         as_area_info_t *info;
    1935         size_t isize;
    1936 
    1937         ipl = interrupts_disable();
    1938         mutex_lock(&as->lock);
    1939 
    1940         /* First pass, count number of areas. */
    1941 
    1942         area_cnt = 0;
    1943 
    1944         for (cur = as->as_area_btree.leaf_head.next;
    1945             cur != &as->as_area_btree.leaf_head; cur = cur->next) {
    1946                 btree_node_t *node;
    1947 
    1948                 node = list_get_instance(cur, btree_node_t, leaf_link);
    1949                 area_cnt += node->keys;
    1950         }
    1951 
    1952         isize = area_cnt * sizeof(as_area_info_t);
    1953         info = malloc(isize, 0);
    1954 
    1955         /* Second pass, record data. */
    1956 
    1957         area_idx = 0;
    1958 
    1959         for (cur = as->as_area_btree.leaf_head.next;
    1960             cur != &as->as_area_btree.leaf_head; cur = cur->next) {
    1961                 btree_node_t *node;
    1962 
    1963                 node = list_get_instance(cur, btree_node_t, leaf_link);
    1964 
    1965                 for (i = 0; i < node->keys; i++) {
    1966                         as_area_t *area = node->value[i];
    1967 
    1968                         ASSERT(area_idx < area_cnt);
    1969                         mutex_lock(&area->lock);
    1970 
    1971                         info[area_idx].start_addr = area->base;
    1972                         info[area_idx].size = FRAMES2SIZE(area->pages);
    1973                         info[area_idx].flags = area->flags;
    1974                         ++area_idx;
    1975 
    1976                         mutex_unlock(&area->lock);
    1977                 }
    1978         }
    1979 
    1980         mutex_unlock(&as->lock);
    1981         interrupts_restore(ipl);
    1982 
    1983         *obuf = info;
    1984         *osize = isize;
    1985 }
    1986 
    1987 
    19881922/** Print out information about address space.
    19891923 *
  • kernel/generic/src/udebug/udebug.c

    rbb0d3d24 re056e820  
    6969        mutex_initialize(&ut->lock, MUTEX_PASSIVE);
    7070        waitq_initialize(&ut->go_wq);
    71         condvar_initialize(&ut->active_cv);
    7271
    7372        ut->go_call = NULL;
     
    447446                                waitq_wakeup(&t->udebug.go_wq, WAKEUP_FIRST);
    448447                        }
    449                         mutex_unlock(&t->udebug.lock);
    450                         condvar_broadcast(&t->udebug.active_cv);
    451                 } else {
    452                         mutex_unlock(&t->udebug.lock);
    453448                }
     449                mutex_unlock(&t->udebug.lock);
    454450        }
    455451
  • kernel/generic/src/udebug/udebug_ipc.c

    rbb0d3d24 re056e820  
    4141#include <proc/task.h>
    4242#include <proc/thread.h>
    43 #include <mm/as.h>
    4443#include <arch.h>
    4544#include <errno.h>
     
    166165static void udebug_receive_thread_read(call_t *call)
    167166{
    168         uintptr_t uspace_addr;
    169         size_t buf_size;
     167        unative_t uspace_addr;
     168        unative_t to_copy;
     169        unsigned total_bytes;
     170        unsigned buf_size;
    170171        void *buffer;
    171         size_t copied, needed;
     172        size_t n;
    172173        int rc;
    173174
     
    179180         * of threads times thread-id size.
    180181         */
    181         rc = udebug_thread_read(&buffer, buf_size, &copied, &needed);
     182        rc = udebug_thread_read(&buffer, buf_size, &n);
    182183        if (rc < 0) {
    183184                IPC_SET_RETVAL(call->data, rc);
     
    186187        }
    187188
    188         /*
    189          * Make use of call->buffer to transfer data to caller's userspace
    190          */
    191 
    192         IPC_SET_RETVAL(call->data, 0);
    193         /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that
    194            same code in process_answer() can be used
    195            (no way to distinguish method in answer) */
    196         IPC_SET_ARG1(call->data, uspace_addr);
    197         IPC_SET_ARG2(call->data, copied);
    198         IPC_SET_ARG3(call->data, needed);
    199         call->buffer = buffer;
    200 
    201         ipc_answer(&TASK->kb.box, call);
    202 }
    203 
    204 /** Process an AREAS_READ call.
    205  *
    206  * Returns a list of address space areas in the current task, as an array
    207  * of as_area_info_t structures.
    208  *
    209  * @param call  The call structure.
    210  */
    211 static void udebug_receive_areas_read(call_t *call)
    212 {
    213         unative_t uspace_addr;
    214         unative_t to_copy;
    215         size_t data_size;
    216         size_t buf_size;
    217         void *data;
    218 
    219         uspace_addr = IPC_GET_ARG2(call->data); /* Destination address */
    220         buf_size = IPC_GET_ARG3(call->data);    /* Dest. buffer size */
    221 
    222         /*
    223          * Read area list.
    224          */
    225         as_get_area_info(AS, (as_area_info_t **) &data, &data_size);
    226 
    227         /* Copy MAX(buf_size, data_size) bytes */
    228 
    229         if (buf_size > data_size)
    230                 to_copy = data_size;
     189        total_bytes = n;
     190
     191        /* Copy MAX(buf_size, total_bytes) bytes */
     192
     193        if (buf_size > total_bytes)
     194                to_copy = total_bytes;
    231195        else
    232196                to_copy = buf_size;
     
    243207        IPC_SET_ARG2(call->data, to_copy);
    244208
    245         IPC_SET_ARG3(call->data, data_size);
    246         call->buffer = data;
    247 
    248         ipc_answer(&TASK->kb.box, call);
    249 }
    250 
     209        IPC_SET_ARG3(call->data, total_bytes);
     210        call->buffer = buffer;
     211
     212        ipc_answer(&TASK->kb.box, call);
     213}
    251214
    252215/** Process an ARGS_READ call.
     
    368331                udebug_receive_thread_read(call);
    369332                break;
    370         case UDEBUG_M_AREAS_READ:
    371                 udebug_receive_areas_read(call);
    372                 break;
    373333        case UDEBUG_M_ARGS_READ:
    374334                udebug_receive_args_read(call);
  • kernel/generic/src/udebug/udebug_ops.c

    rbb0d3d24 re056e820  
    209209
    210210                mutex_lock(&t->udebug.lock);
    211                 if ((t->flags & THREAD_FLAG_USPACE) != 0) {
     211                if ((t->flags & THREAD_FLAG_USPACE) != 0)
    212212                        t->udebug.active = true;
    213                         mutex_unlock(&t->udebug.lock);
    214                         condvar_broadcast(&t->udebug.active_cv);
    215                 } else {
    216                         mutex_unlock(&t->udebug.lock);
    217                 }
     213                mutex_unlock(&t->udebug.lock);
    218214        }
    219215
     
    359355 *
    360356 * If the sequence is longer than @a buf_size bytes, only as much hashes
    361  * as can fit are copied. The number of bytes copied is stored in @a stored.
    362  * The total number of thread bytes that could have been saved had there been
    363  * enough space is stored in @a needed.
     357 * as can fit are copied. The number of thread hashes copied is stored
     358 * in @a n.
    364359 *
    365360 * The rationale for having @a buf_size is that this function is only
     
    369364 * @param buffer        The buffer for storing thread hashes.
    370365 * @param buf_size      Buffer size in bytes.
    371  * @param stored        The actual number of bytes copied will be stored here.
    372  * @param needed        Total number of hashes that could have been saved.
    373  */
    374 int udebug_thread_read(void **buffer, size_t buf_size, size_t *stored,
    375     size_t *needed)
     366 * @param n             The actual number of hashes copied will be stored here.
     367 */
     368int udebug_thread_read(void **buffer, size_t buf_size, size_t *n)
    376369{
    377370        thread_t *t;
    378371        link_t *cur;
    379372        unative_t tid;
    380         size_t copied_ids;
    381         size_t extra_ids;
     373        unsigned copied_ids;
    382374        ipl_t ipl;
    383375        unative_t *id_buffer;
     
    388380
    389381        /* Allocate a buffer to hold thread IDs */
    390         id_buffer = malloc(buf_size + 1, 0);
     382        id_buffer = malloc(buf_size, 0);
    391383
    392384        mutex_lock(&TASK->udebug.lock);
     
    404396        max_ids = buf_size / sizeof(unative_t);
    405397        copied_ids = 0;
    406         extra_ids = 0;
    407398
    408399        /* FIXME: make sure the thread isn't past debug shutdown... */
    409400        for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) {
     401                /* Do not write past end of buffer */
     402                if (copied_ids >= max_ids) break;
     403
    410404                t = list_get_instance(cur, thread_t, th_link);
    411405
     
    415409
    416410                /* Not interested in kernel threads. */
    417                 if ((flags & THREAD_FLAG_USPACE) == 0)
    418                         continue;
    419 
    420                 if (copied_ids < max_ids) {
     411                if ((flags & THREAD_FLAG_USPACE) != 0) {
    421412                        /* Using thread struct pointer as identification hash */
    422413                        tid = (unative_t) t;
    423414                        id_buffer[copied_ids++] = tid;
    424                 } else {
    425                         extra_ids++;
    426415                }
    427416        }
     
    433422
    434423        *buffer = id_buffer;
    435         *stored = copied_ids * sizeof(unative_t);
    436         *needed = (copied_ids + extra_ids) * sizeof(unative_t);
     424        *n = copied_ids * sizeof(unative_t);
    437425
    438426        return 0;
  • uspace/Makefile

    rbb0d3d24 re056e820  
    4040        app/mkfat \
    4141        app/redir \
    42         app/taskdump \
    4342        app/tester \
    4443        app/tetris \
     
    4847        srv/loader \
    4948        srv/ns \
    50         srv/taskmon \
    5149        srv/vfs \
    5250        srv/bd/ata_bd \
  • uspace/app/init/init.c

    rbb0d3d24 re056e820  
    233233}
    234234
    235 static void mount_scratch(void)
    236 {
    237         int rc;
    238 
    239         printf("Trying to mount null/0 on /scratch... ");
    240         fflush(stdout);
    241 
    242         rc = mount("tmpfs", "/scratch", "null/0", "", 0);
    243         if (rc == EOK)
    244                 printf("OK\n");
    245         else
    246                 printf("Failed\n");
    247 }
    248 
    249235static void mount_data(void)
    250236{
     
    269255                return -1;
    270256        }
    271 
    272         /* Make sure tmpfs is running. */
    273         if (str_cmp(STRING(RDFMT), "tmpfs") != 0) {
    274                 spawn("/srv/tmpfs");
    275         }
    276257       
    277258        spawn("/srv/devfs");
    278         spawn("/srv/taskmon");
    279259       
    280260        if (!mount_devfs()) {
     
    282262                return -2;
    283263        }
    284 
    285         mount_scratch();
    286264       
    287265        spawn("/srv/fhc");
  • uspace/lib/libc/generic/udebug.c

    rbb0d3d24 re056e820  
    6969}
    7070
    71 int udebug_areas_read(int phoneid, void *buffer, size_t n,
    72         size_t *copied, size_t *needed)
    73 {
    74         ipcarg_t a_copied, a_needed;
    75         int rc;
    76 
    77         rc = async_req_3_3(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_AREAS_READ,
    78                 (sysarg_t)buffer, n, NULL, &a_copied, &a_needed);
    79 
    80         *copied = (size_t)a_copied;
    81         *needed = (size_t)a_needed;
    82 
    83         return rc;
    84 }
    85 
    86 
    8771int udebug_mem_read(int phoneid, void *buffer, uintptr_t addr, size_t n)
    8872{
  • uspace/lib/libc/include/udebug.h

    rbb0d3d24 re056e820  
    4747int udebug_thread_read(int phoneid, void *buffer, size_t n,
    4848        size_t *copied, size_t *needed);
    49 int udebug_areas_read(int phoneid, void *buffer, size_t n,
    50         size_t *copied, size_t *needed);
    5149int udebug_mem_read(int phoneid, void *buffer, uintptr_t addr, size_t n);
    5250int udebug_args_read(int phoneid, thash_t tid, sysarg_t *buffer);
Note: See TracChangeset for help on using the changeset viewer.