-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
304 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./modules/network/lwnbdsvr/lwNBD/nbd-protocol.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,41 @@ | ||
#include "atad.h" | ||
|
||
int atad_init(struct nbd_context *me) | ||
static inline int atad_read_(nbd_context const *const me, void *buffer, uint64_t offset, uint32_t length) | ||
{ | ||
ata_devinfo_t *dev_info = ata_get_devinfo(0); | ||
if (dev_info != NULL && dev_info->exists) { | ||
me->export_size = (uint64_t)dev_info->total_sectors << me->blockshift; | ||
return 0; | ||
} | ||
return 1; | ||
return ata_device_sector_io(((atad_driver const *)me)->device, buffer, (uint32_t)offset, length, ATA_DIR_READ); | ||
} | ||
|
||
int atad_read(struct nbd_context *me, void *buffer, uint64_t offset, uint32_t length) | ||
static inline int atad_write_(nbd_context const *const me, void *buffer, uint64_t offset, uint32_t length) | ||
{ | ||
return ata_device_sector_io(0, buffer, (uint32_t)offset, length, ATA_DIR_READ); | ||
return ata_device_sector_io(((atad_driver const *)me)->device, buffer, (uint32_t)offset, length, ATA_DIR_WRITE); | ||
} | ||
|
||
int atad_write(struct nbd_context *me, void *buffer, uint64_t offset, uint32_t length) | ||
static inline int atad_flush_(nbd_context const *const me) | ||
{ | ||
return ata_device_sector_io(0, buffer, (uint32_t)offset, length, ATA_DIR_WRITE); | ||
return ata_device_flush_cache(((atad_driver const *)me)->device); | ||
} | ||
|
||
int atad_flush(struct nbd_context *me) | ||
int atad_ctor(atad_driver *const me, int device) | ||
{ | ||
return ata_device_flush_cache(0); | ||
me->device = device; | ||
ata_devinfo_t *dev_info = ata_get_devinfo(me->device); | ||
|
||
static struct nbd_context_Vtbl const vtbl = { | ||
&atad_read_, | ||
&atad_write_, | ||
&atad_flush_, | ||
}; | ||
|
||
me->super.vptr = &vtbl; /* override the vptr */ | ||
// int ata_device_sce_identify_drive(int device, void *data); | ||
strcpy(me->super.export_desc, "PlayStation 2 HDD via ATAD"); | ||
strcpy(me->super.export_name, "hdd0"); | ||
me->super.blockshift = 9; | ||
me->super.buffer = nbd_buffer; | ||
|
||
if (dev_info != NULL && dev_info->exists) { | ||
me->super.export_size = (uint64_t)dev_info->total_sectors << me->super.blockshift; | ||
return 0; | ||
} | ||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
BSD 2 - Clause License | ||
BSD 2-Clause License | ||
|
||
Copyright(c) 2021, | ||
Bignaux Ronan | ||
All rights reserved. | ||
Copyright (c) 2021, Bignaux Ronan | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, | ||
with or without | ||
modification, | ||
are permitted provided that the following conditions are met : | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and / | ||
or other materials provided with the distribution. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, | ||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.