Skip to content
Snippets Groups Projects
Commit e51099e7 authored by Daniela Genius's avatar Daniela Genius
Browse files

solved make problem

parent beb1d755
No related branches found
No related tags found
1 merge request!72Syscams
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
//ajoute DG
//#include <mutek/printk.h>
//#include <pthread.h>
//fin ajoute DG
//#include "pthread.h"
//#include "mwmr.h"
#include "request.h"
#include "syncchannel.h"
#include "request_manager.h"
#include "debug.h"
#include "random.h"
#include "tracemanager.h"
#include "srl.h"
//ajoute DG
//#include "srl_private_types.h"
//fin ajoute DG
#include "Door.h"
#include "Door.h"
#include "Bell.h"
#include "Magnetron.h"
#include "Controller.h"
#include "Controller.h"
#include "MicroWaveOven.h"
#include "ControlPanel.h"
//#include <cpu.h>
//#include "segmentation.h"
#define NB_PROC 2
#define WIDTH 4
#define DEPTH 16
pthread_barrier_t barrier;
pthread_attr_t *attr_t;
pthread_mutex_t __mainMutex;
//ajoute DG
//typedef struct srl_mwmr_status_s srl_mwmr_status_s;
//typedef struct srl_mwmr_lock_s srl_mwmr_lock_t;
//fin ajoute DG
void __user_init() {
}
#define MWMRd 0x20000000
#define LOCKS 0x30000000
#define base(arg) arg
typedef struct mwmr_s mwmr_t;
/*************************Door*****************************/
// uint32_t *Door_open__fifo_data_in = (uint32_t*)(base(MWMRd)+0x1000); //0x20200200;
//uint32_t *Door_closed__fifo_data_in = (uint32_t*)(base(MWMRd)+0x2000); //0x20200400;
//uint32_t *Door_okDoor__fifo_data_out = (uint32_t*)(base(MWMRd)+0x0000); //0x20200000;
mwmr_t *Door_open__Controller_open = (mwmr_t*)(base(MWMRd)+0x3000);
mwmr_t *Door_closed__Controller_closed = (mwmr_t*)(base(MWMRd)+0x4000);
mwmr_t *Door_okDoor__Controller_okDoor = (mwmr_t*)(base(MWMRd)+0x2000);
/***************************Bell*****************************/
uint32_t *ringBell__fifo_data_in = (uint32_t*)(base(MWMRd)+0x0000); //0x20200000;
mwmr_t *Controller_ringBell__Bell_ring = (mwmr_t*)(base(MWMRd)+0x2000);
/**********************Magnetron*****************************/
uint32_t *startMagnetron__fifo_data_in = (uint32_t*)(base(MWMRd)+0x0000); //0x20200000;
uint32_t *stopMagnetron__fifo_data_in = (uint32_t*)(base(MWMRd)+0x1000); //0x20200200;
mwmr_t *Controller_startMagnetron__Magnetron_startM = (mwmr_t*)(base(MWMRd)+0x2000);
mwmr_t *Controller_stopMagnetron__Magnetron_stopM = (mwmr_t*)(base(MWMRd)+0x3000);
/*******************ControlPanel*****************************/
uint32_t *startButton__fifo_data_out = (uint32_t*)(base(MWMRd)+0x0000); //0x20200000;
uint32_t *LEDon__Controller_startCooking__fifo_data_out = (uint32_t*)(base(MWMRd)+0x0000); //0x20200000;
uint32_t *LEDoff__Controller_stopCooking__fifo_data_out = (uint32_t*)(base(MWMRd)+0x0000); //0x20200000;
mwmr_t *ControlPanel_startButton__Controller_start = (mwmr_t*)(base(MWMRd)+0x2000);
mwmr_t *ControlPanel_LEDon__Controller_startCooking = (mwmr_t*)(base(MWMRd)+0x2000);
mwmr_t *ControlPanel_LEDoff__Controller_stopCooking = (mwmr_t*)(base(MWMRd)+0x2000);
/*****************************Main****************************/
int main(int argc, char *argv[]) {
void *ptr;
pthread_barrier_init(&barrier,NULL, NB_PROC);
pthread_attr_t *attr_t = malloc(sizeof(pthread_attr_t));
pthread_attr_init(attr_t);
pthread_mutex_init(&__mainMutex, NULL);
/* Threads of tasks */
pthread_t thread__MicroWaveOven;
pthread_t thread__Bell;
pthread_t thread__ControlPanel;
pthread_t thread__Controller;
pthread_t thread__Magnetron;
pthread_t thread__Door;
/* ici on initialise tous les canaux de l'application */
////////////Door
// static struct srl_mwmr_status_s okDoor_status = MWMR_STATUS_INITIALIZER( 32, 2);
// static struct srl_mwmr_status_s open_status = MWMR_STATUS_INITIALIZER( 32, 2);
// static struct srl_mwmr_status_s closed_status = MWMR_STATUS_INITIALIZER( 32, 2);
//RG: ajouter le & a fin de respecter le prototype de la fonction
// struct srl_mwmr_s Door_okDoor__fifo_data_out = MWMR_INITIALIZER( 32,2,Door_okDoor__Controller_okDoor, &okDoor_status, "Door_okDoor__fifo_data_out", MWMR_LOCK_INITIALIZER);
// struct srl_mwmr_s Door_open__fifo_data_in = MWMR_INITIALIZER(32,2,Door_open__Controller_open, &open_status, "Door_open__fifo_data_out", MWMR_LOCK_INITIALIZER);
// struct srl_mwmr_s Door_closed__fifo_data_in = MWMR_INITIALIZER(32,2,Door_closed__Controller_closed, &closed_status, "Door_closed__fifo_data_out", MWMR_LOCK_INITIALIZER);
struct srl_mwmr_s *Door_okDoor__fifo_data_out = malloc(sizeof( srl_mwmr_t));
//asyncchannel_init( Door_okDoor__fifo_data_out);
struct srl_mwmr_s *Door_open__fifo_data_in=malloc(sizeof( srl_mwmr_t));
//asyncchannel_init( Door_open__fifo_data_in);
struct srl_mwmr_s *Door_closed__fifo_data_in=malloc(sizeof( srl_mwmr_t));
//asyncchannel_init( Door_closed__fifo_data_in);
//////////Bell
// static struct srl_mwmr_status_s ringBell_status = MWMR_STATUS_INITIALIZER( 32, 2);
// struct srl_mwmr_s ringBell__fifo_data_in = MWMR_INITIALIZER( 32,2,Controller_ringBell__Bell_ring, &ringBell_status, "ringBell__fifo_data_in", MWMR_LOCK_INITIALIZER);
struct srl_mwmr_s *ringBell__fifo_data_in =malloc(sizeof( srl_mwmr_t));
//asyncchannel_init( ringBell__fifo_data_in);
//////////Magnetron
// static struct srl_mwmr_status_s startMagnetron_status = MWMR_STATUS_INITIALIZER( 32, 2);
// static struct srl_mwmr_status_s stopMagnetron_status = MWMR_STATUS_INITIALIZER( 32, 2);
// struct srl_mwmr_s startMagnetron__fifo_data_in = MWMR_INITIALIZER( 32,2,Controller_startMagnetron__Magnetron_startM, &startMagnetron_status, "startMagnetron__fifo_data_in", MWMR_LOCK_INITIALIZER);
// struct srl_mwmr_s stopMagnetron__fifo_data_in = MWMR_INITIALIZER( 32,2,Controller_stopMagnetron__Magnetron_stopM, &stopMagnetron_status, "stopMagnetron__fifo_data_in", MWMR_LOCK_INITIALIZER);
struct srl_mwmr_s *startMagnetron__fifo_data_in =malloc(sizeof( srl_mwmr_t));
//asyncchannel_init( startMagnetron__fifo_data_in);
struct srl_mwmr_s *stopMagnetron__fifo_data_in =malloc(sizeof( srl_mwmr_t));
//asyncchannel_init( stopMagnetron__fifo_data_in);
/////////ControlPanel
// static struct srl_mwmr_status_s startButton_status = MWMR_STATUS_INITIALIZER( 32, 2);
// static struct srl_mwmr_status_s LEDon_status = MWMR_STATUS_INITIALIZER( 32, 2);
// static struct srl_mwmr_status_s LEDoff_status = MWMR_STATUS_INITIALIZER( 32, 2);
// struct srl_mwmr_s startButton__fifo_data_out = MWMR_INITIALIZER( 32,2,ControlPanel_startButton__Controller_start, &startButton_status, "startButton__fifo_data_out", MWMR_LOCK_INITIALIZER);
// struct srl_mwmr_s LEDon__Controller_startCooking__fifo_data_out = MWMR_INITIALIZER(32,2,ControlPanel_LEDon__Controller_startCooking, &LEDon_status, "LEDOn__Controller_startCooking__fifo_data_out", MWMR_LOCK_INITIALIZER);
// struct srl_mwmr_s LEDoff__Controller_stopCooking__fifo_data_out = MWMR_INITIALIZER(32,2,ControlPanel_LEDoff__Controller_stopCooking, &LEDoff_status, "LEDoff__Controller_stopCooking__fifo_data_out", MWMR_LOCK_INITIALIZER);
struct srl_mwmr_s *startButton__fifo_data_out=malloc(sizeof( srl_mwmr_t));
//asyncchannel_init( startButton__fifo_data_out);
struct srl_mwmr_s *LEDon__Controller_startCooking__fifo_data_out=malloc(sizeof( srl_mwmr_t));
//asyncchannel_init( LEDon__Controller_startCooking__fifo_data_out);
struct srl_mwmr_s *LEDoff__Controller_stopCooking__fifo_data_out=malloc(sizeof( srl_mwmr_t));
//asyncchannel_init( LEDoff__Controller_stopCooking__fifo_data_out);
//initRandom();
/* Initializing the main mutex */
if (pthread_mutex_init(&__mainMutex, NULL) < 0) { exit(-1);}
/* pour ce thread, qui ne lit ni ecrit les canaux, il est OK de transmettre uniquement son nom */
ptr =malloc(sizeof(pthread_t));
thread__MicroWaveOven = (pthread_t)ptr;
attr_t = malloc(sizeof(pthread_attr_t));
attr_t->cpucount = 0;
pthread_create(&thread__MicroWaveOven, attr_t, mainFunc__MicroWaveOven, (void *)"MicroWaveOven");
/* le thread Bell utilise un seul canal*/
ptr =malloc(sizeof(pthread_t));
thread__Bell = (pthread_t)ptr;
attr_t = malloc(sizeof(pthread_attr_t));
attr_t->cpucount = 1;
pthread_create(&thread__Bell, attr_t, mainFunc__Bell, (void *)Controller_ringBell__Bell_ring);
/* le thread ControlPanel utilise trois canaux*/
struct mwmr_s *canaux_panel[3];
canaux_panel[0]=ControlPanel_LEDon__Controller_startCooking;
canaux_panel[1]=ControlPanel_LEDoff__Controller_stopCooking;
canaux_panel[2]=ControlPanel_startButton__Controller_start;
ptr =malloc(sizeof(pthread_t));
thread__ControlPanel = (pthread_t)ptr;
attr_t = malloc(sizeof(pthread_attr_t));
attr_t->cpucount = 2;
pthread_create(&thread__ControlPanel, attr_t, (void *)mainFunc__ControlPanel, (void *)canaux_panel);
/* le thread Controller utilise 9 canaux*/
struct mwmr_s *canaux_controller[9];
canaux_controller[0]=Controller_ringBell__Bell_ring;
canaux_controller[1]=Door_okDoor__Controller_okDoor;
canaux_controller[2]=Door_open__Controller_open;
canaux_controller[3]=Door_closed__Controller_closed;
canaux_controller[4]=Controller_startMagnetron__Magnetron_startM;
canaux_controller[5]=Controller_stopMagnetron__Magnetron_stopM;
//canaux_controller[6]=ControlPanel_LEDOn__Controller_startCooking;
//canaux_controller[7]=ControlPanel_LEDoff__Controller_stopCooking;
canaux_controller[8]=ControlPanel_startButton__Controller_start;
ptr =malloc(sizeof(pthread_t));
thread__Controller = (pthread_t)ptr;
attr_t->cpucount = 3;
pthread_create(&thread__Controller, attr_t,(void *)mainFunc__Controller, (void *)canaux_controller);
/* le thread Magnetron utilise 2 canaux*/
struct mwmr_s *canaux_magnetron[2];
canaux_magnetron[0]=Controller_startMagnetron__Magnetron_startM ;
canaux_magnetron[1]=Controller_stopMagnetron__Magnetron_stopM;
ptr =malloc(sizeof(pthread_t));
thread__Magnetron = (pthread_t)ptr;
attr_t->cpucount = 4;
pthread_create(&thread__Magnetron, attr_t, (void *)mainFunc__Magnetron, (void *)canaux_magnetron);
/* le thread Door utilise 3 canaux*/
struct mwmr_s *canaux_door[3];
canaux_door[0]=Door_open__Controller_open;
canaux_door[1]=Door_closed__Controller_closed;
canaux_door[2]=Door_okDoor__Controller_okDoor;
ptr =malloc(sizeof(pthread_t));
thread__Door = (pthread_t)ptr;
attr_t = malloc(sizeof(pthread_attr_t));
attr_t->cpucount = 5;
pthread_create(&thread__Door, attr_t, (void *)mainFunc__Door, (void *)canaux_door);
pthread_join(thread__MicroWaveOven, NULL);
pthread_join(thread__Bell, NULL);
pthread_join(thread__ControlPanel, NULL);
pthread_join(thread__Controller, NULL);
pthread_join(thread__Magnetron, NULL);
pthread_join(thread__Door, NULL);
return 0;
}
#ifndef MAIN_H
#define MAIN_H
/* Main mutex */
extern pthread_mutex_t __mainMutex;
/* Synchronous channels */
/* Asynchronous channels */
extern asyncchannel __Controller_ringBell__Bell_ring;
extern asyncchannel __Door_okDoor__Controller_okDoor;
extern asyncchannel __Door_open__Controller_open;
extern asyncchannel __Door_closed__Controller_closed;
extern asyncchannel __Controller_startMagnetron__Magnetron_startM;
extern asyncchannel __Controller_stopMagnetron__Magnetron_stopM;
extern asyncchannel __ControlPanel_LEDOn__Controller_startCooking;
extern asyncchannel __ControlPanel_LEDoff__Controller_stopCooking;
extern asyncchannel __ControlPanel_startButton__Controller_start;
#endif
This diff is collapsed.
/*
*
* SOCLIB_LGPL_HEADER_BEGIN
*
* This file is part of SoCLib, GNU LGPLv2.1.
*
* SoCLib is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; version 2.1 of the License.
*
* SoCLib is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with SoCLib; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* SOCLIB_LGPL_HEADER_END
*
* Copyright (c) UPMC, Lip6, SoC
* Dimitri Refauvelet <dimitri.refauvelet@lip6.fr>, 2009
*
* Maintainers: dimitri.refauvelet@etu.upmc.fr
*/
#define TEXT_BASE 0x00400000
#define TEXT_SIZE 0x00050000
#define RESET_BASE 0xBFC00000
#define RESET_SIZE 0x00010000
#define EXCEP_BASE 0x80000000
#define EXCEP_SIZE 0x00010000
#define DATA_BASE 0x10000000
#define DATA_SIZE 0x00020000
#define TTY_BASE 0xC0200000
#define TTY_SIZE 0x00000010
//#define SIMHELPER_BASE 0xd0200000
//#define SIMHELPER_SIZE 0x00000010
//#define MWMR_IE_BASE 0xA0200000
//#define MWMR_IE_SIZE 0x00001000
#define LOCKS_BASE 0x30200000
#define LOCKS_SIZE 0x00000100
#ifndef SRL_H_
#define SRL_H_
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "srl_public_types.h"
#include "srl_mwmr.h"
//#include <srl_log.h>
#endif
/*
* This file is part of DSX, development environment for static
* SoC applications.
*
* This file is distributed under the terms of the GNU General Public
* License.
*
* Copyright (c) 2006, Nicolas Pouillon, <nipo@ssji.net>
* Laboratoire d'informatique de Paris 6 / ASIM, France
*
* $Id$
*/
#ifndef SRL_MWMR_H_
#define SRL_MWMR_H_
#include "srl_public_types.h"
/* Bloquant */
void srl_mwmr_read( srl_mwmr_t, void *, size_t );
void srl_mwmr_write( srl_mwmr_t, void *, size_t );
/* Non bloquant */
ssize_t srl_mwmr_try_read( srl_mwmr_t, void *, size_t );
ssize_t srl_mwmr_try_write( srl_mwmr_t, void *, size_t );
#endif
#ifndef SRL_PRIVATE_TYPES_H
#define SRL_PRIVATE_TYPES_H
#include "pthread.h"
#include <stdint.h>
#include "srl_public_types.h"
#define SRL_CONST_INITIALIZER(x) x
typedef pthread_mutex_t srl_lock_s;
#define SRL_LOCK_INITIALIZER() PTHREAD_MUTEX_INITIALIZER
typedef struct srl_mwmr_status_s srl_mwmr_status_s;
typedef struct srl_mwmr_lock_s srl_mwmr_lock_t;
struct srl_mwmr_lock_s {
pthread_mutex_t lock;
pthread_cond_t nempty;
pthread_cond_t nfull;
};
#define SRL_MWMR_LOCK_INITIALIZER { \
.lock = PTHREAD_MUTEX_INITIALIZER, \
.nempty = PTHREAD_COND_INITIALIZER, \
.nfull = PTHREAD_COND_INITIALIZER, \
}
typedef struct srl_abstract_mwmr_s {
srl_mwmr_lock_t lock;
size_t width;
size_t depth;
size_t gdepth;
srl_buffer_t buffer;
const char *name;
struct srl_mwmr_status_s *status;
} srl_mwmr_s;
struct srl_mwmr_status_s {
size_t rptr;
size_t wptr;
size_t usage;
};
#define SRL_MWMR_STATUS_INITIALIZER(w,d) { \
.rptr = 0, \
.wptr = 0, \
.usage = 0, \
}
#define SRL_MWMR_INITIALIZER(w, d, b, s, n, l) \
{ \
.width = w, \
.depth = d, \
.gdepth = (w)*(d), \
.buffer = (void*)b, \
.name = n, \
.status = s, \
.lock = l, \
}
typedef struct srl_abstract_barrier_s {
size_t count;
size_t current;
pthread_mutex_t lock;
pthread_cond_t ok;
} srl_barrier_s;
#define SRL_BARRIER_INITIALIZER(c) \
{ \
.count = c, \
.current = 0, \
.lock = PTHREAD_MUTEX_INITIALIZER, \
.ok = PTHREAD_COND_INITIALIZER, \
}
#define SRL_MEMSPACE_INITIALIZER( b, s ) \
{\
.buffer = b,\
.size = s,\
}
typedef void srl_task_func_t( void* );
typedef struct srl_abstract_task_s {
srl_task_func_t *bootstrap;
srl_task_func_t *func;
void *args;
void *stack;
size_t stack_size;
const char *name;
pthread_t thread;
} srl_task_s;
#define SRL_TASK_INITIALIZER(b, f, a, n, ttya, ttyn) \
{ \
.bootstrap = (srl_task_func_t *)b, \
.func = (srl_task_func_t *)f, \
.args = (void*)a, \
.name = n, \
}
#define SRL_CPUSTATE_INITIALIZER() \
{ \
.boo = 0, \
}
typedef struct srl_abstract_cpudesc_s srl_cpudesc_s;
struct srl_abstract_cpudesc_s {
size_t ntasks;
const srl_task_s *const*task_list;
};
#define SRL_CPUDESC_INITIALIZER(nt, tl, ttya, ttyn) \
{ \
.ntasks = nt, \
.task_list = tl, \
}
typedef struct srl_abstract_appdesc_s srl_appdesc_s;
struct srl_abstract_appdesc_s {
const size_t ntasks;
srl_barrier_s *start;
const srl_mwmr_s * const *mwmr;
const srl_cpudesc_s * const *cpu;
const srl_task_s * const *task;
};
#define SRL_APPDESC_INITIALIZER(nt, cl, ml, tl, sb, ttya, ttyn) \
{ \
.ntasks = nt, \
.cpu = cl, \
.mwmr = ml, \
.task = tl, \
.start = sb, \
}
#endif
#ifndef SRL_PUBLIC_TYPES_H
#define SRL_PUBLIC_TYPES_H
#include <stdint.h>
#if defined SRL_POSIX
#include <sys/types.h>
# define SRL_MWMR_USE_SEPARATE_LOCKS
#elif defined SRL_OVER_HEXO
#include <hexo/types.h>
#endif
typedef uint32_t srl_const_t;
struct srl_abstract_lock_s;
typedef struct srl_abstract_lock_s *srl_lock_t;
typedef void *srl_buffer_t;
typedef struct srl_memspace_s {
srl_buffer_t buffer;
uint32_t size;
} srl_memspace_s;
typedef srl_memspace_s *srl_memspace_t;
struct srl_abstract_mwmr_s;
typedef struct srl_abstract_mwmr_s *srl_mwmr_t;
struct srl_abstract_barrier_s;
typedef struct srl_abstract_barrier_s *srl_barrier_t;
#endif
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment