Changeset 798 for soft


Ignore:
Timestamp:
Mar 2, 2016, 3:08:27 PM (8 years ago)
Author:
meunier
Message:
  • Bug fixes in Rosenfeld
Location:
soft/giet_vm
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/Makefile

    r792 r798  
    269269        mcopy -o -i $(DISK_IMAGE) images/mandel_128.mjpg ::/misc
    270270        mcopy -o -i $(DISK_IMAGE) images/video_160_120.mjpg ::/misc
     271        mcopy -o -i $(DISK_IMAGE) images/boulons.pgm ::/misc
    271272        mdir -/ -b -i $(DISK_IMAGE) ::/
    272273
     
    454455### update rosenfeld/appli.elf on virtual disk
    455456applications/rosenfeld/appli.elf: build/libs/libuser.a build/libs/libmath.a
    456         $(MAKE) -C applications/rosenfeld
     457        TARGET=giet-vm $(MAKE) -C applications/rosenfeld
    457458        mcopy -o -i $(DISK_IMAGE) applications/rosenfeld/appli.elf ::/bin/rosenfeld
    458459
  • soft/giet_vm/applications/rosenfeld/Makefile

    r791 r798  
    66INC_PATH = include
    77
     8TARGET ?= linux
     9#
     10# -- Config ----------
     11
     12ifeq ($(TARGET),giet-vm)
     13
     14C_DEBUG_FLAGS = -O0
     15C_OPTIM_FLAGS = -std=c99 -O2 -fstrict-aliasing
     16C_OS_FLAGS = -DGTODay -DTARGET_OS=GIETVM
     17C_CONFIG_FLAGS = -DCLI
     18C_INC_FLAGS = -I$(INC_PATH) -Inrc2/include -I../.. -I../../giet_libs -I../../giet_xml/
     19CFLAGSCPU := -mips32 -EL -G0 -mhard-float -fomit-frame-pointer -fno-builtin -ffreestanding
     20
     21LDFLAGS := -Lnrc2 -L../../build/libs -Trosenfeld.ld --start-group -lnrc2x -luser -lmath --end-group
     22
     23endif
     24
     25ifeq ($(TARGET),linux)
     26
     27CC = gcc
     28LD = gcc
    829
    930# -- Config ----------
    1031C_DEBUG_FLAGS = -O0
    1132C_OPTIM_FLAGS = -std=c99 -O2 -fstrict-aliasing
    12 C_OS_FLAGS = -DGTODay
     33C_OS_FLAGS = -DGTODay -DTARGET_OS=LINUX
    1334C_CONFIG_FLAGS = -DCLI
    14 C_INC_FLAGS = -I$(INC_PATH) -Inrc2/include -I../.. -I../../giet_libs -I../../giet_xml/
     35C_INC_FLAGS = -I$(INC_PATH) -Inrc2/include
     36CFLAGSCPU =
     37
     38LDFLAGS := -Lnrc2 -Wl,--start-group -lnrc2x -lm -Wl,--end-group
     39
     40endif
     41
     42
     43
     44CFLAGSW := -Wredundant-decls -Wdisabled-optimization -Winline -Wpointer-arith -Wsign-compare -Wendif-labels -Wno-unused-function
    1545
    1646# -- Flags ----------
    1747#CFLAGS = $(C_DEBUG_FLAGS) $(C_OS_FLAGS) $(C_INC_FLAGS) $(C_CONFIG_FLAGS)
    18 CFLAGS = $(C_OPTIM_FLAGS) $(C_OS_FLAGS) $(C_INC_FLAGS) $(C_CONFIG_FLAGS)
     48CFLAGS = $(C_OPTIM_FLAGS) $(C_OS_FLAGS) $(C_INC_FLAGS) $(C_CONFIG_FLAGS) -g -Wall $(CFLAGSW) $(CFLAGSCPU)
    1949
    2050
     
    2858
    2959
    30 CFLAGSW := -Wredundant-decls -Wdisabled-optimization -Winline -Wpointer-arith -Wsign-compare -Wendif-labels
    31 CFLAGSCPU := -mips32 -EL -G0 -mhard-float
    32 CFLAGS := $(CFLAGS) -g -Wall -fomit-frame-pointer $(CFLAGSW) $(CFLAGSCPU) -I$(INC_PATH) -fno-builtin -ffreestanding
    3360
    34 LDFLAGS := -Lnrc2 -L../../build/libs -Trosenfeld.ld --start-group -lnrc2x -luser -lmath --end-group
    3561
    3662
  • soft/giet_vm/applications/rosenfeld/nrc2/Makefile

    r793 r798  
    77
    88# -- File list ----------
    9 FILE = nralloc1.c, nralloc2.c, nralloc2x.c, nrarith0.c, nrarith1.c, nrarith2.c, nrarith2x.c, nrbool1.c, nrbool2.c,  nrhisto.c, nrio0.c, nrio1.c, nrio2.c, nrkernel.c, nrlinalg.c, nrlut.c, nrmem1.c, nrmem1x.c, nrmem2.c, nrmem2x.c, nrset1.c, nrset2.c, nrset2x.c, nrsort1.c, nrsort2.c, nrwrap1.c, nrwrap2.c
     9FILE = nralloc1.c, nralloc2.c, nralloc2x.c, nrarith0.c, nrarith1.c, nrarith2.c, nrarith2x.c, nrbool1.c, nrbool2.c, nrhisto.c, nrio0.c, nrio1.c, nrio2.c, nrkernel.c, nrlinalg.c, nrlut.c, nrmem1.c, nrmem1x.c, nrmem2.c, nrmem2x.c, nrset1.c, nrset2.c, nrset2x.c, nrsort1.c, nrsort2.c, nrwrap1.c, nrwrap2.c
    1010
    1111
     
    1919C_DEBUG_FLAGS = -O0
    2020C_OPTIMISATION_FLAGS = -std=c99 -O2 -fstrict-aliasing
    21 C_OS_FLAGS = -DGTODay
     21C_OS_FLAGS = -DGTODay -DTARGET_OS=GIETVM
    2222C_CONFIG_FLAGS = -DCLI
    2323C_INC_FLAGS = -I$(INC_PATH) -I../../.. -I../../../giet_libs
     
    4141CFLAGSW := -Wredundant-decls -Wdisabled-optimization -Winline -Wpointer-arith -Wsign-compare -Wendif-labels
    4242CFLAGSCPU := -mips32 -EL -G0 -mhard-float
    43 CFLAGS := $(CFLAGS) -g -Wall -fomit-frame-pointer $(CFLAGSW) $(CFLAGSCPU) -I$(DIR_INC) -fno-builtin -ffreestanding
     43CFLAGS := $(CFLAGS) -g -Wall -fomit-frame-pointer $(CFLAGSW) $(CFLAGSCPU) -fno-builtin -ffreestanding
    4444
    4545
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrc_os_config.h

    r791 r798  
    11
    2 #define TARGET_OS GIETVM
    32
    4 #if TARGET_OS==GIETVM
     3#define GIETVM 1
     4#define LINUX 2
     5
     6#if TARGET_OS == GIETVM
    57    #define printf(...)  giet_tty_printf(__VA_ARGS__)
    68
     
    1214    #define fscanf(x, ...)  ;
    1315    #define exit(x)         giet_pthread_exit(NULL)
     16#else
    1417#endif
    1518
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrio2.h

    r772 r798  
    239239IMAGE_EXPORT(uint8 **) LoadPGM_bmatrix  (char *filename, int *nrl, int *nrh, int *ncl, int *nch);
    240240IMAGE_EXPORT(void)     LoadPGM_bmatrix2 (char *filename, int *nrl, int *nrh, int *ncl, int *nch, uint8 **m);
    241 IMAGE_EXPORT(void)    MLoadPGM_bmatrix (char *filename, int nrl, int nrh, int ncl, int nch, uint8 **m);
     241IMAGE_EXPORT(void)     MLoadPGM_bmatrix (char *filename, int nrl, int nrh, int ncl, int nch, uint8 **m);
    242242
    243243IMAGE_EXPORT(void)     SavePGM_bmatrix  (uint8 **m, int nrl, int nrh, int ncl, int nch, char *filename);
    244244IMAGE_EXPORT(void)     SavePGM_ui8matrix(uint8 **m, int nrl, int nrh, int ncl, int nch, char *filename);
    245245
    246 IMAGE_EXPORT(rgb8 **) LoadPPM_rgb8matrix (char *filename, int *nrl, int *nrh, int *ncl, int *nch);
    247 IMAGE_EXPORT(void)    LoadPPM_rgb8matrix2(char *filename, int *nrl, int *nrh, int *ncl, int *nch, rgb8 **m);
    248 
    249 IMAGE_EXPORT(void)    SavePPM_rgb8matrix(rgb8 **m, int nrl, int nrh, int ncl, int nch, char *filename);
     246IMAGE_EXPORT(rgb8 **)  LoadPPM_rgb8matrix (char *filename, int *nrl, int *nrh, int *ncl, int *nch);
     247IMAGE_EXPORT(void)     LoadPPM_rgb8matrix2(char *filename, int *nrl, int *nrh, int *ncl, int *nch, rgb8 **m);
     248
     249IMAGE_EXPORT(void)     SavePPM_rgb8matrix(rgb8 **m, int nrl, int nrh, int ncl, int nch, char *filename);
     250
     251
     252
    250253#ifdef __cplusplus
    251254}
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2.c

    r772 r798  
    1313
    1414#include <stdio.h>
    15 #include <stddef.h>
    1615#include <stdlib.h>
     16#include <string.h>
    1717
    1818#include "nrc_os_config.h"
     19
     20#if TARGET_OS == LINUX
     21    #include <sys/types.h>
     22    #include <sys/stat.h>
     23    #include <fcntl.h>
     24    #include <unistd.h>
     25#endif
     26
     27
    1928#include "mypredef.h"
    2029#include "nrtype.h"
     
    2837#include "nrio1.h"
    2938#include "nrio2.h"
     39
     40#define isalnum(x) (((x) >= 0x30 && (x) <= 0x39) \
     41                 || ((x) >= 0x41 && (x) <= 0x5A) \
     42                 || ((x) >= 0x61 && (x) <= 0x7A))
     43
    3044
    3145/*
     
    870884    }   
    871885}
     886
     887
     888
     889/* --------------------------------------- */
     890static char * readitem(int fd, char * buffer)
     891/* --------------------------------------- */
     892{
     893    char * aux;
     894    int k;
     895    int n;
     896   
     897    k = 0;
     898    aux = buffer;
     899    while (1) {
     900        n = read(fd, aux, 1);
     901        if (n == 0) {
     902            break;
     903        }
     904        switch (k) {
     905            case 0:
     906                if (*aux == '#') {
     907                    k = 1;
     908                }
     909                if (isalnum(*aux)) {
     910                    k = 2;
     911                    aux++;
     912                }
     913                break;
     914            case 1:
     915                if (*aux == 0xA) {
     916                    k = 0;
     917                }
     918                break;
     919            case 2:
     920                if (!isalnum(*aux)) {
     921                    *aux = 0;
     922                    return buffer;
     923                }
     924                aux++;
     925                break;
     926        }
     927    }
     928    *aux = 0;
     929    return buffer;
     930}
     931
     932
     933/* ------------------------------------------------- */
     934static void ReadPGMrow(int fd, int width, uint8 * line)
     935/* ------------------------------------------------- */
     936{
     937    read(fd, &line[0], sizeof(uint8) * width);
     938}
     939
     940
     941/* -------------------------------------------------- */
     942static void WritePGMrow(uint8 * line, int width, int fd)
     943/* -------------------------------------------------- */
     944{
     945    write(fd, &line[0], sizeof(uint8) * width);
     946}
     947
     948
     949/* ----------------------------------------------------------------------------------------------- */
     950IMAGE_EXPORT(uint8 **) LoadPGM_ui8matrix(char * filename, int * nrl, int * nrh, int * ncl, int * nch)
     951/* ----------------------------------------------------------------------------------------------- */
     952{
     953    // only for P5 binary type, not for text type
     954   
     955    int height, width, gris;
     956    uint8 ** m;
     957    int fd;
     958   
     959    char buffer[80];
     960    int i;
     961   
     962    // open file
     963    fd = open(filename, O_RDONLY);
     964    if (fd < 0) {
     965        printf("*** Error: Can't open file %s in %s.\n", filename, __func__);
     966    }
     967   
     968    // read PGM header
     969    readitem(fd, &buffer[0]);
     970    if (strcmp(&buffer[0], "P5") != 0) {
     971        printf("*** Error: Invalid file header in file %s\n", filename);
     972    }
     973   
     974    width  = atoi(readitem(fd, &buffer[0]));
     975    height = atoi(readitem(fd, &buffer[0]));
     976    gris   = atoi(readitem(fd, &buffer[0]));
     977   
     978    *nrl = 0;
     979    *nrh = height - 1;
     980    *ncl = 0;
     981    *nch = width - 1;
     982    m = ui8matrix(*nrl, *nrh, *ncl, *nch);
     983   
     984    for (i = 0; i < height; i++) {
     985        ReadPGMrow(fd, width, m[i]);
     986    }
     987   
     988    close(fd);
     989   
     990    return m;
     991}
     992
     993
     994/* ----------------------------------------------------------------------------------------------- */
     995IMAGE_EXPORT(void) SavePGM_ui8matrix(uint8 ** m, int nrl, int nrh, int ncl, int nch, char * filename)
     996/* ----------------------------------------------------------------------------------------------- */
     997{
     998    int nrow = nrh - nrl + 1;
     999    int ncol = nch - ncl + 1;
     1000   
     1001    char buffer[80];
     1002   
     1003    int fd;
     1004    int i;
     1005   
     1006    fd = open(filename, O_TRUNC | O_CREAT);
     1007    if (fd < 0) {
     1008        printf("*** Error: Impossible to open file %s in %s\n", filename, __func__);
     1009    }
     1010   
     1011    /* enregistrement de l'image au format rpgm */
     1012    snprintf(buffer, 80, "P5\n%d %d\n255\n", ncol, nrow);
     1013    write(fd, buffer, strlen(buffer));
     1014    for (i = nrl; i <= nrh; i++) {
     1015        WritePGMrow(m[i], ncol, fd);
     1016    }
     1017   
     1018    /* fermeture du fichier */
     1019    close(fd);
     1020}
     1021
     1022
     1023
  • soft/giet_vm/applications/rosenfeld/rosenfeld.py

    r791 r798  
    4444
    4545    heap_base  = 0x60000000
    46     heap_size  = 0x00200000     # 2 Mbytes (per cluster)
     46    heap_size  = 0x01000000     # 16 Mbytes (per cluster)
    4747
    4848    # create vspace
    49     vspace = mapping.addVspace( name = 'rosenfeld', startname = 'rosen_data' )
     49    vspace = mapping.addVspace( name = 'rosenfeld', startname = 'rosen_data', active = True )
    5050   
    5151    # data vseg : shared (only in cluster[0,0])
  • soft/giet_vm/applications/rosenfeld/src/bmpNR.c

    r772 r798  
    1010#include <stdlib.h>
    1111#include <math.h>
    12 
    1312
    1413/* -- image -- */
     
    2019#include "nralloc.h"
    2120#endif
     21
     22#if TARGET_OS == LINUX
     23    #include <sys/types.h>
     24    #include <sys/stat.h>
     25    #include <fcntl.h>
     26    #include <unistd.h>
     27#endif
     28
    2229
    2330#include "palette.h"
     
    242249    //DEBUG(printf("BMP  : %d %d\n", sizeof( BitmapFileHeader), sizeof( BitmapInfoHeader)));
    243250    if (sizeof(BitmapFileHeader) != 14) {
    244         printf("*** Error SaveMBP: sizeof(BitmapFileHeader) = %d should be 14...\n", sizeof(BitmapFileHeader));
     251        printf("*** Error SaveMBP: sizeof(BitmapFileHeader) = %d should be 14...\n", (int) sizeof(BitmapFileHeader));
    245252    }
    246253
  • soft/giet_vm/applications/rosenfeld/src/dummy_func.c

    r792 r798  
    1010
    1111
    12 
    13 IMAGE_EXPORT(uint8 **) LoadPGM_ui8matrix(char *filename, int *nrl, int *nrh, int *ncl, int *nch) { return NULL; }
    14 IMAGE_EXPORT(void) SavePGM_ui8matrix(uint8 **m, int nrl, int nrh, int ncl, int nch, char *filename) {}
    15 
    1612void write_ui8matrix_positive (uint8  **m,int i0, int i1, int j0, int j1, int iformat, char *filename) {}
    1713
  • soft/giet_vm/applications/rosenfeld/src/ecc_common.c

    r777 r798  
    88#include <math.h>
    99
    10 
    1110#ifdef CLI
    1211#include "nrc_os_config.h"
    1312#include "nrc.h"
    1413#endif
     14
     15#if TARGET_OS == LINUX
     16    #include <sys/types.h>
     17    #include <sys/stat.h>
     18    #include <fcntl.h>
     19#endif
     20
    1521
    1622#include "ecc_common.h"
  • soft/giet_vm/applications/rosenfeld/src/ecc_features.c

    r772 r798  
    1919#include <malloc.h>
    2020
    21 #ifdef OPENMP
    22 #include <omp.h>
    23 #endif
    2421
    2522#ifdef CLI
    2623#include "nrc_os_config.h"
    2724#include "nrc.h"
     25#endif
     26
     27
     28
     29#if TARGET_OS == LINUX
     30    #include <sys/types.h>
     31    #include <sys/stat.h>
     32    #include <fcntl.h>
     33#endif
     34
     35
     36#ifdef OPENMP
     37#include <omp.h>
    2838#endif
    2939
     
    147157// ---------------------------------
    148158{
    149     int ne;
     159    int ne = 0;
    150160    // @QM giet
    151161    fscanf(fd, "%d", &ne);
     
    162172// --------------------------------------------------------------
    163173{
    164     int i, t;
     174    int i;
    165175   
    166176    for (i = 1; i <= ne; i++) {
  • soft/giet_vm/applications/rosenfeld/src/ecc_main_rosenfeld_sa.c

    r791 r798  
    159159// ---------------------------------------------------------------------
    160160{
    161     printf("[---------------------------]");
    162     printf("[--- main_rosenfeld_file ---]");
    163     printf("[---------------------------]");
    164    
    165     char *pathSrc = src_path;
    166     char *pathDst = dst_path;
    167    
    168     uint8 **X0, **X;
    169     uint8 **E8;
    170    
    171     uint32 **E32;
    172     uint32 *S; // Stack for Bailey algorithm
    173    
    174     uint32 *T;
    175     uint32 *A;
    176     uint32 *N;
    177     //uint32 *SNE; // memorisation de la somme des ne: sne
     161    printf("[---------------------------]\n");
     162    printf("[--- main_rosenfeld_file ---]\n");
     163    printf("[---------------------------]\n");
     164   
     165    char * pathSrc = src_path;
     166    char * pathDst = dst_path;
     167   
     168    uint8 ** X0;
     169    uint8 ** X;
     170    uint8 ** E8;
     171   
     172    uint32 ** E32;
     173    uint32 * S; // Stack for Bailey algorithm
     174   
     175    uint32 * T;
     176    uint32 * A;
     177    uint32 * N;
     178    //uint32 * SNE; // memorisation de la somme des ne: sne
    178179
    179180    int i0, i1, j0, j1;
    180     int height, width, border=1;
     181    int height, width, border = 1;
    181182    uint32 nemax, nermax;
    182183    int na;
     
    191192
    192193    // chargement d'une image depuis le disque
    193     //X0 = LoadPGM_ui8matrix(complete_filename, &i0, &i1, &j0, &j1);
    194     init_forme_boulon1(&X0, &i0, &i1, &j0, &j1);
    195    
     194    printf("Loading file %s... ", filename);
     195    X0 = LoadPGM_ui8matrix(complete_filename, &i0, &i1, &j0, &j1);
     196    //init_forme_boulon1(&X0, &i0, &i1, &j0, &j1);
     197    printf("done.\n");
     198
     199    printf("Allocating memory... ");
    196200    // allocation memoire
    197201    X   = ui8matrix (i0 - border, i1 + border, j0 - border, j1 + border);
     
    206210    // pre-traitements
    207211    binarisation_ui8matrix(X0, i0, i1, j0, j1, 20, 1, X); // pour le traitement
    208     //binarisation_ui8matrix(X0, i0, i1, j0, j1, 20, 255, X0); // pour la verif visuelle
    209     //generate_path_filename(pathDst, "verif.pgm", complete_filename, 1024);
    210     //SavePGM_ui8matrix(X0, i0, i1, j0, j1, complete_filename);
     212    binarisation_ui8matrix(X0, i0, i1, j0, j1, 20, 255, X0); // pour la verif visuelle
     213    printf("done.\n");
     214
     215    printf("Saving file %s for verification... ", complete_filename);
     216    generate_path_filename(pathDst, "verif.pgm", complete_filename, 1024);
     217    SavePGM_ui8matrix(X0, i0, i1, j0, j1, complete_filename);
     218    printf("done.\n");
    211219
    212220    height = i1 - i0 + 1;
     
    246254    /*na = Rosenfeld_UF_Org2_4C    (X, height, width, E32, T, A, nemax, Stats); ECC_VERBOSE(printf("na = %d\n", na)); filename = "Rosenfeld_UF_Org2_4C.bmp";     mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8); generate_path_filename(pathDst, filename, complete_filename); SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename); zero_ui32matrix(E32, i0-border, i1+border, j0-border, j1+border); display_RegionStatsVector(Stats, 1, na, "Stats"); zero_RegionStatsVector(Stats, 0, nemax);*/
    247255
    248     free_ui8matrix (X0,  i0,        i1,        j0,        j1);
    249     free_ui8matrix (X,   i0-border, i1+border, j0-border, j1+border);
    250     free_ui8matrix (E8,  i0-border, i1+border, j0-border, j1+border);
    251     free_ui32matrix(E32, i0-border, i1+border, j0-border, j1+border);
     256    free_ui8matrix (X0,  i0,          i1,          j0,          j1);
     257    free_ui8matrix (X,   i0 - border, i1 + border, j0 - border, j1 + border);
     258    free_ui8matrix (E8,  i0 - border, i1 + border, j0 - border, j1 + border);
     259    free_ui32matrix(E32, i0 - border, i1 + border, j0 - border, j1 + border);
    252260   
    253261    free_ui32vector(T, 0, nemax);
     
    255263    free_ui32vector(N, 0, nemax);
    256264   
    257     free_ui32vector(S, 0, 2*nermax);
     265    free_ui32vector(S, 0, 2 * nermax);
    258266
    259267    return;
     
    267275    char *dst_path;
    268276   
    269     printf("[======================]");
    270     printf("[=== main_rosenfeld ===]");
    271     printf("[======================]");
    272    
    273     src_path = "./"; // ne pas oublier le / a la fin
     277    printf("[======================]\n");
     278    printf("[=== main_rosenfeld ===]\n");
     279    printf("[======================]\n");
     280   
     281    src_path = "/misc/"; // ne pas oublier le / a la fin
    274282    dst_path = "";
    275283   
     
    287295    int i;
    288296   
    289     printf("=================");
    290     printf("== display_arg ==");
    291     printf("=================");
    292     printf("");
     297    printf("=================\n");
     298    printf("== display_arg ==\n");
     299    printf("=================\n");
     300    printf("\n");
    293301   
    294302    printf("argc = %d\n", argc);
     
    297305        printf("%s ", argv[i]);
    298306    }
    299     printf("");
     307    printf("\n");
    300308}
    301309// -----------------------
     
    303311// -----------------------
    304312{
    305     printf("=====================");
    306     printf("== ecc_info_define ==");
    307     printf("=====================");
    308     printf("");
     313    printf("=====================\n");
     314    printf("== ecc_info_define ==\n");
     315    printf("=====================\n");
     316    printf("\n");
    309317    ecc_info_omp();
    310318    //Label_Display_Info();
    311     printf("");
     319    printf("\n");
    312320}
    313321// -----------------------------
    314 int main(int argc, char* argv[])
     322__attribute__((constructor)) void main(int argc, char* argv[])
    315323// -----------------------------
    316324{
    317 #if TARGET_OS==GIET_VM
     325#if TARGET_OS == GIETVM
    318326    giet_tty_alloc(1);
     327    heap_init(0, 0);
    319328#endif
    320329    display_arg(argc, argv);
     
    322331    main_rosenfeld(argc, argv);
    323332    printf("[main]: bye");
    324     return 0;
    325 }
     333    exit(0);
     334}
  • soft/giet_vm/giet_drivers/bdv_driver.c

    r728 r798  
    253253    unsigned int ltid    = (_bdv_trdid      ) & 0xFF;
    254254
    255     // Reset NORUN_MASK_IOC bit 
     255    // Reset NORUN_MASK_IOC bit
    256256    static_scheduler_t* psched  = (static_scheduler_t*)_schedulers[x][y][p];
    257257    unsigned int*       ptr     = &psched->context[ltid].slot[CTX_NORUN_ID];
     
    263263                   0 );          // don't force context switch
    264264
    265 #if GIET_DEBUG_IOC 
    266 unsigned int pid  = _get_procid();
    267 unsigned int c_x  = pid >> (Y_WIDTH + P_WIDTH);
    268 unsigned int c_y  = (pid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
    269 unsigned int c_p  = pid & ((1<<P_WIDTH)-1);
    270 if ( _get_proctime() > GIET_DEBUG_IOC )
    271 _printf("\n[BDV DEBUG] Processor[%d,%d,%d] enters _bdv_isr() at cycle %d\n"
    272         "  for thread %d running on P[%d,%d,%d] / bdv_status = %x\n",
    273         c_x , c_y , c_p , _get_proctime() ,
    274         ltid , x , y , p , status );
     265#if GIET_DEBUG_IOC
     266    unsigned int pid  = _get_procid();
     267    unsigned int c_x  = pid >> (Y_WIDTH + P_WIDTH);
     268    unsigned int c_y  = (pid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
     269    unsigned int c_p  = pid & ((1<<P_WIDTH)-1);
     270    if ( _get_proctime() > GIET_DEBUG_IOC )
     271        _printf("\n[BDV DEBUG] Processor[%d,%d,%d] enters _bdv_isr() at cycle %d\n"
     272                "  for thread %d running on P[%d,%d,%d] / bdv_status = %x\n",
     273                c_x , c_y , c_p , _get_proctime() ,
     274                ltid , x , y , p , status );
    275275#endif
    276276
  • soft/giet_vm/giet_fat32/fat32.c

    r797 r798  
    565565
    566566/////////////////////////////////////////////////////////////////
    567 static inline unsigned int _get_fat_entry( unsigned int  cluster,
     567static unsigned int _get_fat_entry( unsigned int  cluster,
    568568                                           unsigned int* value )
    569569{
     
    24402440
    24412441#if GIET_DEBUG_FAT
    2442 unsigned int procid  = _get_procid();
    2443 unsigned int x       = procid >> (Y_WIDTH + P_WIDTH);
    2444 unsigned int y       = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1);
    2445 unsigned int p       = procid & ((1<<P_WIDTH)-1);
    2446 if ( _get_proctime() > GIET_DEBUG_FAT )
    2447 _printf("\n[DEBUG FAT] _fat_open(): P[%d,%d,%d] enters for path <%s>\n"
    2448         " create = %d / read_only = %d / truncate = %d\n",
    2449         x, y, p, pathname , create , read_only , truncate );
     2442    unsigned int procid  = _get_procid();
     2443    unsigned int x       = procid >> (Y_WIDTH + P_WIDTH);
     2444    unsigned int y       = (procid >> P_WIDTH) & ((1 << Y_WIDTH) - 1);
     2445    unsigned int p       = procid & ((1 << P_WIDTH) - 1);
     2446    if ( _get_proctime() > GIET_DEBUG_FAT )
     2447        _printf("\n[DEBUG FAT] _fat_open(): P[%d,%d,%d] enters for path <%s>\n"
     2448                " create = %d / read_only = %d / truncate = %d\n",
     2449                x, y, p, pathname , create , read_only , truncate );
    24502450#endif
    24512451
    24522452    // checking FAT initialized
    2453     if( _fat.initialized != FAT_INITIALIZED )
     2453    if ( _fat.initialized != FAT_INITIALIZED )
    24542454    {
    24552455        _printf("\n[FAT ERROR] _fat_open(): FAT not initialized\n");
     
    24992499
    25002500#if GIET_DEBUG_FAT
    2501 if ( _get_proctime() > GIET_DEBUG_FAT )
    2502 _printf("\n[DEBUG FAT] _fat_open(): P[%d,%d,%d] create a new file <%s>\n",
    2503         x , y , p , pathname );
     2501        if ( _get_proctime() > GIET_DEBUG_FAT )
     2502            _printf("\n[DEBUG FAT] _fat_open(): P[%d,%d,%d] create a new file <%s>\n",
     2503                    x , y , p , pathname );
    25042504#endif
    25052505
     
    25622562
    25632563#if GIET_DEBUG_FAT
    2564 if ( _get_proctime() > GIET_DEBUG_FAT )
    2565 {
    2566     _printf("\n[DEBUG FAT] _fat_open() : new inode created for <%s>\n"
    2567             " size = %x / cluster = %x / cache = %x",
    2568             child->name , child->size , child->cluster , child->cache );
    2569     if ( child->cache != NULL )
    2570     {
    2571          _printf(" / pdesc[0] = %x\n", (unsigned int)(child->cache->children[0]) );
    2572     }
    2573     else
    2574     {
    2575          _printf("\n");
    2576     }
    2577 }
     2564        if ( _get_proctime() > GIET_DEBUG_FAT )
     2565        {
     2566            _printf("\n[DEBUG FAT] _fat_open() : new inode created for <%s>\n"
     2567                    " size = %x / cluster = %x / cache = %x",
     2568                    child->name , child->size , child->cluster , child->cache );
     2569            if ( child->cache != NULL )
     2570            {
     2571                _printf(" / pdesc[0] = %x\n", (unsigned int)(child->cache->children[0]) );
     2572            }
     2573            else
     2574            {
     2575                _printf("\n");
     2576            }
     2577        }
    25782578#endif
    25792579
     
    25852585
    25862586#if GIET_DEBUG_FAT
    2587 if ( _get_proctime() > GIET_DEBUG_FAT )
    2588 {
    2589     _printf("\n[DEBUG FAT] _fat_open(): P[%d,%d,%d] found file <%s>\n"
    2590             " inode = %x / size = %x\n",
    2591             x , y , p , pathname , (unsigned int)child , child->size );
    2592 
    2593     _display_clusters_list( child );
    2594 }
     2587        if ( _get_proctime() > GIET_DEBUG_FAT )
     2588        {
     2589            _printf("\n[DEBUG FAT] _fat_open(): P[%d,%d,%d] found file <%s>\n"
     2590                    " inode = %x / size = %x\n",
     2591                    x , y , p , pathname , (unsigned int)child , child->size );
     2592
     2593            _display_clusters_list( child );
     2594        }
    25952595#endif
    25962596
     
    26242624
    26252625    // truncate the file if requested
    2626     if ( truncate && !read_only && !child->is_dir )
     2626    if ( truncate && !read_only && !child->is_dir && child->size != 0 )
    26272627    {
    26282628        // empty file
     
    26552655
    26562656#if GIET_DEBUG_FAT
    2657 if ( _get_proctime() > GIET_DEBUG_FAT )
    2658 _printf("\n[DEBUG FAT] _fat_open(): P[%d,%d,%d] get fd = %d for <%s>\n"
    2659         " inode = %x / offset = %x / read_only = %d / size = %x / cluster = %x\n",
    2660         x , y , p , fd_id , pathname ,
    2661         (unsigned int)_fat.fd[fd_id].inode,
    2662         _fat.fd[fd_id].seek,
    2663         _fat.fd[fd_id].read_only,
    2664         _fat.fd[fd_id].inode->size,
    2665         _fat.fd[fd_id].inode->cluster );
     2657    if ( _get_proctime() > GIET_DEBUG_FAT )
     2658        _printf("\n[DEBUG FAT] _fat_open(): P[%d,%d,%d] get fd = %d for <%s>\n"
     2659                " inode = %x / offset = %x / read_only = %d / size = %x / cluster = %x\n",
     2660                x , y , p , fd_id , pathname ,
     2661                (unsigned int)_fat.fd[fd_id].inode,
     2662                _fat.fd[fd_id].seek,
     2663                _fat.fd[fd_id].read_only,
     2664                _fat.fd[fd_id].inode->size,
     2665                _fat.fd[fd_id].inode->cluster );
    26662666#endif
    26672667
  • soft/giet_vm/giet_kernel/exc_handler.c

    r709 r798  
    1616///////////////////////////////////////////////////////////////////////////////////
    1717
    18 static void _cause_ukn();
    19 static void _cause_adel();
    20 static void _cause_ades();
    21 static void _cause_ibe();
    22 static void _cause_dbe();
    23 static void _cause_bp();
    24 static void _cause_ri();
    25 static void _cause_cpu();
    26 static void _cause_ovf();
     18static void _cause_ukn(unsigned int * regs_table);
     19static void _cause_adel(unsigned int * regs_table);
     20static void _cause_ades(unsigned int * regs_table);
     21static void _cause_ibe(unsigned int * regs_table);
     22static void _cause_dbe(unsigned int * regs_table);
     23static void _cause_bp(unsigned int * regs_table);
     24static void _cause_ri(unsigned int * regs_table);
     25static void _cause_cpu(unsigned int * regs_table);
     26static void _cause_ovf(unsigned int * regs_table);
    2727
    2828extern void _int_handler();
     
    5555
    5656///////////////////////////////////////////////
    57 static void _display_cause( unsigned int type )
     57static void _display_cause( unsigned int type, unsigned int * regs_table )
    5858{
    5959    unsigned int gpid       = _get_procid();
    6060    unsigned int cluster_xy = gpid >> P_WIDTH;
    6161    unsigned int x          = cluster_xy >> Y_WIDTH;
    62     unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);
    63     unsigned int p          = gpid & ((1<<P_WIDTH)-1);
     62    unsigned int y          = cluster_xy & ((1 << Y_WIDTH) - 1);
     63    unsigned int p          = gpid & ((1 << P_WIDTH) - 1);
    6464    unsigned int trdid      = _get_thread_trdid();
    6565    unsigned int ltid       = _get_thread_ltid();
     
    8585            mips32_exc_str[type], _get_epc(), _get_bvar() );
    8686
     87    _printf("Registers:\n");
     88    _printf("CR:   %X\tEPC:  %X\tSR:   %X\tCO_HI %X\tC0_LO  %X\n",
     89            regs_table[33], regs_table[32], regs_table[34], regs_table[36], regs_table[35]);
     90    _printf("at_1  %X\tv0_2  %X\tv1_3  %X\ta0_4  %X\ta1_5   %X\n",
     91            regs_table[1], regs_table[2], regs_table[3], regs_table[4], regs_table[5]);
     92    _printf("a2_6  %X\ta3_7  %X\tt0_8  %X\tt1_9  %X\tt2_10  %X\n",
     93            regs_table[6], regs_table[7], regs_table[8], regs_table[9], regs_table[10]);
     94    _printf("t3_11 %X\tt4_12 %X\tt5_13 %X\tt6_14 %X\tt7_15  %X\n",
     95            regs_table[11], regs_table[12], regs_table[13], regs_table[14], regs_table[15]);
     96    _printf("s0_16 %X\ts1_17 %X\ts2_18 %X\ts3_19 %X\ts4_20  %X\n",
     97            regs_table[16], regs_table[17], regs_table[18], regs_table[19], regs_table[20]);
     98    _printf("s5_21 %X\ts6_22 %X\ts7_23 %X\tt8_24 %X\tt9_25  %X\n",
     99            regs_table[21], regs_table[22], regs_table[23], regs_table[24], regs_table[25]);
     100    _printf("gp_28 %X\tsp_29 %X\tfp_30 %X\tra_31 %X\n\n",
     101            regs_table[28], regs_table[29], regs_table[30], regs_table[31]);
     102
     103
    87104    // register KILL signal
    88105    _atomic_or( &psched->context[ltid].slot[CTX_SIGS_ID] , SIGS_MASK_KILL );
     
    95112}  // end display_cause()
    96113
    97 static void _cause_ukn()  { _display_cause(0); }
    98 static void _cause_adel() { _display_cause(1); }
    99 static void _cause_ades() { _display_cause(2); }
    100 static void _cause_ibe()  { _display_cause(3); }
    101 static void _cause_dbe()  { _display_cause(4); }
    102 static void _cause_bp()   { _display_cause(5); }
    103 static void _cause_ri()   { _display_cause(6); }
    104 static void _cause_cpu()  { _display_cause(7); }
    105 static void _cause_ovf()  { _display_cause(8); }
     114static void _cause_ukn(unsigned int * regs_table)  { _display_cause(0, regs_table); }
     115static void _cause_adel(unsigned int * regs_table) { _display_cause(1, regs_table); }
     116static void _cause_ades(unsigned int * regs_table) { _display_cause(2, regs_table); }
     117static void _cause_ibe(unsigned int * regs_table)  { _display_cause(3, regs_table); }
     118static void _cause_dbe(unsigned int * regs_table)  { _display_cause(4, regs_table); }
     119static void _cause_bp(unsigned int * regs_table)   { _display_cause(5, regs_table); }
     120static void _cause_ri(unsigned int * regs_table)   { _display_cause(6, regs_table); }
     121static void _cause_cpu(unsigned int * regs_table)  { _display_cause(7, regs_table); }
     122static void _cause_ovf(unsigned int * regs_table)  { _display_cause(8, regs_table); }
    106123
    107124// Local Variables:
  • soft/giet_vm/giet_kernel/exc_handler.h

    r440 r798  
    1717///////////////////////////////////////////////////////////////////////////////////
    1818
    19 typedef void (*_exc_func_t)(void);
     19typedef void (*_exc_func_t)();
    2020
    2121extern const _exc_func_t _cause_vector[16];
  • soft/giet_vm/giet_kernel/giet.s

    r742 r798  
    3939_giet:
    4040    mfc0    $27,    $13                 /* $27 <= Cause register */
    41     la      $26,    _cause_vector       /* $26 <= _cause_vector */
    42     andi    $27,    $27,    0x3c            /* $27 <= XCODE*4 */
    43     addu    $26,    $26,    $27             /* $26 <= &_cause_vector[XCODE] */
    44     lw      $26,    ($26)               /* $26 <=  _cause_vector[XCODE] */
    45     jr      $26                         /* Jump to handler indexed by XCODE */
     41    andi    $27,    $27,    0x3c        /* $27 <= XCODE*4 */
     42    beq     $27,    $0,     do_jump     /* jump if interrupt */
     43    addiu   $26,    $0,     0x20
     44    beq     $27,    $26,    do_jump     /* jump if syscall */
     45    /* Other exception: saving registers for future display */
     46    addiu   $27,    $29,    -38*4
     47    sw      $29,    (29*4)($27)
     48    or      $29,    $27,    $0
     49   
     50    .set noat
     51    sw      $1,     (1*4)($29)
     52    .set at
     53    sw      $2,     (2*4)($29)
     54    sw      $3,     (3*4)($29)
     55    sw      $4,     (4*4)($29)
     56    sw      $5,     (5*4)($29)
     57    sw      $6,     (6*4)($29)
     58    sw      $7,     (7*4)($29)
     59    sw      $8,     (8*4)($29)
     60    sw      $9,     (9*4)($29)
     61    sw      $10,    (10*4)($29)
     62    sw      $11,    (11*4)($29)
     63    sw      $12,    (12*4)($29)
     64    sw      $13,    (13*4)($29)
     65    sw      $14,    (14*4)($29)
     66    sw      $15,    (15*4)($29)
     67    sw      $24,    (24*4)($29)
     68    sw      $25,    (25*4)($29)
     69    sw      $16,    (16*4)($29)
     70    mfc0    $16,    $14               /* Read EPC */
     71    sw      $17,    (17*4)($29)
     72    mfc0    $17,    $13               /* read CR (used later) */
     73    sw      $18,    (18*4)($29)
     74    mfc0    $18,    $12               /* Read current SR (used later) */
     75    sw      $19,    (19*4)($29)
     76    sw      $20,    (20*4)($29)
     77    sw      $21,    (21*4)($29)
     78    sw      $22,    (22*4)($29)
     79    sw      $23,    (23*4)($29)
     80    sw      $30,    (30*4)($29)
     81    sw      $28,    (28*4)($29)
     82    mflo    $14                       /* read LO */
     83    mfhi    $15                       /* read HI */
     84    sw      $31,    (31*4)($29)       /* save RA */
     85    sw      $16,    (32*4)($29)       /* Save EPC */
     86    sw      $17,    (33*4)($29)       /* Save CR */
     87    sw      $18,    (34*4)($29)       /* Save SR */
     88    sw      $14,    (35*4)($29)       /* save LO */
     89    sw      $15,    (36*4)($29)       /* save HI */
     90    or      $4,     $0, $27
     91   
     92   
     93do_jump:
     94    mfc0    $27,    $13               /* $27 <= Cause register */
     95    andi    $27,    $27,    0x3c      /* $27 <= XCODE*4 */
     96    la      $26,    _cause_vector     /* $26 <= _cause_vector */
     97    addu    $26,    $26,    $27       /* $26 <= &_cause_vector[XCODE] */
     98    lw      $26,    0($26)            /* $26 <=  _cause_vector[XCODE] */
     99    jr      $26                       /* Jump to handler indexed by XCODE */
    46100
    47101    .endfunc
Note: See TracChangeset for help on using the changeset viewer.