[coreboot] r45 - in trunk/filo-0.5: drivers/usb fs i386 main

svn at coreboot.org svn at coreboot.org
Fri Mar 28 15:25:18 CET 2008


Author: stepan
Date: 2008-03-28 15:25:16 +0100 (Fri, 28 Mar 2008)
New Revision: 45

Modified:
   trunk/filo-0.5/drivers/usb/scsi_cmds.c
   trunk/filo-0.5/drivers/usb/scsi_cmds.h
   trunk/filo-0.5/drivers/usb/usb.c
   trunk/filo-0.5/drivers/usb/usb_scsi_low.c
   trunk/filo-0.5/drivers/usb/usb_scsi_low.h
   trunk/filo-0.5/fs/fsys_iso9660.c
   trunk/filo-0.5/fs/iso9660.h
   trunk/filo-0.5/i386/ldscript
   trunk/filo-0.5/i386/segment.c
   trunk/filo-0.5/main/malloc.c
Log:
Some fixes for USB. 
Thanks to Fridel Fainshtain for the malloc/alignment hints.



Modified: trunk/filo-0.5/drivers/usb/scsi_cmds.c
===================================================================
--- trunk/filo-0.5/drivers/usb/scsi_cmds.c	2008-03-13 02:25:53 UTC (rev 44)
+++ trunk/filo-0.5/drivers/usb/scsi_cmds.c	2008-03-28 14:25:16 UTC (rev 45)
@@ -228,11 +228,11 @@
 	uchar control;
 } __attribute__ ((packed)) ReadBlockCMD_t ;
 
-int ll_read_block(devhandle sgd, char *buffer, int blocknum, int count)
+int ll_read_block(devhandle sgd, unsigned char *buffer, int blocknum, int count)
 {
 	int ret;
 	ReadBlockCMD_t rb;
-	char sensedat[32];
+	unsigned char sensedat[32];
 
 	memset(&rb,0,sizeof(rb));
 	rb.cmd = READ_10;
@@ -250,11 +250,11 @@
 
 }
 
-int ll_write_block(devhandle sgd, char *buffer, int blocknum, int count)
+int ll_write_block(devhandle sgd, unsigned char *buffer, int blocknum, int count)
 {
 	int ret;
 	ReadBlockCMD_t rb;
-	char sensedat[32];
+	unsigned char sensedat[32];
 
 	memset(&rb,0,sizeof(rb));
 	rb.cmd = WRITE_10;
@@ -281,11 +281,11 @@
 	uchar control;
 } __attribute__ ((packed)) ReadLongCMD_t ;
 
-int ll_read_long(devhandle sgd, char *buffer, int blocknum, int size)
+int ll_read_long(devhandle sgd, unsigned char *buffer, int blocknum, int size)
 {
 	int ret;
 	ReadLongCMD_t rb;
-	char sensedat[32];
+	unsigned char sensedat[32];
 
 	memset(&rb,0,sizeof(rb));
 	rb.cmd = READ_LONG;
@@ -307,7 +307,7 @@
 {
 	int ret;
 	struct ReadCapacityResponse response;
-	char sensedat[32];
+	unsigned char sensedat[32];
 
 	ret = scsi_command(sgd, ReadCapacityCMD, sizeof(ReadCapacityCMD), SG_DXFER_FROM_DEV, (uint8_t *)&response, sizeof(response), sensedat, sizeof(sensedat) );
 	if(ret<0) {
@@ -328,7 +328,7 @@
 int query(devhandle sgd, query_response_t *qr)
 {
 	int ret;
-	char sensedat[32];
+	unsigned char sensedat[32];
 
 	ret = scsi_command(sgd, InquiryCMD, sizeof(InquiryCMD), SG_DXFER_FROM_DEV, (uint8_t *)qr, sizeof(query_response_t), sensedat, sizeof(sensedat) );
 
@@ -351,7 +351,7 @@
 int ReportLUNS(devhandle sgd, lun_list_t *list)
 {
 	int ret;
-	char sensedat[32];
+	unsigned char sensedat[32];
 
 	memset (list, 0, sizeof(lun_list_t));
 	ret = scsi_command(sgd, ReportLunsCMD, sizeof(ReportLunsCMD), SG_DXFER_FROM_DEV, (uint8_t *)list, sizeof(lun_list_t), sensedat, sizeof(sensedat) );
@@ -399,7 +399,7 @@
 int ReportOpCodes(devhandle sgd, report_opcode_result_t *list)
 {
 	int ret;
-	char sensedat[32];
+	unsigned char sensedat[32];
 	ReportOpcodesCMD_t ReportOpcodesCMD;
 
 	memset (list, 0, sizeof(report_opcode_result_t));

Modified: trunk/filo-0.5/drivers/usb/scsi_cmds.h
===================================================================
--- trunk/filo-0.5/drivers/usb/scsi_cmds.h	2008-03-13 02:25:53 UTC (rev 44)
+++ trunk/filo-0.5/drivers/usb/scsi_cmds.h	2008-03-28 14:25:16 UTC (rev 45)
@@ -7,7 +7,7 @@
 #define ushort uint16_t
 
 void PrintSense(uchar *sense, int len);
-int ll_read_block(devhandle sgd, char *buffer, int blocknum, int count);
+int ll_read_block(devhandle sgd, unsigned char *buffer, int blocknum, int count);
 
 int get_capacity(devhandle sgd, unsigned long *block_count, unsigned int *blk_len);
 int UnitReady(uchar sgd);

Modified: trunk/filo-0.5/drivers/usb/usb.c
===================================================================
--- trunk/filo-0.5/drivers/usb/usb.c	2008-03-13 02:25:53 UTC (rev 44)
+++ trunk/filo-0.5/drivers/usb/usb.c	2008-03-28 14:25:16 UTC (rev 45)
@@ -155,7 +155,7 @@
 	ushort lang;
 
 	if(!string) {
-		strcpy(buffer, "unknown");
+		strcpy((char *)buffer, "unknown");
 		return(0);
 	}
 
@@ -191,7 +191,7 @@
                 real_len = len;
 
 	if(real_len<=4)  {
-		strcpy(buffer, "USB");
+		strcpy((char *)buffer, "USB");
 		real_len = 3;
 		buffer[real_len] = 0;
 	} else {

Modified: trunk/filo-0.5/drivers/usb/usb_scsi_low.c
===================================================================
--- trunk/filo-0.5/drivers/usb/usb_scsi_low.c	2008-03-13 02:25:53 UTC (rev 44)
+++ trunk/filo-0.5/drivers/usb/usb_scsi_low.c	2008-03-28 14:25:16 UTC (rev 45)
@@ -70,7 +70,7 @@
 } __attribute__ ((packed)) usb_csw_t;
 
 
-int scsi_command( uchar device, unsigned char *cmd, int cmd_len, int direction, unsigned char *data, int data_len, char *sense_data, int sense_len)
+int scsi_command( uchar device, unsigned char *cmd, int cmd_len, int direction, unsigned char *data, int data_len, unsigned char *sense_data, int sense_len)
 {
 	usb_cbw_t cbw;
 	usb_csw_t csw;
@@ -131,7 +131,7 @@
 	return(data_len - csw.residue);
 }
 
-int request_sense( uchar device, char *sense_data, int len)
+int request_sense( uchar device, unsigned char *sense_data, int len)
 {
 	usb_cbw_t cbw;
 	usb_csw_t csw;

Modified: trunk/filo-0.5/drivers/usb/usb_scsi_low.h
===================================================================
--- trunk/filo-0.5/drivers/usb/usb_scsi_low.h	2008-03-13 02:25:53 UTC (rev 44)
+++ trunk/filo-0.5/drivers/usb/usb_scsi_low.h	2008-03-28 14:25:16 UTC (rev 45)
@@ -4,7 +4,7 @@
 #define SG_DXFER_FROM_DEV -3
 #define SG_DXFER_TO_DEV -2
 
-int scsi_command( unsigned char device, unsigned char *cmd, int cmd_len, int direction, unsigned char *data, int data_len, char *sense_data, int sense_len);
-int request_sense( unsigned char device, char *sense_data, int len);
+int scsi_command( unsigned char device, unsigned char *cmd, int cmd_len, int direction, unsigned char *data, int data_len, unsigned char *sense_data, int sense_len);
+int request_sense( unsigned char device, unsigned char *sense_data, int len);
 
 #endif

Modified: trunk/filo-0.5/fs/fsys_iso9660.c
===================================================================
--- trunk/filo-0.5/fs/fsys_iso9660.c	2008-03-13 02:25:53 UTC (rev 44)
+++ trunk/filo-0.5/fs/fsys_iso9660.c	2008-03-28 14:25:16 UTC (rev 45)
@@ -151,7 +151,7 @@
 	  for (; idr->length.l > 0;
 		 idr = (struct iso_directory_record *)((char *)idr + idr->length.l) )
 	  {
-	      const char *name = idr->name;
+	      const unsigned char *name = idr->name;
 	      unsigned int name_len = idr->name_len.l;
 
 	      file_type = (idr->flags.l & 2) ? ISO_DIRECTORY : ISO_REGULAR;
@@ -236,7 +236,7 @@
 		      }
 		      rr_ptr.ptr = RRCONT_BUF + ce_ptr->u.ce.offset.l;
 		      rr_len = ce_ptr->u.ce.size.l;
-		      if (!iso9660_devread(ce_ptr->u.ce.extent.l, 0, ISO_SECTOR_SIZE, RRCONT_BUF))
+		      if (!iso9660_devread(ce_ptr->u.ce.extent.l, 0, ISO_SECTOR_SIZE, (char *)RRCONT_BUF))
 		      {
 			  errnum = 0;	/* this is not fatal. */
 			  break;

Modified: trunk/filo-0.5/fs/iso9660.h
===================================================================
--- trunk/filo-0.5/fs/iso9660.h	2008-03-13 02:25:53 UTC (rev 44)
+++ trunk/filo-0.5/fs/iso9660.h	2008-03-28 14:25:16 UTC (rev 45)
@@ -152,7 +152,7 @@
 
 typedef	union RR_ptr {
 	struct rock_ridge *rr;
-	char		  *ptr;
+	unsigned char		  *ptr;
 	int		   i;
 } RR_ptr_t;
 

Modified: trunk/filo-0.5/i386/ldscript
===================================================================
--- trunk/filo-0.5/i386/ldscript	2008-03-13 02:25:53 UTC (rev 44)
+++ trunk/filo-0.5/i386/ldscript	2008-03-28 14:25:16 UTC (rev 45)
@@ -8,8 +8,8 @@
  */
 BASE_ADDR = 0x100000;
 
-/* 16KB heap and stack */
-HEAP_SIZE = 16384;
+/* 32KB heap and 16k stack */
+HEAP_SIZE = 32768;
 STACK_SIZE = 16384;
 
 SECTIONS

Modified: trunk/filo-0.5/i386/segment.c
===================================================================
--- trunk/filo-0.5/i386/segment.c	2008-03-13 02:25:53 UTC (rev 44)
+++ trunk/filo-0.5/i386/segment.c	2008-03-28 14:25:16 UTC (rev 45)
@@ -48,7 +48,7 @@
     unsigned long new_offset;
     unsigned d0, d1, d2;
     struct gdtarg gdtarg;
-#define ALIGNMENT 16
+#define ALIGNMENT 0x1000
 
     prog_addr = virt_to_phys(&_start);
     prog_size = virt_to_phys(&_end) - virt_to_phys(&_start);

Modified: trunk/filo-0.5/main/malloc.c
===================================================================
--- trunk/filo-0.5/main/malloc.c	2008-03-13 02:25:53 UTC (rev 44)
+++ trunk/filo-0.5/main/malloc.c	2008-03-28 14:25:16 UTC (rev 45)
@@ -186,20 +186,24 @@
 
 
 // very dumb allot2 implementation to get 
-// usb stack working quickly. This should be
-// redone later..
-// 
-// note: this will fail if alignment is smaller than sizeof(unsigned long)
+// usb stack working quickly.
+
 void *allot2(size_t size, unsigned int alignment)
 {
 	void *addr;
 	unsigned long addrval;
-	addr=malloc(2*size);
 
+	if(((alignment + 1) & alignment) != 0) {
+		debug("alignment not power of 2");
+		return (void *)0;
+	}
+
+	addr=malloc(size + alignment + sizeof(unsigned long));
+
 	addrval=(unsigned long)addr;
 	addrval+=alignment+1; //  0x12345600 + 0xff + 1
 	addrval&=~alignment;  //  0x12345700
-	*(void * *)(addrval-sizeof(unsigned long))=addr;
+	*(unsigned long *)(addrval-sizeof(unsigned long))=addr;
 	return (void *)addrval;
 }
 
@@ -208,11 +212,9 @@
 	unsigned long addr=(unsigned long)mem;
 	
 	addr-=sizeof(unsigned long);
-	free((void *)(*(unsigned long *)addr));
+	free((void *)addr);
 }
 
-// end of ugly code.
-
 void malloc_diag(void)
 {
     debug("alloc: %lu bytes (%u blocks), free: %lu bytes (%u blocks)\n",





More information about the coreboot mailing list