Exemple #1
0
static inline void _lltimer_set(uint32_t target)
{
    if (_in_handler) {
        return;
    }
    DEBUG("__lltimer_set(): setting %" PRIu32 "\n", _mask(target));
#ifdef XTIMER_SHIFT
    target >>= XTIMER_SHIFT;
    if (!target) {
        target++;
    }
#endif
    timer_set_absolute(XTIMER, XTIMER_CHAN, _mask(target));
}
Exemple #2
0
int main(int argc, char const *argv[])
{
	unsigned int i;
	unsigned int inumber;

	if (argc < 2) {
		printf("Usage : if_delete [inumber] -> supprimer l'inode de numero [inumber] et renvoi OK ou KO\n");
		return EXIT_FAILURE;
	}

  /* init hardware */
  if(init_hardware("hardware.ini") == 0) {
    fprintf(stderr, "Error in hardware initialization\n");
    exit(EXIT_FAILURE);
  }

  /* Interreupt handlers */
  for(i=0; i<16; i++) {
    IRQVECTOR[i] = empty_it;
  }

  /* Allows all IT */
  _mask(1);

  printf("Loading Master Boot Record...\n");
  load_mbr();

  	load_super(0);

  	inumber = atoi(argv[1]);

  	delete_ifile(inumber, 0);

  	return EXIT_SUCCESS;
}
Exemple #3
0
int
main (int argc, char **argv)
{
  unsigned int i;

  /* init hardware */
  if (init_hardware (HARDWARE_INI) == 0)
    {
      fprintf (stderr, "Error in hardware initialization\n");
      exit (EXIT_FAILURE);
    }

  /* dummy interrupt handlers */
  for (i = 0; i < 16; i++)
    IRQVECTOR[i] = empty_it;

  /* program timer */
  IRQVECTOR[TIMER_IRQ] = timer_it;
  _out (TIMER_PARAM, 128 + 64 + 32 + 8);	/* reset + alarm on + 8 tick / alarm */
  _out (TIMER_ALARM, 0xFFFFFFFE);	/* alarm at next tick (at 0xFFFFFFFF) */

  /* allows all IT */
  _mask (1);

  /* count for a while... */
  for (i = 0; i < (1 << 28); i++)
    ;

  /* and exit! */
  exit (EXIT_SUCCESS);
}
Exemple #4
0
int xtimer_remove(xtimer_t *timer)
{
    if (!_is_set(timer)) {
        return 0;
    }

    unsigned state = disableIRQ();
    int res = 0;
    if (timer_list_head == timer) {
        uint32_t next;
        timer_list_head = timer->next;
        if (timer_list_head) {
            /* schedule callback on next timer target time */
            next = timer_list_head->target - XTIMER_OVERHEAD;
        }
        else {
            next = _mask(0xFFFFFFFF);
        }
        _lltimer_set(next);
    }
    else {
        res = _remove_timer_from_list(&timer_list_head, timer) ||
            _remove_timer_from_list(&overflow_list_head, timer) ||
            _remove_timer_from_list(&long_list_head, timer);
    }

    timer->target = 0;
    timer->long_target = 0;

    restoreIRQ(state);

    return res;
}
Exemple #5
0
int main(int argc, char**argv){

  unsigned int i;
  unsigned int inumber = 0;
  file_desc_t fd;

  /* gestion des arguments */
  if(argc!=3){
    usage();
    exit(EXIT_SUCCESS);
  }

  inumber = atoi(argv[1]);
  if(inumber==0){
    usage();
    exit(EXIT_FAILURE);
  }  

  /* init hardware */
  if(!init_hardware(HW_CONFIG)) {
    fprintf(stderr, "Initialization error\n");
    exit(EXIT_FAILURE);
  }

  /* Interreupt handlers */
  for(i=0; i<NB_EMPTY_FUNCTION; i++)
    IRQVECTOR[i] = empty_it;

  /* Allows all IT */
  _mask(1);

  /* chargement du mbr */
  if(!load_mbr()){
    fprintf(stderr, "Erreur lors du chargement du Master Boot Record.\n");
    exit(EXIT_FAILURE);
  }

  /* initialise le super du premier volume */
  init_super(CURRENT_VOLUME);

  /* charge le super du premier volume dans la variable globale */
  load_super(CURRENT_VOLUME);


  /* manipulation du fichier */
  if(open_ifile(&fd, inumber) == RETURN_FAILURE){
    fprintf(stderr, "Erreur lors de l'ouverture du fichier\n");
    exit(EXIT_FAILURE);
  }

  if(write_ifile(&fd, argv[2], strlen(argv[2])+1) == RETURN_FAILURE){
    fprintf(stderr, "Erreur lors de l'ecriture dans le fichier\n");
    exit(EXIT_FAILURE);
  }

  flush_ifile(&fd);
  close_ifile(&fd);

  exit(EXIT_SUCCESS);
}
Exemple #6
0
int 
main() 
{

    unsigned int i;

    if(init_hardware("etc/hardware.ini") == 0) {
	fprintf(stderr, "Error in hardware initialization\n");
        exit(EXIT_FAILURE);
    }
    
    printf("ATTENTION !\nSi l'on donne une taille de matrice très grande, le processus peut prendre un certain temps\n\n");
    printf("MATRIX_SIZE : %d\n\n", MATRIX_SIZE);
    for(i=0;i<16;i++){
	IRQVECTOR[i] = ignore;
    }

    _out(MMU_PROCESS,1);


    IRQVECTOR[MMU_IRQ] = mmuhandler;
    IRQVECTOR[SYSCALL_SWTCH_0] = switch_to_process0;
    IRQVECTOR[SYSCALL_SWTCH_1] = switch_to_process1;
    _mask(0x1001);

    if(init_swap("./swap_file")==-1){
	printf("erreur\n");
    }
    init();
    return 0;
}
Exemple #7
0
int main(int argc, char **argv)
{
    unsigned int i;
    unsigned char buffer[HDA_SECTORSIZE];
    unsigned int cylinder;
    unsigned int sector;

    if(argc < 3) {
	    fprintf(stderr, "Error arguments missing\n");
	    exit(EXIT_FAILURE);
    }

    cylinder = atoi(argv[1]);
    sector = atoi(argv[2]);

    if(cylinder < 0 || cylinder >= HDA_MAXCYLINDER) {
	    fprintf(stderr, "Error cylinder\n");
	    exit(EXIT_FAILURE);
    }

    if(sector < 0 || sector >= HDA_MAXSECTOR) {
	    fprintf(stderr, "Error sector\n");
	    exit(EXIT_FAILURE);
    }
    
    /* init hardware */
    if(init_hardware("hardware.ini") == 0) {
	    fprintf(stderr, "Error in hardware initialization\n");
	    exit(EXIT_FAILURE);
    }

    /* Interreupt handlers */
    for(i=0; i<16; i++)
	    IRQVECTOR[i] = empty_it;

    /* Allows all IT */
    _mask(1);

    read_sector(cylinder, sector, buffer);
    
    printf("--------------------------------------------------------------------------------\n");
    printf("Cylindre %i | Secteur %i\n", cylinder, sector);
    printf("--------------------------------------------------------------------------------");
    for(i = 0; i < HDA_SECTORSIZE; i++)
    {
        if(i%8 == 0) {
            printf("\n");
        }
        printf("\t0x%x ",buffer[i]);
    }
    printf("\n");
    printf("--------------------------------------------------------------------------------\n");

    /* and exit! */
    exit(EXIT_SUCCESS);
}
Exemple #8
0
int main() {

  unsigned int cpt = 0, i;

  /* init hardware */
  if(!init_hardware(HW_CONFIG)){
    perror("Initialization error\n");
    exit(EXIT_FAILURE);
  }

  /* Interreupt handlers */
  for(i=0; i<16; i++)
    IRQVECTOR[i] = empty_it;

  /* Allows all IT */
  _mask(1);

  /* chargement du mbr */
  if(!load_mbr()){
    perror("Erreur lors du chargement du Master Boot Record.");
    exit(EXIT_FAILURE);
  }

  /* creation d'un volume bidon */
  if(!make_vol(1, 1, 10)) {
    perror("Erreur a la creation d'un volume bidon.");
    exit(EXIT_FAILURE);
  }

  /* initialise le super du premier volume */
  init_super(CURRENT_VOLUME);

  /* charge le super du premier volume dans la variable globale */
  load_super(CURRENT_VOLUME);

  /* creation de nouveau bloc jusqu'a ce qu'il y est une erreur */
  while(new_bloc());

  if(is_full()) {
    free_bloc(2);
    free_bloc(5);
    free_bloc(6);

    printf("nombre de bloc libre = %d\n", get_nb_free_bloc());

    while(new_bloc()) cpt++;

    printf("le nombre de bloc alloué est %d\n", cpt);
				
  } else {
    printf("le disque n'est pas encore rempli\n");
  }

  exit(EXIT_SUCCESS);
}
Exemple #9
0
int main(int argc, char const *argv[])
{
	unsigned int i;
	unsigned int inumber;
	char line[LINE_SIZE];
	struct file_desc_t fd;

	if (argc < 2) {
		printf("Usage : if_copy [inumber] -> ecrit le contenu de l'entrée standard dans l'inode de numero [inumber]\n");
		return EXIT_FAILURE;
	}

  /* init hardware */
  if(init_hardware("hardware.ini") == 0) {
    fprintf(stderr, "Error in hardware initialization\n");
    exit(EXIT_FAILURE);
  }

  /* Interreupt handlers */
  for(i=0; i<16; i++) {
    IRQVECTOR[i] = empty_it;
  }

  /* Allows all IT */
  _mask(1);

  printf("Loading Master Boot Record...\n");
  load_mbr();

  	load_super(0);

  	inumber = atoi(argv[1]);

  	open_ifile(&fd, inumber, 0);

	
	while (fgets(line, LINE_SIZE, stdin) != NULL) {
	  
	  write_ifile(&fd, line, strlen(line), 0);
   
	}



  	close_ifile(&fd, 0);

  	return EXIT_SUCCESS;
}
Exemple #10
0
int main(int argc, char**argv){

    unsigned int i;
    unsigned int inumber;

    /* gestion des arguments */
    if(argc != 1){
        usage();
        exit(EXIT_SUCCESS);
    }

    /* init hardware */
    if(!init_hardware(HW_CONFIG)) {
        fprintf(stderr, "Initialization error\n");
        exit(EXIT_FAILURE);
    }

    /* Interreupt handlers */
    for(i=0; i<NB_EMPTY_FUNCTION; i++)
        IRQVECTOR[i] = empty_it;

    /* Allows all IT */
    _mask(1);

    /* chargement du mbr */
    if(!load_mbr()){
        fprintf(stderr, "Erreur lors du chargement du Master Boot Record.\n");
        exit(EXIT_FAILURE);
    }

    /* initialise le super du premier volume */
    init_super(CURRENT_VOLUME);

    /* charge le super du premier volume dans la variable globale */
    load_super(CURRENT_VOLUME);

    /* création du fichier */
    inumber = create_ifile(IT_FILE);
    if(!inumber){
        fprintf(stderr, "Erreur lors de la creation du fichier\n");
        exit(EXIT_FAILURE);
    }
  
    printf("Création d'un fichier:\n");
    printf("\tinumber: %d.\n", inumber);

    exit(inumber);
}
Exemple #11
0
int main(int argc, char**argv){

  unsigned int i;
  unsigned fc = 0;
  unsigned fs = 1;
  unsigned nb_bloc = 10;

  /* init hardware */
  if(!init_hardware(HW_CONFIG)) {
    fprintf(stderr, "Initialization error\n");
    exit(EXIT_FAILURE);
  }

  /* Interreupt handlers */
  for(i=0; i<NB_EMPTY_FUNCTION; i++)
    IRQVECTOR[i] = empty_it;

  /* Allows all IT */
  _mask(1);

  /* chargement du mbr */
  if(!load_mbr()){
    fprintf(stderr, "Erreur lors du chargement du Master Boot Record.\n");
    exit(EXIT_FAILURE);
  }

  if(mbr.mbr_n_vol < 1) {

    /* creation d'un volume bidon */
    if(!make_vol(fc, fs, nb_bloc)) {
      fprintf(stderr, "Erreur a la creation d'un volume bidon.\n");
      exit(EXIT_FAILURE);
    }

    /* initialise le super du volume 1 */
    init_super(CURRENT_VOLUME);

    printf("Le volume principale a été créé avec succès.\n");

    /* sauvegarde de tous les changements effectué sur le mbr */
    save_mbr();
  } else {
    printf("Le volume principale a déjà été créé!\n");
  }

  exit(EXIT_SUCCESS);
}
Exemple #12
0
int _xtimer_set_absolute(xtimer_t *timer, uint32_t target)
{
    uint32_t now = xtimer_now();
    int res = 0;

    DEBUG("timer_set_absolute(): now=%" PRIu32 " target=%" PRIu32 "\n", now, target);

    timer->next = NULL;
    if ((target >= now) && ((target - XTIMER_BACKOFF) < now)) {
        /* backoff */
        xtimer_spin_until(target+XTIMER_BACKOFF);
        _shoot(timer);
        return 0;
    }

    timer->target = target;
    timer->long_target = _long_cnt;
    if (target < now) {
        timer->long_target++;
    }

    unsigned state = disableIRQ();
    if ( !_this_high_period(target) ) {
        DEBUG("xtimer_set_absolute(): the timer doesn't fit into the low-level timer's mask.\n");
        _add_timer_to_long_list(&long_list_head, timer);
    }
    else {
        if (_mask(now) >= target) {
            DEBUG("xtimer_set_absolute(): the timer will expire in the next timer period\n");
            _add_timer_to_list(&overflow_list_head, timer);
        }
        else {
            DEBUG("timer_set_absolute(): timer will expire in this timer period.\n");
            _add_timer_to_list(&timer_list_head, timer);

            if (timer_list_head == timer) {
                DEBUG("timer_set_absolute(): timer is new list head. updating lltimer.\n");
                _lltimer_set(target - XTIMER_OVERHEAD);
            }
        }
    }

    restoreIRQ(state);

    return res;
}
Exemple #13
0
void randorig::dump( const char *str, bool debug) const 
{
    union {
        double  d;
        int64_t l;
        w_ieee_double ieee;
    } u;
    u.l = _state;

    cout << str 
         << " hex: " << ::hex << u.l << ::dec;

    if(debug)
    {
        cout 
             << " double: " << setprecision(21) << u.d 
         << " sign: " << ::hex << u.ieee.sign << ::dec
         << " exp: " << ::hex << u.ieee.exponent << ::dec
         << " mant1: " << ::hex << u.ieee.mant1 << ::dec
         << " mant2: " << ::hex << u.ieee.mant2 << ::dec;
    }
    cout << endl;


    int64_t tmp = _state;
    const uint64_t mplier = 0x5deece66dull;
    tmp *= mplier;
    cout << " _update preview: "
         << " state * 0x5deece66dull: " << ::hex << tmp << ::dec
         ;

    tmp += 0xb;
    cout 
         << " state + 0xb: " << ::hex << tmp << ::dec
         ;
        tmp = _mask(tmp);
    cout 
         << " _mask(state): " << ::hex << tmp << ::dec
         ;
    cout 
        << endl;
}
Exemple #14
0
int
main(int argc, char **argv)
{
    unsigned int i;

    /* init hardware */
    if(init_hardware("hardware.ini") == 0) {
	fprintf(stderr, "Error in hardware initialization\n");
	exit(EXIT_FAILURE);
    }

    /* Interreupt handlers */
    for(i=0; i<16; i++)
	IRQVECTOR[i] = empty_it;

    /* Allows all IT */
    _mask(1);

    /* and exit! */
    exit(EXIT_SUCCESS);
}
int main(int argc, char* argv[]) {

	void *ptr;
	int res;
	printf("Init hardware...\n");
	/* Initialise le matériel */
	if(init_hardware(HARDWARE_INI) == 0) {
		fprintf(stderr, "Error in hardware initialization\n");
		exit(EXIT_FAILURE);
	}

	/* Initialise le vecteur d'interruptions */
	IRQVECTOR[MMU_IRQ] = mmu_handler;
	IRQVECTOR[SYSCALL_SWITCH_0] = switch_to_process0; 
	IRQVECTOR[SYSCALL_SWITCH_1] = switch_to_process1; 
	
	 //  Passe la main au code Utilisateur 
	_mask(0x1001);
	printf("User mode...\n");
	init();
}
Exemple #16
0
int main(int argc, char **argv)
{
    /* init hardware */
    if(init_hardware("hardware.ini") == 0)
    {
	    fprintf(stderr, "Error in hardware initialization\n");
	    exit(EXIT_FAILURE);
    }
    
    init_swap("swapfile");
    
    memset(vm_mapping, 0, sizeof(struct vm_mapping_s) * VM_PAGES);
    memset(pm_mapping, 0, sizeof(struct pm_mapping_s) * PM_PAGES);
    
    IRQVECTOR[MMU_IRQ] = mmuhandler;
    _mask(0x1001);

    user_process();
    
    return 0;
}
Exemple #17
0
int main (){
  unsigned int i;
  if(init_hardware("hardware.ini") == 0) {
    fprintf(stderr, "Error in hardware initialization\n");
    exit(EXIT_FAILURE);
  }
    
  /* Interrupt handlers */
  for(i=0; i<16; i++)
    IRQVECTOR[i] = empty_it;

  /* Allows all IT */
  _mask(1);
  chk_hda();
    
  mbrvol(4,2,1);
  mbrvol(6,5,4);
  dvol();

  return 1;
}
Exemple #18
0
/* ------------------------------
   Initialization and finalization fucntions
   ------------------------------------------------------------*/
void
mount()
{
    char *hw_config;
    int status, i; 

    /* Hardware initialization */
    hw_config = get_hw_config();
    status = init_hardware(hw_config);
    ffatal(status, "error in hardware initialization with %s\n", hw_config);

    /* Interrupt handlers */
    for(i=0; i<16; i++)
	IRQVECTOR[i] = emptyIT;
    
    /* Allows all IT */
    _mask(1);

    /* Load MBR and current volume */
    load_mbr();
    load_current_volume();
}
int main(){
	int nbSec,nbCyl,cylinder,secteur,i;
	if(init_hardware("hardware.ini") == 0) {
		fprintf(stderr, "Error in hardware initialization\n");
		exit(EXIT_FAILURE);
    	}

	/* Interreupt handlers */
	for(i=0; i<16; i++)
		IRQVECTOR[i] = empty_it;

	/* Allows all IT */
	_mask(1);
	_out(HDA_CMDREG,CMD_DSKINFO);
	nbCyl=_in(HDA_DATAREGS)<<8;
	nbCyl+=_in(HDA_DATAREGS+1);
	nbSec=_in(HDA_DATAREGS+2)<<8;
	nbSec+=_in(HDA_DATAREGS+3);
	printf("Formatage du disque\n");
	for(cylinder=0;cylinder<nbCyl;cylinder++)
		for(secteur=0;secteur<nbSec;secteur++)
			format_sector(cylinder,secteur,1,0);
	return 0;
} 
Exemple #20
0
/**
 * @brief main xtimer callback function
 */
static void _timer_callback(void)
{
    uint32_t next_target;
    uint32_t reference;

    _in_handler = 1;

    DEBUG("_timer_callback() now=%" PRIu32 " (%" PRIu32 ")pleft=%" PRIu32 "\n", xtimer_now(),
            _mask(xtimer_now()), _mask(0xffffffff-xtimer_now()));

    if (!timer_list_head) {
        DEBUG("_timer_callback(): tick\n");
        /* there's no timer for this timer period,
         * so this was a timer overflow callback.
         *
         * In this case, we advance to the next timer period.
         */
        _next_period();

        reference = 0;

        /* make sure the timer counter also arrived
         * in the next timer period */
        while (_xtimer_now() == _mask(0xFFFFFFFF));
    }
    else {
        /* we ended up in _timer_callback and there is
         * a timer waiting.
         */
        /* set our period reference to that timer's target time. */
        reference = _mask(timer_list_head->target);
    }

overflow:
    /* check if next timers are close to expiring */
    while (timer_list_head && (_time_left(_mask(timer_list_head->target), reference) < XTIMER_ISR_BACKOFF)) {
        /* make sure we don't fire too early */
        while (_time_left(_mask(timer_list_head->target), reference));

        /* pick first timer in list */
        xtimer_t *timer = timer_list_head;

        /* advance list */
        timer_list_head = timer->next;

        /* make sure timer is recognized as being already fired */
        timer->target = 0;
        timer->long_target = 0;

        /* fire timer */
        _shoot(timer);
    }

    /* possibly executing all callbacks took enough
     * time to overflow.  In that case we advance to
     * next timer period and check again for expired
     * timers.*/
    if (reference > _xtimer_now()) {
        DEBUG("_timer_callback: overflowed while executing callbacks. %i\n", timer_list_head != 0);
        _next_period();
        reference = 0;
        goto overflow;
    }

    if (timer_list_head) {
        /* schedule callback on next timer target time */
        next_target = timer_list_head->target - XTIMER_OVERHEAD;
    }
    else {
        /* there's no timer planned for this timer period */
        /* schedule callback on next overflow */
        next_target = _mask(0xFFFFFFFF);
        uint32_t now = _xtimer_now();

        /* check for overflow again */
        if (now < reference) {
            _next_period();
            reference = 0;
            goto overflow;
        }
        else {
            /* check if the end of this period is very soon */
            if (_mask(now + XTIMER_ISR_BACKOFF) < now) {
                /* spin until next period, then advance */
                while (_xtimer_now() > now);
                _next_period();
                reference = 0;
                goto overflow;
            }
        }
    }

    _in_handler = 0;

    /* set low level timer */
    _lltimer_set(next_target);
}
Exemple #21
0
void GatherFolderImg::computeMask( bool save_counter ) {
	_mask = arma::zeros< arma::Mat< arma::u8 > >( _scene->n_rows, _scene->n_cols ) ;
	
	if ( _minFrequencyMask > 100 ) {
		_mask = 1 - _mask ;
		return ;
	}
	
	arma::Mat< arma::u16 > counter = arma::zeros< arma::Mat< arma::u16 > > ( _scene->n_rows, _scene->n_cols ) ;

	int x, y, slice, u ;
	boost::filesystem::path filePath;
	Pgm3dFactory<arma::u8> factory ;

	if ( _scene->max() == 0 ) {
		std::cerr<<"loop on slices"<<std::endl;
		for ( slice = 0 ; slice < _scene->n_slices ; slice++ ) {
			filePath = _folderpath ;
			filePath /= QString( ANTHILL_SLICE_NAME ).arg( slice, 0, 10 ).toStdString() ;
			BillonTpl<arma::u8> *image = factory.read( QString( filePath.string().c_str() ) );
			*image *= -1 ;

			for ( y = 0 ; y < counter.n_rows ; y++ )
				for ( x = 0 ; x < counter.n_cols ; x++ )
					counter( y, x ) += (*image)( y,x,0 ) ;
			delete image ;
		}
	} else {
		for ( slice = 0 ; slice < _scene->n_slices ; slice++ ) {
			arma::Mat< arma::u8 > image = _scene->slice( slice ) ;
			arma::Mat< arma::u8 >::iterator readIter,
											readEnd = image.end() ;
			arma::Mat< arma::u16 >::iterator writeIter = counter.begin();
			for ( readIter = image.begin() ; readIter != readEnd ; readIter++,writeIter++ )
				*writeIter += *readIter ;
		}
	}
	
	if ( save_counter ) {
		arma::Cube<arma::u16> counter3D( counter.n_rows, counter.n_cols, 1 ) ;
		counter3D.slice(0) = counter ;
		counter3D.slice(0) *= 255 ;
		counter3D.slice(0) /= _scene->n_slices ;
		fs::path premaskfs = _folderpath ;
		premaskfs /= ANTHILL_PRE_MASK_NAME ;
		IOPgm3d<arma::u16,qint8,false>::write( counter3D, QString("%1").arg( premaskfs.string().c_str() ) );
	}
	arma::u16 th = (_scene->n_slices*_minFrequencyMask)/100 ;
	for ( y = 0 ; y < _mask.n_rows ; y++ )
		for ( x = 0 ; x < _mask.n_cols ; x++ )
			if ( counter( y, x ) >= th )
				_mask( y, x ) = 1 ;
	arma::Mat<arma::u8> *dilMask = dilate( _mask, 4, 4 ) ;
	_mask = *dilMask ;
	delete dilMask ;
	
	int minDist[] = { 0,0,0,0 } ;

	for ( y = 0 ; y < _mask.n_rows ; y++ ) 
		for ( x = 0 ; x < _mask.n_cols ; x++ )	{
			if ( _mask(y,x) == 0 ) continue ;
			minDist[0] = std::max( minDist[0], x ) ;
			minDist[1] = std::max( minDist[1], y ) ;
			
			minDist[2] = std::max( minDist[2], (int)_mask.n_cols-x ) ;
			minDist[3] = std::max( minDist[3], (int)_mask.n_rows-y ) ;
		}
	if ( std::min( minDist[0], minDist[2] ) < std::min( minDist[1], minDist[3] ) ) {
		// the stand is either at the left or the right side
		if ( minDist[0] < minDist[2] ) {
			// left side
			for ( y = 0 ; y < _mask.n_rows ; y++ )
				for ( x = _mask.n_cols-1 ; x >= 0 ; x-- ) {
					if ( _mask(y,x) == 0 ) continue ;
					for ( u = 0 ; u < x ; u++ )
						_mask(y,u) = 1 ;
					break ;
				}
		} else {
			// right side
			for ( y = 0 ; y < _mask.n_rows ; y++ )
				for ( x = 0 ; x < _mask.n_cols ; x++ ) {
					if ( _mask(y,x) == 0 ) continue ;
					for ( u = x ; u < _mask.n_cols ; u++ )
						_mask(y,u) = 1 ;
					break ;
				}
		}
	} else {
		// the stand is either at the top or the bottom side
		if ( minDist[1] < minDist[3] ) {
			// top side
			for ( x = 0 ; x < _mask.n_cols ; x++ )
				for ( y = _mask.n_rows-1 ; y >= 0 ; y-- ) {
					if ( _mask(y,x) == 0 ) continue ;
					for ( u = 0 ; u < y ; u++ )
						_mask(u,x) = 1 ;
					break ;
				}
		} else {
			// bottom side
			for ( x = 0 ; x < _mask.n_cols ; x++ )
				for ( y = 0 ; y < _mask.n_rows ; y++ ) {
					if ( _mask(y,x) == 0 ) continue ;
					for ( u = y ; u < _mask.n_rows ; u++ )
						_mask(u,x) = 1 ;
					break ;
				}
		}
		
	}
	_mask = 1 - _mask ;
}
Exemple #22
0
int main(int argc, char** argv){
  int v, first_cylinder, first_sector, n_block;
  unsigned int i;


  /* init hardware */
  if(init_hardware("hardware.ini") == 0) {
    fprintf(stderr, "Error in hardware initialization\n");
    exit(EXIT_FAILURE);
  }

  /* Interreupt handlers */
  for(i=0; i<16; i++) {
    IRQVECTOR[i] = empty_it;
  }

  /* Allows all IT */
  _mask(1);


  if ( argc < 5 ){
    printf("Usage : mkvol vol_name first_cylinder first_sector nb_block [-tother, -tannexe]\n");
    return EXIT_FAILURE;
  }

  first_cylinder = atoi(argv[2]);
  first_sector = atoi(argv[3]);
  n_block = atoi(argv[4]);

  if ( atoi(argv[2])==0 && atoi(argv[3])==0 ){
    printf("Cannot create volume at Master Boot Record position.\n");
    return EXIT_FAILURE;
  }


   printf("Loading Master Boot Record...\n");
  load_mbr();

  if ( mbr.n_vol >= MAX_VOL ){
    printf("Hard drive already has 8 volumes, please delete at least one volume before creating new one.\n");
    return EXIT_FAILURE;
  }

  first_cylinder = atoi(argv[2]);

  check_before_create(atoi(argv[2]), atoi(argv[3]), atoi(argv[4]));

  v = mbr.n_vol;
  mbr.vol[v].first_cylinder = first_cylinder;
  mbr.vol[v].first_sector = first_sector;
  mbr.vol[v].n_block = n_block;

  printf("Creating volume %d...\n", v);
  mbr.vol[v].type = BASE;
  if ( argc == 5 ){
    if ( strcmp(argv[4], "-tother") == 0){
      mbr.vol[v].type = OTHER;
    }
    if ( strcmp(argv[4], "-tannexe") == 0){
      mbr.vol[v].type = ANNEXE;
    }
  }


  srand((unsigned)time(NULL));
  init_super(v, argv[1], rand(), n_block);


  mbr.n_vol++;
  save_mbr();
  save_super(v);

  printf("Volume %d created.\n", v);
  return EXIT_SUCCESS;
}
bool posix::filesystem::mkdir(my::string path, my::string mask) {
  return(::mkdir(path, _mask(mask)));
}
Exemple #24
0
unsigned48_t rand48::_update() 
{
    _state = _mask(_state*0x5deece66dull + 0xb);
    return _state;
}