Beispiel #1
0
int main(){

#ifndef TESTING

#include "uart.h"
#include "mmc.h"

	// Initializam modulele hardware

	uart_init();
	SPI_init();
	MMC_init();
	BTN_init();
	LCD_init();
#endif
	/* Gaseste prima partitie FAT32 de pe card*/
	init_partition(buffer);

	/**
	  * Gaseste datele despre sistemul de fisiere :
	  * nr de tabele FAT, cluster-ul directorului Root, etc.
	  */
	initFAT32(buffer);
	print_volid(buffer);

	LCD_str( "  ", 0);
	LCD_str( "  ", 0);
	LCD_str( "  Welcome to", 0);
	LCD_str( " MMC Explorer", 0);
	_delay_ms(2500);
	LCD_clear();
	printdirs(openroot());
	return EXIT_SUCCESS;
}
Beispiel #2
0
int
init_basic_fs_on_lvm (guestfs_h *g)
{
  const char *pvs[] = { "/dev/sda1", NULL };

  if (init_partition (g) == -1)
    return -1;

  if (guestfs_pvcreate (g, "/dev/sda1") == -1)
    return -1;

  if (guestfs_vgcreate (g, "VG", (char **) pvs) == -1)
    return -1;

  if (guestfs_lvcreate (g, "LV", "VG", 8) == -1)
    return -1;

  if (guestfs_mkfs (g, "ext2", "/dev/VG/LV") == -1)
    return -1;

  if (guestfs_mount (g, "/dev/VG/LV", "/") == -1)
    return -1;

  return 0;
}
Beispiel #3
0
/**
 * fdisk_new_partition:
 *
 * Returns: new instance.
 */
struct fdisk_partition *fdisk_new_partition(void)
{
	struct fdisk_partition *pa = calloc(1, sizeof(*pa));

	pa->refcount = 1;
	init_partition(pa);
	DBG(PART, ul_debugobj(pa, "alloc"));
	return pa;
}
Beispiel #4
0
int
init_basic_fs (guestfs_h *g)
{
  if (init_partition (g) == -1)
    return -1;

  if (guestfs_mkfs (g, "ext2", "/dev/sda1") == -1)
    return -1;

  if (guestfs_mount (g, "/dev/sda1", "/") == -1)
    return -1;

  return 0;
}
Beispiel #5
0
/**
 * fdisk_reset_partition:
 * @pa: partition
 *
 * Resets partition content.
 */
void fdisk_reset_partition(struct fdisk_partition *pa)
{
	int ref;

	if (!pa)
		return;

	DBG(PART, ul_debugobj(pa, "reset"));
	ref = pa->refcount;

	fdisk_unref_parttype(pa->type);
	free(pa->name);
	free(pa->uuid);
	free(pa->attrs);

	memset(pa, 0, sizeof(*pa));
	pa->refcount = ref;

	init_partition(pa);
}
Beispiel #6
0
int main(void)
{

	uint32_t i;
	char c;
	char s1[64], s2[64];
	
	uint8_t bufb[512];
	
	init_serial();

	lcd_init();
	
	lcd_printf("Hello World! \n n: %d", 152);

	// init card
	send_str("\ninit mmc card: ");
	c = mmc_init();
	if (c) {
		send_str("failed (");
		send_int(c);
		send_str(")\n");
	} else {
		send_str("success\n");
		
		init_partition(0);
		
		c = 'h';
		
		while (1) {
		
			switch (c) {
				case 'l' :
					ls();
					break;
				
				case 'c' :
					send_str("dir: ");
					receive_str(s1);
					cd(s1);
					break;
					
				case 'r' :
					send_str("rename file: ");
					receive_str(s1);
					send_str("new name: ");
					receive_str(s2);
					rn(s1, s2);
					break;
					
				case 'd' :
					send_str("delete file: ");
					receive_str(s1);
					del(s1);
					break;
					
				case 'p' :
					send_str("file: ");
					receive_str(s1);
					cat(s1);
					break;

				case 't' :
					send_str("name: ");
					receive_str(s1);
					touch(s1);
					break;
					
				case 's' :
					send_str("sector: 0x");
					i = receive_hex();
					if (mmc_readsector(i, bufb)) {
						send_str("error reading sector\n");
					} else {
						dump_sector(bufb);
						send_char('\n');
					}
					break;
				
				case 'h' :
				default :
					send_str("h - help\nl - dir listing\nc - change dir\nd - delete file\np - print file contents\nt - create empty file\ns - dump sector\n");
					break;
			
			}
			
			// prompt
			send_str("> ");
			c = receive_char();
			send_char('\n');
		}
		
	}
	
	while (1) ;
	
	return 0;
}
Beispiel #7
0
int main (int argc, char* argv[])
{
	struct gps_location gl1 , gl2;
	struct gps_displacement gd;
	struct fatwrite_t fout;
	char logging_state = 0;
	char flag_reset = 0;

	gps_init_serial();
	lcd_init();
	camera_init();
	camera_sleep();
	lcd_printf("sd card:\nconnecting");
	char rt = mmc_init();
	if (rt) {
		lcd_printf("sd card: error\n");
		while (1) ;
	}
	
	init_partition(0);
	init_logtoggle();
	lcd_printf("GPS ...");

	gps_disable_unwanted();

	char in[64];
	int i, img_counter = 0;
	char c = 0;
	char loading_map[] = {'-', '\\', '|', '/'};
	const char * fpic;

	while (1) {

		// wait until valid location
		do {
			receive_str(in);
			gps_log_data(in , &gl1);
			lcd_printf("GPS Fixing %c\n", loading_map[(c++)&0x3]);
		} while (gl1.status != 'A');
	
		// got fix
		lcd_printf("Acquired Fix");

		// compute displacement
		while (1) {
			// read in gps data
			receive_str(in);
			if (flag_reset) {
				// reset waypoint
				gps_log_data(in, &gl1);
				flag_reset = 0;
			}
			i = gps_log_data(in , &gl2);
			
			// end log
			if (logging_state && !CHECK_LOGTOGGLE()) {
					logging_state = 0;
					lcd_printf("log: finishing..\n");
					log_end(&fout);
			}
		
			// check if we have a fix
			if (gl2.status != 'A') {
				lcd_printf("Lost GPS Fix %c\n", loading_map[(c++)&0x3]);
				continue;
			}
		
			// compute and display gps data
			gps_calc_disp(&gl1, &gl2, &gd);
			lcd_printf("I: %d\xb2 F: %d\xb2\nMg: %dm Sp: %d",
				(int)gd.initial_bearing,
				(int)gd.final_bearing,
				(int)gd.magnitude,
				(int)(1.15*gl2.sog + 0.5));
			
			// start / update logging
			if (logging_state) {
				// add to log
				fpic = gps_gen_name(img_counter++);
				camera_init();
				camera_takephoto(fpic, &fout);
				camera_sleep();
				log_add(&fout, &gl2, &gd, fpic);
			} else if (CHECK_LOGTOGGLE()) {
				// start logging
				logging_state = 1;
				flag_reset = 1;
				img_counter = 0;
				log_start(&fout);
			}
		}

	}
	
	return 0;
}
Beispiel #8
0
int main() {
  uint32_t i;
  int32_t x, y, rx, ry;

  init_partition(&partition, 0);
  printf("\n*** Initial partition ***\n");
  print_partition_details(&partition);

  for (i=0; i<40; i++) {
    x = random() % N;
    printf("--- testing %"PRId32" ---\n", x);
    y = partition_find(&partition, x);
    if (y < 0) {
      printf("item %"PRId32" not present; adding it\n", x);
      partition_add(&partition, x);
    } else {
      printf("root[%"PRId32"] = %"PRId32"\n", x, y);
    }
  }

  printf("\n*** Partition ***\n");
  print_partition_details(&partition);
  printf("\n");

  print_partition(&partition);
  printf("\n");

  for (x=0; x<N; x++) {
    aux[x] = partition_find(&partition, x);
  }
  for (i=1; i<10; i++) {
    do { x = random() % N; } while (aux[x] < 0);
    do { y = random() % N; } while (x == y || aux[y] < 0);

    x = partition_find(&partition, x);
    y = partition_find(&partition, y);
    if (x != y) {
      printf("--- Merging %"PRId32" and %"PRId32" ---\n", x, y);
      partition_merge(&partition, x, y);
    }
  }
  printf("\n");
  print_partition(&partition);

  reset_partition(&partition);

  for (i=0; i<100; i++) {
    x = random() % 300;
    rx = partition_find(&partition, x);
    if (rx < 0) {
      partition_add(&partition, x);
      rx = x;
    }
    y = random() % 300;
    ry = partition_find(&partition, y);
    if (ry < 0) {
      partition_add(&partition, y);
      ry = y;
    }
    if (rx != ry) {
      partition_merge(&partition, rx, ry);
    }
  }

  printf("\n\n");
  print_partition(&partition);

  delete_partition(&partition);

  return 0;
}