This repository has been archived by the owner on Nov 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aggiunti header relativi ai device di phase0
Spostata gestione semafori di umps in sorgenti condivisi [uMPS] Fix errori compilazione #15 Aggiornato SConstruct
- Loading branch information
Showing
7 changed files
with
152 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#ifndef __SHARED_DEVICE_H__ | ||
#define __SHARED_DEVICE_H__ | ||
|
||
#define DEV_FULL_MASK 0xFFFFFFFF | ||
|
||
// stati generici di un dispositivo | ||
#define DEV_STATUS_NOT_INSTALLED 0 | ||
#define DEV_STATUS_READY 1 | ||
#define DEV_STATUS_UNKNOWN_CMD 2 | ||
#define DEV_STATUS_BUSY 3 | ||
#define DEV_STATUS_CODE_4 4 | ||
#define DEV_STATUS_CODE_5 5 | ||
#define DEV_STATUS_CODE_6 6 | ||
#define DEV_STATUS_CODE_7 7 | ||
#define DEV_STATUS_CODE_128 128 | ||
// comandi generici di un dispositivo | ||
#define DEV_CMD_RESET 0 | ||
#define DEV_CMD_ACK 1 | ||
|
||
#define IS_DEV_IN_ERROR(status) (\ | ||
(status&0xFF)==DEV_STATUS_NOT_INSTALLED || (status&0xFF)==DEV_STATUS_UNKNOWN_CMD || \ | ||
(status&0xFF)==DEV_STATUS_CODE_4 || (status&0xFF)==DEV_STATUS_CODE_5 || \ | ||
(status&0xFF)==DEV_STATUS_CODE_6 || (status&0xFF)==DEV_STATUS_CODE_7 || \ | ||
(status&0xFF)==DEV_STATUS_CODE_128) | ||
|
||
// | ||
#define IS_IRQ_RAISED_FROM_I(line,i) ((i>=0 && i<8 && CDEV_BITMAP_ADDR(line)&(1U<<i)) != 0) | ||
|
||
/* We are 8 type of interrupt lines. But, only 5 | ||
* lines are related to devices. | ||
*/ | ||
#define SEM_DEV_N ((N_EXT_IL+1)*N_DEV_PER_IL) | ||
|
||
// | ||
#define GET_SEM_OFFSET(dev_reg,line) (line!=IL_TERMINAL ? (0) : (IS_TERM_READY(dev_reg->term.transm_status)? (0) : (1))) | ||
// | ||
#define GET_SEM_INDEX(dev_reg,line,device) (N_DEV_PER_IL*(line-N_EXT_IL+GET_SEM_OFFSET(dev_reg,line))+device) | ||
#define GET_SEM_INDEX_SUBDEV(line,device,subdevice) (N_DEV_PER_IL*(line-N_EXT_IL+ ( line!=IL_TERMINAL ? 0 : subdevice ) )+device) | ||
// | ||
#define GET_DEV_STATUS(dev_reg, line) (line!=IL_TERMINAL ?(dev_reg->dtp.status):(GET_SEM_OFFSET(dev_reg,line) ?(dev_reg->term.recv_status):(dev_reg->term.transm_status)) ) | ||
|
||
|
||
void device_init(); | ||
|
||
/** | ||
* @brief Memorizza il tipo (linea) di interrupt e numero di device relativo al registro del device fornito | ||
* | ||
* @param devreg indirizzo del registro del device | ||
* @param line tipo (linea) di interrupt | ||
* @param devNo numero del device | ||
*/ | ||
void device_GetInfo( devreg_t *devreg, int *devline, int *devNo ); | ||
|
||
/** | ||
* @brief Restituisce il puntatore al semaforo dedicato al (sotto-)dispositivo del tipo specificato | ||
* | ||
* @param devline | ||
* @param devNo | ||
* @param subDev | ||
* @return int* | ||
*/ | ||
int *device_GetSem( int devline, int devNo, int subDev ); | ||
|
||
#endif | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef __DEVICE_TERMINAL_H__ | ||
#define __DEVICE_TERMINAL_H__ | ||
|
||
#include "device.h" | ||
|
||
#define TERMINAL_STATUS_TRANSMISSION_ERROR DEV_STATUS_CODE_4 | ||
#define TERMINAL_STATUS_RECEIVED_ERROR TERMINAL_STATUS_RECEIVED_ERROR | ||
|
||
#define TERMINAL_STATUS_TRANSMITTED DEV_STATUS_CODE_5 | ||
#define TERMINAL_STATUS_RECEIVED TERMINAL_STATUS_TRANSMITTED | ||
|
||
#define TERMINAL_CMD_TRANSMIT 2 | ||
#define TERMINAL_CMD_RECEIVE TERMINAL_CMD_TRANSMIT | ||
|
||
#define CHAR_OFFSET 8 | ||
#define TERMINAL_STATUS_MASK 0xFF | ||
#define TERMINAL_DATA_MASK 0xFF00 | ||
|
||
|
||
#define IS_TERM_READY(status) ((status&TERMINAL_STATUS_MASK)==DEV_STATUS_READY) | ||
#define IS_TERM_IN_ERROR(status) (\ | ||
(status&TERMINAL_STATUS_MASK)==DEV_STATUS_NOT_INSTALLED || \ | ||
(status&TERMINAL_STATUS_MASK)==DEV_STATUS_UNKNOWN_CMD || \ | ||
(status&TERMINAL_STATUS_MASK)==TERMINAL_STATUS_TRANSMISSION_ERROR) | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <system/system.h> | ||
#include <system/shared/device/device.h> | ||
|
||
HIDDEN int _semdev[SEM_DEV_N]; | ||
|
||
void device_init() { | ||
|
||
} | ||
|
||
void device_GetInfo( devreg_t *devreg, int *_line, int *_devNo ) { | ||
if( _line == NULL ) return; | ||
|
||
int line, devNo; | ||
for( line = DEV_IL_START; line < DEV_PER_INT ; line++ ) { | ||
if( !( (devreg_t*)DEV_REG_ADDR(line, 0) <= devreg && devreg <= (devreg_t*)DEV_REG_ADDR(line, N_EXT_IL-1 ) ) ) { | ||
continue; | ||
} | ||
*_line = line; | ||
if( _devNo == NULL ) return; | ||
|
||
for( devNo = 0; devNo < N_EXT_IL; devNo ++ ){ | ||
if( devreg == (devreg_t*)DEV_REG_ADDR(line, devNo) ) { | ||
*_devNo = devNo; | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
|
||
int *device_GetSem( int devline, int devNo, int subDev ) { | ||
return &_semdev[ GET_SEM_INDEX_SUBDEV(devline, devNo, subDev) ]; | ||
} |