⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basic.c

📁 如何制作ramdisk的一个好资料
💻 C
字号:
/*************************************************************
File Name: basic.c (RAMDisk 4.1)			     *
**************************************************************
Programmer: MSC
Last Modified Date: 2000/08/16
Compiler : GNU Cross-compiler/SDS
Platform : X86 protection mode, MIPS, Dragonball
Usage : basic ramdisk functions
*************************************************************/
//#include <sys/syscall.h>
//#include <sys/config.h>
//#include <kernel/malloc.h>
#include <ar2kreg.h>
#include <artsm.h>
#include <errno.h>

#include <malloc.h>
#include "../../FileSys/include/FileSys.h"
#include "../include/ramdisk.h"
//#include "../include/myansi.h"
#include "../include/dskblk.h"
#include "../include/basic.h"
#include "../include/piece.h"

#ifdef RAMDISK_ID
#ifdef RAMDISK_DEBUG
	//#include <ansi_c/stdio.h>
	/**** modified by chilong 8/23/2001 ****/
	#include <stdio.h>
	/**** modified by chilong 8/23/2001 ****/
	char RD_DebugString[80];
#else
	#ifdef RAMDISK_INIT_DEBUG
		//#include <ansi_c/stdio.h>
	/**** modified by chilong 8/23/2001 ****/
		#include <stdio.h>
	/**** modified by chilong 8/23/2001 ****/
		char RD_DebugString[80];
	#endif
#endif

/* The following are used in read_boot_sector */
void *RD_BootBegin = NULL;
unsigned long RD_DiskSize = 0;
unsigned long RD_SignSize = 0;

//int RD_SemaphoreID = -1;
int InitRD = FALSE;

unsigned char *RAMMemory = NULL;	// the starting location of the RAMDisk's first memory block

int RDerrno = 0;
int RDExist = 0;

unsigned long RDLowerBoundary = 0;	// the lower boundary of the RAMDisk
unsigned long RDUpperBoundary = 0;	// the upper boundary of the RAMDisk

char RD_Sign1[SIGN1_LEN] = "RAMDisk 4";
unsigned long RD_Sign2 = 0xDADA55AA;

//int RDOutput = TO_MONITOR;

//extern unsigned short * reset_status;//thhuang, 2002/5/15

/* piece.c */
extern unsigned long RDPieceSize;
extern void **RD_PLT;

/* dskblk.c */
extern struct diskBlock *RD_FirstFreeBlock;

// FileSys.c
//extern short *FileSysHandleTable[MAX_OPEN_FILE];
extern short **FileSysHandleTable;

/* fio.c */
extern struct RD_FILE	**RD_HandleTable;

#ifdef CURRENT_DIR_ENABLE
	extern unsigned char RD_CurrentPathname[MAX_PATH_LENGTH];
#endif

/* mallocX.c */

//	#define CHUNK_SIZE	32			/* 1 chunk = 32 bytes */

	// kernel/mm/superbmp/MallocSB.c
	extern struct memoryBitmap FreeChunkArraySB;
	extern unsigned long dbg_bmp_usage;	/* the number of small memory usage */
	extern unsigned long dbg_bmp_worst;	/* worst case of small memory usage (unit = 32byte) */


//extern unsigned char KernelInit;


void memoryZero(void *source, unsigned int size);



/*************************************************************
Function : ramdisk_init
Description :
	initialize the ramdisk
Inputs :
	size - size of ramdisk in sectors
Outputs :
	 0 - succeeded
	-1 - failed
Notes:
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -