📄 init_system.c
字号:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "general.h"
#include "sti_cli.h"
#include "hd_info_struct.h"
#include "dir_entry.h"
#include "msdos_dir_entry.h"
#include "d_inode.h"
#include "m_inode.h"
#include "buffer_head.h"
#include "fat_cache.h"
#include "file.h"
#include "hd_request_struct.h"
#include "super_block.h"
#include "common_head.h"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void format_hard(void)
{
struct buffer_head * bh;
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
cli();
bh = free_list;
bh->b_prev_free->b_next_free = bh->b_next_free;
bh->b_next_free->b_prev_free = bh->b_prev_free;
free_list = bh->b_next_free;
if (free_list == bh)
free_list = NULL;
sti();
bh->b_prev_free = bh->b_next_free = bh;
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
do_formatboot(bh);
do_formathard(bh);
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
cli();
bh->b_next_free = free_list;
bh->b_prev_free = free_list->b_prev_free;
free_list->b_prev_free->b_next_free = bh;
free_list->b_prev_free = bh;
free_list = bh;
sti();
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
return;
}
//////////////////////////////////////////////////////////////////////////////
void do_formatboot(struct buffer_head * temp_bh)
{
unsigned char * temp_pChar;
long * temp_pLong;
long temp_block;
long temp_dev,temp_cyl,temp_head,temp_sec;
int i;
/////////////////////////////////////////////////////////////////
temp_pChar = temp_bh->b_data;
for (i = 0; i < 1024; i++)
*temp_pChar++ = 0;
temp_pChar = temp_bh->b_data;
*(temp_pChar + 0x1be) = 0x80;
*(temp_pChar + 0x1c6) = 0x3f;
*(temp_pChar + 510) = 0x55;
*(temp_pChar + 511) = 0xaa;
temp_block = 0;
temp_dev = 0;
temp_sec = temp_block % hd_info[0].sect;
temp_block = temp_block / hd_info[0].sect;
temp_head = temp_block % hd_info[0].head;
temp_cyl = temp_block / hd_info[0].head;
if (!raw_wblock(temp_bh,temp_dev,temp_cyl,temp_head,temp_sec))
while(1);
/////////////////////////////////////////////////////////////////
temp_pChar = temp_bh->b_data;
*(temp_pChar + 0x1be) = 0x00;
*(temp_pChar + 0x1c6) = 0x00;
*(temp_pChar + 506) = 0x0e;
*(temp_pChar + 507) = 0x27;
temp_block = 63;
temp_dev = 0;
temp_sec = temp_block % hd_info[0].sect;
temp_block = temp_block / hd_info[0].sect;
temp_head = temp_block % hd_info[0].head;
temp_cyl = temp_block / hd_info[0].head;
if (!raw_wblock(temp_bh,temp_dev,temp_cyl,temp_head,temp_sec))
while(1);
/////////////////////////////////////////////////////////////////
return;
}
//////////////////////////////////////////////////////////////////////////////
void do_formathard(struct buffer_head * temp_bh)
{
unsigned char * temp_pChar;
long * temp_pLong;
struct d_inode * temp_pDinode;
struct dir_entry * temp_pDirentry;
long temp_block;
long temp_dev,temp_cyl,temp_head,temp_sec;
int i;
/////////////////////////////////////////////////////////////////
temp_pChar = temp_bh->b_data;
for (i = 0; i < 1024; i++)
*temp_pChar++ = 0;
temp_pChar = temp_bh->b_data;
temp_pLong = (long *)temp_pChar;
*temp_pLong++ = 3;
*temp_pLong++ = 1024;
*temp_pLong++ = 10000;
*temp_pLong++ = 10000;
*temp_pLong++ = 20000;
*temp_pLong++ = 10000;
*temp_pLong++ = 30000;
*temp_pLong++ = 10000;
*(temp_pChar + 510) = 0x55;
*(temp_pChar + 511) = 0xaa;
temp_block = 9998;
temp_dev = 0;
temp_sec = temp_block % hd_info[0].sect;
temp_block = temp_block / hd_info[0].sect;
temp_head = temp_block % hd_info[0].head;
temp_cyl = temp_block / hd_info[0].head;
if (!raw_wblock(temp_bh,temp_dev,temp_cyl,temp_head,temp_sec))
while(1);
/////////////////////////////////////////////////////////////////
temp_pChar = temp_bh->b_data;
for (i = 0; i < 1024; i++)
*temp_pChar++ = 0;
temp_pChar = temp_bh->b_data;
temp_pLong = (long *)temp_pChar;
*temp_pLong++ = 16 * 1024 - 1;
*temp_pLong++ = 5000;
*temp_pLong++ = 2;
*temp_pLong++ = 2;
*temp_pLong++ = 1 + 2 + 2 + 1024;
*temp_pLong++ = 0x19680124;
temp_block = 10000;
temp_dev = 0;
temp_sec = temp_block % hd_info[0].sect;
temp_block = temp_block / hd_info[0].sect;
temp_head = temp_block % hd_info[0].head;
temp_cyl = temp_block / hd_info[0].head;
if (!raw_wblock(temp_bh,temp_dev,temp_cyl,temp_head,temp_sec))
while(1);
/////////////////////////////////////////////////////////////////
temp_block = 20000;
temp_dev = 0;
temp_sec = temp_block % hd_info[0].sect;
temp_block = temp_block / hd_info[0].sect;
temp_head = temp_block % hd_info[0].head;
temp_cyl = temp_block / hd_info[0].head;
if (!raw_wblock(temp_bh,temp_dev,temp_cyl,temp_head,temp_sec))
while(1);
/////////////////////////////////////////////////////////////////
temp_block = 30000;
temp_dev = 0;
temp_sec = temp_block % hd_info[0].sect;
temp_block = temp_block / hd_info[0].sect;
temp_head = temp_block % hd_info[0].head;
temp_cyl = temp_block / hd_info[0].head;
if (!raw_wblock(temp_bh,temp_dev,temp_cyl,temp_head,temp_sec))
while(1);
/////////////////////////////////////////////////////////////////
temp_pChar = temp_bh->b_data;
for (i = 0; i < 1024; i++)
*temp_pChar++ = 0;
temp_pChar = temp_bh->b_data;
*temp_pChar++ = 0x07;
temp_block = 10002;
temp_dev = 0;
temp_sec = temp_block % hd_info[0].sect;
temp_block = temp_block / hd_info[0].sect;
temp_head = temp_block % hd_info[0].head;
temp_cyl = temp_block / hd_info[0].head;
if (!raw_wblock(temp_bh,temp_dev,temp_cyl,temp_head,temp_sec))
while(1);
/////////////////////////////////////////////////////////////////
temp_pChar = temp_bh->b_data;
*temp_pChar++ = 0x00;
temp_block = 10004;
temp_dev = 0;
temp_sec = temp_block % hd_info[0].sect;
temp_block = temp_block / hd_info[0].sect;
temp_head = temp_block % hd_info[0].head;
temp_cyl = temp_block / hd_info[0].head;
if (!raw_wblock(temp_bh,temp_dev,temp_cyl,temp_head,temp_sec))
while(1);
/////////////////////////////////////////////////////////////////
temp_pChar = temp_bh->b_data;
*temp_pChar++ = 0x03;
temp_block = 10006;
temp_dev = 0;
temp_sec = temp_block % hd_info[0].sect;
temp_block = temp_block / hd_info[0].sect;
temp_head = temp_block % hd_info[0].head;
temp_cyl = temp_block / hd_info[0].head;
if (!raw_wblock(temp_bh,temp_dev,temp_cyl,temp_head,temp_sec))
while(1);
/////////////////////////////////////////////////////////////////
temp_pChar = temp_bh->b_data;
*temp_pChar++ = 0x00;
temp_block = 10008;
temp_dev = 0;
temp_sec = temp_block % hd_info[0].sect;
temp_block = temp_block / hd_info[0].sect;
temp_head = temp_block % hd_info[0].head;
temp_cyl = temp_block / hd_info[0].head;
if (!raw_wblock(temp_bh,temp_dev,temp_cyl,temp_head,temp_sec))
while(1);
/////////////////////////////////////////////////////////////////
temp_pChar = temp_bh->b_data;
*temp_pChar++ = 0x07;
temp_block = 20002;
temp_dev = 0;
temp_sec = temp_block % hd_info[0].sect;
temp_block = temp_block / hd_info[0].sect;
temp_head = temp_block % hd_info[0].head;
temp_cyl = temp_block / hd_info[0].head;
if (!raw_wblock(temp_bh,temp_dev,temp_cyl,temp_head,temp_sec))
while(1);
/////////////////////////////////////////////////////////////////
temp_pChar = temp_bh->b_data;
*temp_pChar++ = 0x00;
temp_block = 20004;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -